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 8, 2021 21:11Sergey StreminSergey StreminScore: 10,204Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 21:1210,165138,900,28978,576,00033,243,0002,289,664
2May 8, 2021 21:1110,167142,032,46578,886,00032,952,0002,289,664
3May 8, 2021 21:1210,169141,717,61077,901,00033,956,0002,281,472
4May 8, 2021 21:1310,171137,456,75283,911,00027,970,0002,289,664
5May 8, 2021 21:1310,171136,858,03280,913,00030,966,0002,289,664
6May 8, 2021 21:1210,178138,203,63681,972,00029,989,0002,367,488
7May 8, 2021 21:1310,180137,551,36384,986,00026,995,0002,375,680
8May 8, 2021 21:1110,180135,078,71480,984,00030,994,0002,289,664
9May 8, 2021 21:1110,185136,588,69880,027,00032,010,0002,289,664
10May 8, 2021 21:1110,186137,133,55884,037,00028,012,0002,289,664
11May 8, 2021 21:1210,187134,709,56984,042,00028,014,0002,289,664
12May 8, 2021 21:1110,188134,675,90782,050,00030,018,0002,289,664
13May 8, 2021 21:1310,193132,909,78381,088,00031,033,0002,289,664
14May 8, 2021 21:1110,193133,328,07584,092,00028,030,0002,289,664
15May 8, 2021 21:1110,194134,840,55983,098,00029,034,0002,379,776
16May 8, 2021 21:1110,194136,370,31183,102,00029,035,0002,387,968
17May 8, 2021 21:1110,195134,445,72780,107,00032,042,0002,289,664
18May 8, 2021 21:1210,203134,680,16283,174,00029,060,0002,289,664
19May 8, 2021 21:1310,204135,391,06180,178,00032,071,0002,289,664
20May 8, 2021 21:1110,206131,505,23684,201,00028,067,0002,363,392
21May 8, 2021 21:1110,207132,851,02384,209,00028,069,0002,371,584
22May 8, 2021 21:1310,207134,671,17985,212,00027,067,0002,371,584
23May 8, 2021 21:1210,209140,033,50180,217,00032,087,0002,289,664
24May 8, 2021 21:1110,209134,843,88380,212,00032,085,0002,371,584
25May 8, 2021 21:1110,209139,362,29879,214,00033,089,0002,371,584
26May 8, 2021 21:1310,216137,194,70085,284,00027,090,0002,289,664
27May 8, 2021 21:1210,218140,717,99285,300,00027,095,0002,289,664
28May 8, 2021 21:1110,218132,663,31882,292,00030,107,0002,289,664
29May 8, 2021 21:1210,219134,203,11282,296,00030,108,0002,375,680
30May 8, 2021 21:1310,220137,310,28180,299,00032,119,0002,367,488
31May 8, 2021 21:1310,221135,455,31186,335,00026,101,0002,465,792
32May 8, 2021 21:1110,227133,310,96780,358,00032,143,0002,289,664
33May 8, 2021 21:1210,232139,810,46084,418,00028,139,0002,289,664
34May 8, 2021 21:1110,234141,834,01781,413,00031,158,0002,281,472
35May 8, 2021 21:1110,239140,602,42281,456,00031,174,0002,289,664
36May 8, 2021 21:1110,256137,865,52984,864,00027,955,0002,281,472