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:16Ilya AniskovetsIlya AniskovetsScore: 13,946Success
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:1613,716213,827,246150,878,38402,244,608
2Sep 19, 2021 12:1613,789216,815,923151,676,45302,244,608
3Sep 19, 2021 12:1613,796227,180,371151,756,08902,240,512
4Sep 19, 2021 12:1613,904175,569,020150,946,0001,999,0002,293,760
5Sep 19, 2021 12:1613,931180,538,977151,239,0002,003,0002,510,848
6Sep 19, 2021 12:1613,933178,209,176151,260,0002,003,0002,293,760
7Sep 19, 2021 12:1613,946179,069,430151,398,0002,005,0002,506,752
8Sep 19, 2021 12:1613,950175,117,341152,446,0001,002,0002,293,760
9Sep 19, 2021 12:1613,984180,123,935151,831,0001,997,0002,510,848
10Sep 19, 2021 12:1613,985176,708,191151,840,0001,997,0002,498,560
11Sep 19, 2021 12:1613,994177,334,337151,938,0001,999,0002,293,760
12Sep 19, 2021 12:1614,007178,157,694153,075,0001,000,0002,506,752