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:26Ilya AniskovetsIlya AniskovetsScore: 12,346Success
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:2612,263162,891,657132,900,0001,998,0002,293,760
2Sep 19, 2021 12:2612,278159,999,488133,058,0002,000,0002,293,760
3Sep 19, 2021 12:2612,281159,539,118133,088,0002,001,0002,289,664
4Sep 19, 2021 12:2612,282156,282,787133,098,0002,001,0002,293,760
5Sep 19, 2021 12:2612,305157,343,202134,357,0001,002,0002,490,368
6Sep 19, 2021 12:2612,332161,927,994134,646,0001,004,0002,293,760
7Sep 19, 2021 12:2612,346162,941,541133,806,0001,997,0002,506,752
8Sep 19, 2021 12:2612,347167,595,034133,819,0001,997,0002,293,760
9Sep 19, 2021 12:2612,584159,064,392137,426,0001,003,0002,293,760
10Sep 19, 2021 12:2612,885202,711,364141,736,04602,228,224
11Sep 19, 2021 12:2612,887212,903,795141,756,99102,236,416
12Sep 19, 2021 12:2612,896201,897,961141,857,30202,220,032