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:26Ilya AniskovetsIlya AniskovetsScore: 8,893Success
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:268,836124,494,64396,192,0001,002,0002,269,184
2Sep 27, 2021 20:268,844124,868,84695,277,0002,005,0002,289,664
3Sep 27, 2021 20:268,844118,554,56895,281,0002,005,0002,289,664
4Sep 27, 2021 20:268,847125,587,40396,315,0001,003,0002,531,328
5Sep 27, 2021 20:268,867126,240,71797,533,00002,281,472
6Sep 27, 2021 20:268,872123,655,55996,586,0001,006,0002,265,088
7Sep 27, 2021 20:268,893121,709,68996,823,000998,0002,289,664
8Sep 27, 2021 20:268,899126,500,54895,893,0001,997,0002,281,472
9Sep 27, 2021 20:268,901120,900,28895,910,0001,998,0002,289,664
10Sep 27, 2021 20:269,473166,215,901104,207,30202,265,088
11Sep 27, 2021 20:269,480191,690,372104,278,24402,265,088
12Sep 27, 2021 20:269,480170,433,108104,282,56102,265,088