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:48Joad NacerJoad NacerScore: 7,829Success
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:514,768112,803,22052,451,66902,273,280
2Apr 19, 2024 00:484,772112,320,88552,490,70102,265,088
3Apr 19, 2024 00:514,775114,026,32352,522,93602,265,088
4Apr 19, 2024 00:484,776105,513,55252,540,28302,269,184
5Apr 19, 2024 00:514,778111,461,69252,561,55902,269,184
6Apr 19, 2024 00:484,785127,343,47352,639,50202,400,256
7Apr 19, 2024 00:517,772110,814,03784,483,0001,005,0002,289,664
8Apr 19, 2024 00:517,818108,893,97784,001,0002,000,0002,273,280
9Apr 19, 2024 00:517,826109,503,66084,089,0002,002,0002,269,184
10Apr 19, 2024 00:517,827111,738,37285,101,0001,001,0002,289,664
11Apr 19, 2024 00:487,827111,134,58485,093,0001,001,0002,527,232
12Apr 19, 2024 00:517,829111,515,57885,117,0001,001,0002,289,664
13Apr 19, 2024 00:517,829111,178,18184,120,0002,002,0002,269,184
14Apr 19, 2024 00:487,830112,023,27584,125,0002,002,0002,289,664
15Apr 19, 2024 00:487,832108,664,44884,148,0002,003,0002,269,184
16Apr 19, 2024 00:517,839107,006,64585,231,0001,002,0002,392,064
17Apr 19, 2024 00:487,839108,700,28985,225,0001,002,0002,379,776
18Apr 19, 2024 00:487,844108,025,57884,275,0002,006,0002,273,280
19Apr 19, 2024 00:517,849111,228,09884,328,0002,007,0002,273,280
20Apr 19, 2024 00:517,921111,163,00186,130,0001,001,0002,273,280
21Apr 19, 2024 00:487,922109,720,98785,135,0002,003,0002,289,664
22Apr 19, 2024 00:487,934112,186,18985,270,0002,006,0002,289,664
23Apr 19, 2024 00:487,946109,604,61284,397,0003,014,0002,289,664
24Apr 19, 2024 00:487,951110,198,44285,450,0002,010,0002,355,200