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 5, 2021 09:18Yurkov AlekseyYurkov AlekseyScore: 6,721Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2021 09:206,69399,509,60972,619,0001,008,0002,277,376
2May 5, 2021 09:186,701100,116,07773,710,00002,277,376
3May 5, 2021 09:186,71198,657,42471,824,0001,995,0002,277,376
4May 5, 2021 09:186,71298,690,61171,836,0001,995,0002,371,584
5May 5, 2021 09:206,71396,108,74170,852,0002,993,0002,523,136
6May 5, 2021 09:186,715102,917,15170,876,0002,994,0002,273,280
7May 5, 2021 09:206,71698,915,86671,875,0001,996,0002,277,376
8May 5, 2021 09:186,71698,316,64371,882,0001,996,0002,277,376
9May 5, 2021 09:186,71698,990,50372,874,000998,0002,277,376
10May 5, 2021 09:206,71794,902,09171,893,0001,997,0002,273,280
11May 5, 2021 09:186,71995,913,58371,916,0001,997,0002,277,376
12May 5, 2021 09:186,71999,838,92171,908,0001,997,0002,277,376
13May 5, 2021 09:206,72195,978,59870,929,0002,997,0002,531,328
14May 5, 2021 09:186,72196,635,45371,932,0001,998,0002,277,376
15May 5, 2021 09:206,72296,833,19971,943,0001,998,0002,277,376
16May 5, 2021 09:186,72395,519,66571,954,0001,998,0002,367,488
17May 5, 2021 09:186,72497,094,50471,969,0001,999,0002,277,376
18May 5, 2021 09:206,72697,235,64970,988,0002,999,0002,273,280
19May 5, 2021 09:186,73098,124,18772,029,0002,000,0002,519,040
20May 5, 2021 09:186,731106,717,86971,038,0003,001,0002,277,376
21May 5, 2021 09:186,73297,942,60372,050,0002,001,0002,277,376
22May 5, 2021 09:186,73296,790,16372,054,0002,001,0002,351,104
23May 5, 2021 09:186,735102,605,85871,079,0003,003,0002,277,376
24May 5, 2021 09:206,73798,119,21472,105,0002,002,0002,277,376
25May 5, 2021 09:206,73896,274,53071,117,0003,004,0002,273,280
26May 5, 2021 09:186,74096,144,86072,133,0002,003,0002,269,184
27May 5, 2021 09:186,741101,331,27673,151,0001,002,0002,277,376