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:14Ilya AniskovetsIlya AniskovetsScore: 12,847Success
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:1412,539206,586,075137,933,50902,232,320
2Sep 19, 2021 12:1412,586192,246,920138,445,74602,240,512
3Sep 19, 2021 12:1412,826167,773,921139,088,0002,001,0002,285,568
4Sep 19, 2021 12:1412,829171,922,482139,114,0002,001,0002,334,720
5Sep 19, 2021 12:1412,831163,720,569140,145,0001,001,0002,293,760
6Sep 19, 2021 12:1412,834168,409,129139,174,0002,002,0002,293,760
7Sep 19, 2021 12:1412,847163,509,330139,316,0002,004,0002,289,664
8Sep 19, 2021 12:1412,850207,894,665141,353,06702,244,608
9Sep 19, 2021 12:1412,852164,629,619140,373,0001,002,0002,359,296
10Sep 19, 2021 12:1412,861172,514,220140,463,0001,003,0002,293,760
11Sep 19, 2021 12:1412,892167,856,185139,815,0001,997,0002,506,752
12Sep 19, 2021 12:1412,989165,813,931140,880,0001,998,0002,502,656