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 listMay 7, 2021 18:34Sergey StreminSergey StreminScore: 15,939Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 7, 2021 18:3315,896203,765,690146,883,00027,977,0002,289,664
2May 7, 2021 18:3415,908207,254,277144,986,00029,997,0002,289,664
3May 7, 2021 18:3415,918198,953,959144,077,00031,016,0002,289,664
4May 7, 2021 18:3415,919196,351,640143,091,00032,020,0002,469,888
5May 7, 2021 18:3315,921202,851,373139,101,00036,026,0002,281,472
6May 7, 2021 18:3315,922204,230,887147,117,00028,022,0002,371,584
7May 7, 2021 18:3415,926198,219,790141,148,00034,035,0002,281,472
8May 7, 2021 18:3315,935198,580,812145,234,00030,048,0002,289,664
9May 7, 2021 18:3315,938203,168,334145,263,00030,054,0002,289,664
10May 7, 2021 18:3415,939199,720,199144,272,00031,058,0002,375,680
11May 7, 2021 18:3415,940197,910,819147,282,00028,053,0002,478,080
12May 7, 2021 18:3415,942195,711,472149,312,00026,054,0002,289,664
13May 7, 2021 18:3315,943201,859,099148,313,00027,057,0002,289,664
14May 7, 2021 18:3315,948203,185,008143,348,00032,077,0002,289,664
15May 7, 2021 18:3315,962202,737,181142,472,00033,109,0002,289,664
16May 7, 2021 18:3315,963204,193,599146,493,00029,097,0002,469,888
17May 7, 2021 18:3415,984203,219,215144,852,00030,968,0002,289,664
18May 7, 2021 18:3415,992198,459,284142,933,00032,984,0002,289,664