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:10Ilya AniskovetsIlya AniskovetsScore: 13,871Success
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:1013,585216,159,981149,434,17602,236,416
2Sep 19, 2021 12:1013,593209,611,716149,518,11102,228,224
3Sep 19, 2021 12:1013,593207,808,785149,525,72302,224,128
4Sep 19, 2021 12:1013,823172,377,440151,054,0001,000,0002,293,760
5Sep 19, 2021 12:1013,830177,710,715150,125,0002,001,0002,293,760
6Sep 19, 2021 12:1013,866176,680,722151,527,0001,003,0002,293,760
7Sep 19, 2021 12:1013,871178,763,922151,574,0001,003,0002,498,560
8Sep 19, 2021 12:1013,874181,355,024151,610,0001,004,0002,281,472
9Sep 19, 2021 12:1013,875183,548,716151,620,0001,004,0002,293,760
10Sep 19, 2021 12:1013,879179,981,929151,661,0001,004,0002,523,136
11Sep 19, 2021 12:1013,911180,886,345152,020,0001,000,0002,506,752
12Sep 19, 2021 12:1013,919176,116,287151,104,0002,001,0002,506,752