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 27, 2021 20:16Ilya AniskovetsIlya AniskovetsScore: 8,594Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 27, 2021 20:168,556116,457,11292,118,0002,002,0002,289,664
2Sep 27, 2021 20:168,571119,835,73193,280,0001,003,0002,289,664
3Sep 27, 2021 20:168,578121,519,08692,352,0002,007,0002,387,968
4Sep 27, 2021 20:168,585121,003,70392,425,0002,009,0002,289,664
5Sep 27, 2021 20:168,586117,642,20793,444,0001,004,0002,289,664
6Sep 27, 2021 20:168,587115,530,32193,449,0001,004,0002,289,664
7Sep 27, 2021 20:168,594115,562,15993,524,0001,005,0002,289,664
8Sep 27, 2021 20:168,599124,912,86193,580,0001,006,0002,289,664
9Sep 27, 2021 20:168,603120,987,14993,627,0001,006,0002,289,664
10Sep 27, 2021 20:169,273154,874,120101,999,75502,265,088
11Sep 27, 2021 20:169,278168,772,532102,060,61802,265,088
12Sep 27, 2021 20:169,279153,205,483102,070,78102,265,088