Parse JSON Sergey Svistunov

Compute the total amount of non-canceled external USD transactions from a stream of JSON records as fast as possible.

Input: 1 000 000 JSON records on STDIN, one per line. Each record has the following structure:

{
    "user_id": 0,
    "currency": "USD",
    "transactions": [
        {
            "amount": 0,
            "to_user_id": 0,
            "canceled": false
        }
    ]
}
Field Constraints
user_id Integer, max 10 000
currency One of "GBP", "USD", "RUB", "JPY", "CHF"
transactions Array, max 10 elements
amount Integer, max 1000
canceled Boolean; may be omitted when false

Field order is not guaranteed within any object.

Output: The total amount of all transactions where:

  • record.currency == "USD"
  • transaction.to_user_id != record.user_id (external)
  • transaction.canceled is false or absent
Back to listMay 20, 2021 05:58Yuriy LyfenkoYuriy LyfenkoScore: 5,608Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 20, 2021 05:585,596831,343,93660,565,000992,0002,265,088
2May 20, 2021 05:585,5982,823,208,93960,583,000993,0002,523,136
3May 20, 2021 05:585,5984,577,732,63859,595,0001,986,0002,523,136
4May 20, 2021 05:585,5991,847,976,69960,579,0001,009,0002,510,848
5May 20, 2021 05:585,602568,464,82961,627,00002,265,088
6May 20, 2021 05:585,6073,309,174,19559,688,0001,989,0002,523,136
7May 20, 2021 05:585,6083,064,679,69559,696,0001,989,0002,260,992
8May 20, 2021 05:585,6093,670,870,81460,703,000995,0002,260,992
9May 20, 2021 05:585,6194,515,774,80860,817,000997,0002,260,992
10May 20, 2021 05:585,8803,522,685,43664,685,04902,252,800
11May 20, 2021 05:585,8821,695,346,34564,704,58102,248,704
12May 20, 2021 05:585,889701,908,35264,774,82502,248,704