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 listApr 19, 2024 00:06Joad NacerJoad NacerScore: 7,814Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2024 00:064,751120,745,23652,259,56402,256,896
2Apr 19, 2024 00:074,753118,835,67452,286,80802,277,376
3Apr 19, 2024 00:074,754108,791,47252,292,70502,260,992
4Apr 19, 2024 00:064,759127,459,91652,344,31902,273,280
5Apr 19, 2024 00:064,761114,048,57752,369,68602,260,992
6Apr 19, 2024 00:074,762129,778,13652,382,27102,277,376
7Apr 19, 2024 00:077,804109,003,53984,841,000998,0002,289,664
8Apr 19, 2024 00:077,807115,456,58483,876,0001,997,0002,269,184
9Apr 19, 2024 00:077,811108,909,99483,920,0001,998,0002,531,328
10Apr 19, 2024 00:077,811110,474,67583,923,0001,998,0002,289,664
11Apr 19, 2024 00:067,812109,986,16583,932,0001,998,0002,289,664
12Apr 19, 2024 00:077,813110,887,34583,948,0001,998,0002,531,328
13Apr 19, 2024 00:067,814108,836,25484,956,000999,0002,289,664
14Apr 19, 2024 00:067,818110,706,30283,997,0001,999,0002,289,664
15Apr 19, 2024 00:067,820108,107,04384,024,0002,000,0002,289,664
16Apr 19, 2024 00:067,823109,726,21086,056,00002,379,776
17Apr 19, 2024 00:067,826111,368,71784,084,0002,002,0002,289,664
18Apr 19, 2024 00:067,826109,353,48586,084,00002,527,232
19Apr 19, 2024 00:077,827110,658,15484,098,0002,002,0002,519,040
20Apr 19, 2024 00:067,828109,137,60184,103,0002,002,0002,269,184
21Apr 19, 2024 00:077,829119,481,53884,119,0002,002,0002,289,664
22Apr 19, 2024 00:077,831107,592,77084,134,0002,003,0002,289,664
23Apr 19, 2024 00:077,832107,760,75884,150,0002,003,0002,289,664
24Apr 19, 2024 00:067,833114,442,08885,166,0001,001,0002,519,040