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:04Ilya AniskovetsIlya AniskovetsScore: 13,731Success
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:0413,638181,714,752148,013,0002,000,0002,289,664
2Sep 19, 2021 12:0413,679172,420,380149,471,0001,003,0002,293,760
3Sep 19, 2021 12:0413,682172,728,468149,494,0001,003,0002,506,752
4Sep 19, 2021 12:0413,689180,021,709149,579,0001,003,0002,293,760
5Sep 19, 2021 12:0413,689175,355,083150,584,00002,293,760
6Sep 19, 2021 12:0413,695178,896,600149,646,0001,004,0002,519,040
7Sep 19, 2021 12:0413,731173,252,119149,045,0002,000,0002,326,528
8Sep 19, 2021 12:0413,734181,199,205150,074,0001,000,0002,293,760
9Sep 19, 2021 12:0413,879177,653,418151,669,000997,0002,289,664
10Sep 19, 2021 12:0414,614220,334,011160,751,14402,232,320
11Sep 19, 2021 12:0414,638222,373,817161,020,00302,224,128
12Sep 19, 2021 12:0414,658213,536,663161,243,43402,240,512