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 19, 2021 12:23Ilya AniskovetsIlya AniskovetsScore: 12,152Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 19, 2021 12:2312,115152,862,711131,264,0002,004,0002,293,760
2Sep 19, 2021 12:2312,124156,565,141133,367,00002,293,760
3Sep 19, 2021 12:2312,130155,362,766133,433,00002,494,464
4Sep 19, 2021 12:2312,132205,154,332133,455,34202,244,608
5Sep 19, 2021 12:2312,132154,474,285132,446,0001,003,0002,293,760
6Sep 19, 2021 12:2312,143201,559,569133,572,42002,215,936
7Sep 19, 2021 12:2312,152166,685,405133,669,00002,293,760
8Sep 19, 2021 12:2312,157163,173,079131,733,0001,995,0002,293,760
9Sep 19, 2021 12:2312,165160,818,368131,820,0001,997,0002,273,280
10Sep 19, 2021 12:2312,166160,474,879131,824,0001,997,0002,293,760
11Sep 19, 2021 12:2312,177161,555,413131,952,0001,999,0002,293,760
12Sep 19, 2021 12:2312,196191,106,341134,151,99502,224,128