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 2, 2021 16:27Yurkov AlekseyYurkov AlekseyScore: 8,937Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:318,907118,730,31496,979,000999,0002,523,136
2May 2, 2021 16:288,912120,696,11495,029,0003,000,0002,277,376
3May 2, 2021 16:278,913125,164,88395,037,0003,001,0002,277,376
4May 2, 2021 16:298,917120,185,58396,090,0002,001,0002,392,064
5May 2, 2021 16:318,918120,690,99097,097,0001,001,0002,527,232
6May 2, 2021 16:288,919120,073,27796,107,0002,002,0002,277,376
7May 2, 2021 16:318,920127,075,99796,123,0002,002,0002,523,136
8May 2, 2021 16:298,920124,434,15596,116,0002,002,0002,277,376
9May 2, 2021 16:318,923118,575,89696,148,0002,003,0002,531,328
10May 2, 2021 16:288,926119,323,27197,182,0001,001,0002,404,352
11May 2, 2021 16:288,927125,295,68996,189,0002,003,0002,277,376
12May 2, 2021 16:318,927124,933,01096,194,0002,004,0002,281,472
13May 2, 2021 16:298,927121,741,34297,198,0001,002,0002,277,376
14May 2, 2021 16:278,929123,790,47696,219,0002,004,0002,277,376
15May 2, 2021 16:298,929126,219,91396,211,0002,004,0002,277,376
16May 2, 2021 16:288,929126,980,08796,216,0002,004,0002,277,376
17May 2, 2021 16:298,932129,657,99496,248,0002,005,0002,277,376
18May 2, 2021 16:318,934121,466,44996,266,0002,005,0002,277,376
19May 2, 2021 16:298,937124,732,69896,303,0002,006,0002,269,184
20May 2, 2021 16:288,939120,854,33996,325,0002,006,0002,277,376
21May 2, 2021 16:288,940128,106,96295,325,0003,010,0002,277,376
22May 2, 2021 16:318,941121,750,54697,351,0001,003,0002,281,472
23May 2, 2021 16:298,941120,862,14996,347,0002,007,0002,269,184
24May 2, 2021 16:278,943122,145,83596,367,0002,007,0002,277,376
25May 2, 2021 16:288,945121,746,59598,392,00002,519,040
26May 2, 2021 16:278,945125,239,40597,391,0001,004,0002,269,184
27May 2, 2021 16:288,946128,014,53797,400,0001,004,0002,273,280
28May 2, 2021 16:318,946123,774,21097,404,0001,004,0002,273,280
29May 2, 2021 16:278,948125,083,22296,425,0002,008,0002,523,136
30May 2, 2021 16:278,949123,433,47797,434,0001,004,0002,277,376
31May 2, 2021 16:318,952121,021,47796,464,0002,009,0002,277,376
32May 2, 2021 16:298,954125,230,78295,476,0003,015,0002,359,296
33May 2, 2021 16:278,956118,761,34397,509,0001,005,0002,277,376
34May 2, 2021 16:298,959123,785,02597,541,0001,005,0002,269,184
35May 2, 2021 16:278,968126,649,52097,638,0001,006,0002,277,376
36May 2, 2021 16:278,982123,729,05596,807,0001,996,0002,277,376