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 11:07Yurkov AlekseyYurkov AlekseyScore: 6,752Success
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 11:086,72598,766,00471,976,0001,999,0002,277,376
2May 4, 2021 11:076,72899,855,26371,006,0003,000,0002,367,488
3May 4, 2021 11:086,73494,476,38572,076,0002,002,0002,277,376
4May 4, 2021 11:086,73498,980,28272,068,0002,001,0002,277,376
5May 4, 2021 11:086,73597,113,75672,085,0002,002,0002,277,376
6May 4, 2021 11:076,737102,585,18873,103,0001,001,0002,277,376
7May 4, 2021 11:086,738102,617,53572,112,0002,003,0002,277,376
8May 4, 2021 11:086,73998,150,13973,130,0001,001,0002,265,088
9May 4, 2021 11:086,74295,485,65972,162,0002,004,0002,531,328
10May 4, 2021 11:086,74599,029,11371,189,0003,008,0002,277,376
11May 4, 2021 11:086,74695,674,73473,206,0001,002,0002,273,280
12May 4, 2021 11:076,74897,039,84973,227,0001,003,0002,269,184
13May 4, 2021 11:076,75197,615,85072,253,0002,007,0002,281,472
14May 4, 2021 11:086,75298,397,95273,269,0001,003,0002,277,376
15May 4, 2021 11:086,75595,923,42872,300,0002,008,0002,265,088
16May 4, 2021 11:086,75598,745,83171,288,0003,012,0002,277,376
17May 4, 2021 11:076,755105,027,72572,301,0002,008,0002,277,376
18May 4, 2021 11:086,75897,402,57674,335,00002,277,376
19May 4, 2021 11:076,76096,358,87772,353,0002,009,0002,277,376
20May 4, 2021 11:086,763100,762,02872,385,0002,010,0002,265,088
21May 4, 2021 11:086,76495,444,20572,393,0002,010,0002,277,376
22May 4, 2021 11:086,76497,186,37274,402,00002,277,376
23May 4, 2021 11:086,767100,625,68072,431,0002,011,0002,277,376
24May 4, 2021 11:076,770100,776,73772,462,0002,012,0002,277,376
25May 4, 2021 11:076,772102,485,29474,496,00002,531,328
26May 4, 2021 11:076,77399,174,31574,498,00002,277,376
27May 4, 2021 11:086,791100,648,52672,680,0002,018,0002,269,184