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:11Ilya AniskovetsIlya AniskovetsScore: 11,641Success
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:1111,620158,095,046125,825,0001,997,0002,289,664
2Sep 27, 2021 20:1111,623157,953,117125,857,0001,997,0002,289,664
3Sep 27, 2021 20:1111,626159,528,855125,887,0001,998,0002,289,664
4Sep 27, 2021 20:1111,627152,151,831125,902,0001,998,0002,277,376
5Sep 27, 2021 20:1111,632149,902,401126,956,000999,0002,277,376
6Sep 27, 2021 20:1111,639150,986,991126,031,0002,000,0002,392,064
7Sep 27, 2021 20:1111,641156,159,471126,049,0002,000,0002,289,664
8Sep 27, 2021 20:1111,643150,985,035126,077,0002,001,0002,281,472
9Sep 27, 2021 20:1111,656152,225,415126,217,0002,003,0002,269,184
10Sep 27, 2021 20:1112,222197,270,407134,443,29102,265,088
11Sep 27, 2021 20:1112,249196,643,062134,742,84702,265,088
12Sep 27, 2021 20:1112,269203,857,665134,957,05402,260,992