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 listMay 4, 2021 23:11Yurkov AlekseyYurkov AlekseyScore: 6,713Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2021 23:116,68396,340,04771,504,0002,014,0002,383,872
2May 4, 2021 23:096,68698,688,94971,532,0002,014,0002,277,376
3May 4, 2021 23:076,68999,164,40273,578,00002,387,968
4May 4, 2021 23:116,690103,051,12373,585,00002,277,376
5May 4, 2021 23:076,691102,592,07872,594,0001,008,0002,273,280
6May 4, 2021 23:076,691100,187,12472,588,0001,008,0002,277,376
7May 4, 2021 23:096,69197,119,91871,580,0002,016,0002,277,376
8May 4, 2021 23:076,692100,808,12572,603,0001,008,0002,277,376
9May 4, 2021 23:076,69398,470,60571,607,0002,017,0002,281,472
10May 4, 2021 23:116,69498,951,89871,612,0002,017,0002,531,328
11May 4, 2021 23:096,69499,083,74772,624,0001,008,0002,265,088
12May 4, 2021 23:116,70099,837,47073,698,00002,375,680
13May 4, 2021 23:096,71399,787,14671,845,0001,995,0002,277,376
14May 4, 2021 23:076,71398,322,36071,852,0001,995,0002,277,376
15May 4, 2021 23:096,713101,825,53172,850,000997,0002,265,088
16May 4, 2021 23:096,713102,523,48772,842,000997,0002,527,232
17May 4, 2021 23:116,71399,259,75771,853,0001,995,0002,527,232
18May 4, 2021 23:096,714101,306,61170,861,0002,994,0002,273,280
19May 4, 2021 23:116,714100,710,83373,855,00002,277,376
20May 4, 2021 23:076,71498,116,62473,852,00002,269,184
21May 4, 2021 23:116,715100,749,86571,842,0002,023,0002,277,376
22May 4, 2021 23:076,715107,206,73471,867,0001,996,0002,277,376
23May 4, 2021 23:076,71598,431,01371,869,0001,996,0002,277,376
24May 4, 2021 23:096,71795,918,27171,888,0001,996,0002,277,376
25May 4, 2021 23:096,722102,223,31671,948,0001,998,0002,277,376
26May 4, 2021 23:116,72899,459,01172,012,0002,000,0002,277,376
27May 4, 2021 23:116,73796,995,81872,106,0002,002,0002,277,376