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 5, 2021 12:35Andrey TsvetkovAndrey TsvetkovScore: 8,945Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2021 12:358,920124,571,59797,117,0001,001,0002,334,720
2Sep 5, 2021 12:358,922122,594,55595,133,0003,004,0002,334,720
3Sep 5, 2021 12:358,924120,460,87096,160,0002,003,0002,334,720
4Sep 5, 2021 12:358,927122,636,89095,195,0003,006,0002,334,720
5Sep 5, 2021 12:358,930120,881,84296,224,0002,004,0002,281,472
6Sep 5, 2021 12:358,930122,157,20397,233,0001,002,0002,334,720
7Sep 5, 2021 12:358,945120,921,57594,375,0004,015,0002,535,424
8Sep 5, 2021 12:358,949118,527,70195,427,0003,013,0002,293,760
9Sep 5, 2021 12:358,970165,360,48198,673,44202,232,320
10Sep 5, 2021 12:358,971130,008,84896,664,0002,013,0002,289,664
11Sep 5, 2021 12:358,993166,037,17398,926,67202,240,512
12Sep 5, 2021 12:359,375177,541,130103,124,62502,215,936