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:19Ilya AniskovetsIlya AniskovetsScore: 12,619Success
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:1912,379198,610,277136,169,41102,215,936
2Sep 19, 2021 12:1912,381197,590,208136,188,90402,220,032
3Sep 19, 2021 12:1912,383205,071,362136,215,31202,240,512
4Sep 19, 2021 12:1912,566161,827,860137,228,0001,001,0002,293,760
5Sep 19, 2021 12:1912,575170,089,321136,323,0002,004,0002,510,848
6Sep 19, 2021 12:1912,598170,127,571137,573,0001,004,0002,293,760
7Sep 19, 2021 12:1912,619165,132,461137,814,000998,0002,289,664
8Sep 19, 2021 12:1912,621163,790,194137,837,000998,0002,498,560
9Sep 19, 2021 12:1912,622168,595,356136,849,0001,997,0002,293,760
10Sep 19, 2021 12:1912,628165,753,432136,905,0001,998,0002,293,760
11Sep 19, 2021 12:1912,630159,991,912136,927,0001,998,0002,342,912
12Sep 19, 2021 12:1912,647162,088,441137,113,0002,001,0002,277,376