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 17:07Yurkov AlekseyYurkov AlekseyScore: 7,132Success
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 17:587,109102,517,11176,191,0002,005,0002,277,376
2May 2, 2021 17:097,109103,704,71776,194,0002,005,0002,277,376
3May 2, 2021 17:097,11199,654,18777,218,0001,002,0002,277,376
4May 2, 2021 17:097,11899,378,06177,300,0001,003,0002,527,232
5May 2, 2021 17:077,11898,786,17077,295,0001,003,0002,523,136
6May 2, 2021 17:097,11999,836,99177,308,0001,004,0002,277,376
7May 2, 2021 17:587,121103,252,83277,332,0001,004,0002,277,376
8May 2, 2021 17:587,122110,181,90076,339,0002,008,0002,277,376
9May 2, 2021 17:097,122105,736,77278,345,00002,527,232
10May 2, 2021 17:587,122104,321,59677,340,0001,004,0002,277,376
11May 2, 2021 17:097,125100,809,34576,370,0002,009,0002,277,376
12May 2, 2021 17:077,126100,662,39977,378,0001,004,0002,269,184
13May 2, 2021 17:107,126108,352,71776,373,0002,009,0002,273,280
14May 2, 2021 17:107,12699,995,17176,374,0002,009,0002,269,184
15May 2, 2021 17:107,126106,220,22777,380,0001,004,0002,277,376
16May 2, 2021 17:587,12699,906,61677,380,0001,004,0002,277,376
17May 2, 2021 17:097,127110,294,99877,388,0001,005,0002,379,776
18May 2, 2021 17:097,12999,457,65577,413,0001,005,0002,269,184
19May 2, 2021 17:587,130100,739,85675,414,0003,016,0002,277,376
20May 2, 2021 17:097,13199,369,01776,433,0002,011,0002,269,184
21May 2, 2021 17:107,131110,027,27976,426,0002,011,0002,277,376
22May 2, 2021 17:097,131103,879,83777,432,0001,005,0002,277,376
23May 2, 2021 17:107,13297,139,72878,452,00002,277,376
24May 2, 2021 17:107,132105,380,04277,443,0001,005,0002,527,232
25May 2, 2021 17:077,132102,194,73477,448,0001,005,0002,527,232
26May 2, 2021 17:077,132104,292,44678,452,00002,277,376
27May 2, 2021 17:587,132100,186,12675,435,0003,017,0002,277,376
28May 2, 2021 17:107,134100,300,62377,467,0001,006,0002,527,232
29May 2, 2021 17:097,136105,102,41976,480,0002,012,0002,277,376
30May 2, 2021 17:107,137101,690,51277,497,0001,006,0002,273,280
31May 2, 2021 17:097,138100,266,49878,516,00002,383,872
32May 2, 2021 17:097,139103,304,44077,528,0001,006,0002,277,376
33May 2, 2021 17:097,140100,709,52877,532,0001,006,0002,527,232
34May 2, 2021 17:077,140106,883,15577,529,0001,006,0002,531,328
35May 2, 2021 17:097,14199,204,06877,539,0001,007,0002,519,040
36May 2, 2021 17:097,14399,280,43677,563,0001,007,0002,269,184
37May 2, 2021 17:587,143100,831,10077,564,0001,007,0002,273,280
38May 2, 2021 17:587,143105,935,44577,571,0001,007,0002,277,376
39May 2, 2021 17:097,143106,850,60077,565,0001,007,0002,277,376
40May 2, 2021 17:097,147111,205,45278,621,00002,277,376
41May 2, 2021 17:077,150112,668,31977,643,0001,008,0002,277,376
42May 2, 2021 17:077,152105,547,25777,659,0001,008,0002,277,376
43May 2, 2021 17:077,155109,541,01576,712,0001,992,0002,277,376
44May 2, 2021 17:107,167105,821,08576,845,0001,995,0002,355,200
45May 2, 2021 17:077,169105,003,76377,857,000998,0002,277,376