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 listSep 27, 2021 20:20Ilya AniskovetsIlya AniskovetsScore: 8,621Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 27, 2021 20:208,583116,681,82594,413,00002,289,664
2Sep 27, 2021 20:208,596118,204,56393,549,0001,005,0002,289,664
3Sep 27, 2021 20:208,596116,612,21194,558,00002,277,376
4Sep 27, 2021 20:208,610128,108,28893,699,0001,007,0002,289,664
5Sep 27, 2021 20:208,612119,475,97192,741,0001,994,0002,281,472
6Sep 27, 2021 20:208,620119,500,20492,823,0001,996,0002,527,232
7Sep 27, 2021 20:208,621126,564,70894,831,00002,289,664
8Sep 27, 2021 20:208,622122,676,07392,848,0001,996,0002,277,376
9Sep 27, 2021 20:208,633116,951,75992,969,0001,999,0002,289,664
10Sep 27, 2021 20:209,290155,885,721102,186,35602,265,088
11Sep 27, 2021 20:209,293172,672,791102,217,95702,256,896
12Sep 27, 2021 20:209,321164,329,165102,531,29302,269,184