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 listSep 3, 2024 18:58Yuriy LyfenkoYuriy LyfenkoScore: 3,834Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 3, 2024 19:013,81264,111,38239,940,0001,997,0002,273,280
2Dec 12, 2024 18:203,81669,199,94139,976,0001,998,0002,453,504
3Sep 3, 2024 19:023,81864,163,41039,995,0001,999,0002,453,504
4Sep 3, 2024 18:583,81964,359,58640,007,0002,000,0002,273,280
5Sep 3, 2024 19:023,82060,533,62440,023,0002,001,0002,273,280
6Sep 3, 2024 19:013,82168,550,55140,031,0002,001,0002,269,184
7Sep 3, 2024 18:583,82261,928,98340,036,0002,001,0002,445,312
8Sep 3, 2024 18:583,82263,045,42640,041,0002,002,0002,535,424
9Sep 3, 2024 19:013,82263,766,39440,043,0002,002,0002,531,328
10Sep 3, 2024 19:013,82359,115,51540,046,0002,002,0002,535,424
11Sep 3, 2024 19:023,82367,358,41040,054,0002,002,0002,535,424
12Sep 3, 2024 18:583,82463,759,87640,057,0002,002,0002,531,328
13Sep 3, 2024 19:013,82464,372,35540,060,0002,003,0002,535,424
14Sep 3, 2024 19:013,82468,196,46340,066,0002,003,0002,269,184
15Sep 3, 2024 18:583,82561,292,37940,072,0002,003,0002,531,328
16Sep 3, 2024 18:583,82764,028,00940,095,0002,004,0002,531,328
17Sep 3, 2024 18:583,82764,142,20040,096,0002,004,0002,531,328
18Sep 3, 2024 19:013,82765,445,34840,097,0002,004,0002,535,424
19Sep 3, 2024 18:583,82960,188,06240,119,0002,005,0002,273,280
20Sep 3, 2024 18:583,82964,238,80140,117,0002,005,0002,273,280
21Sep 3, 2024 19:013,82963,700,77840,119,0002,005,0002,445,312
22Sep 3, 2024 19:013,82964,614,65840,118,0002,005,0002,449,408
23Sep 3, 2024 19:013,82963,911,97040,110,0002,005,0002,535,424
24Sep 3, 2024 18:583,83064,048,66140,122,0002,006,0002,531,328
25Dec 12, 2024 18:203,83172,437,56740,134,0002,006,0002,531,328
26Sep 3, 2024 19:023,83262,725,43240,145,0002,007,0002,269,184
27Sep 3, 2024 19:013,83367,242,93440,152,0002,007,0002,269,184
28Dec 12, 2024 18:203,83463,819,26140,167,0002,008,0002,453,504
29Sep 3, 2024 19:013,83463,963,65340,162,0002,008,0002,445,312
30Sep 3, 2024 19:023,83464,173,63640,171,0002,008,0002,457,600
31Sep 3, 2024 19:023,83563,880,85140,178,0002,008,0002,453,504
32Sep 3, 2024 19:023,83666,444,84940,183,0002,009,0002,535,424
33Sep 3, 2024 19:013,83862,833,82940,206,0002,010,0002,461,696
34Sep 3, 2024 19:013,83973,447,19240,218,0002,010,0002,453,504
35Sep 3, 2024 19:013,83965,030,09040,220,0002,011,0002,531,328
36Sep 3, 2024 18:583,83966,668,59240,218,0002,010,0002,531,328
37Sep 3, 2024 19:013,84066,320,86341,233,0001,005,0002,445,312
38Sep 3, 2024 19:023,84064,948,85241,237,0001,005,0002,273,280
39Sep 3, 2024 19:013,84160,204,38241,247,0001,006,0002,273,280
40Sep 3, 2024 19:023,84168,454,58540,237,0002,011,0002,453,504
41Sep 3, 2024 18:583,84361,327,94541,264,0001,006,0002,535,424
42Sep 3, 2024 18:583,84464,795,02041,275,0001,006,0002,535,424
43Sep 3, 2024 18:583,84464,793,26041,276,0001,006,0002,453,504
44Sep 3, 2024 18:583,84563,125,15441,284,0001,006,0002,273,280
45Sep 3, 2024 19:013,84963,571,25941,333,0001,008,0002,273,280
46Sep 3, 2024 19:013,85163,457,95342,362,00002,527,232
47Sep 3, 2024 19:023,85263,001,18241,365,0001,008,0002,445,312
48Sep 3, 2024 19:013,85266,283,56941,360,0001,008,0002,535,424
49Sep 3, 2024 19:023,85267,007,99541,360,0001,008,0002,535,424
50Sep 3, 2024 18:583,85263,573,66542,368,00002,453,504
51Sep 3, 2024 18:583,85372,269,60941,373,0001,009,0002,535,424
52Sep 3, 2024 19:013,85464,167,59141,383,0001,009,0002,535,424
53Sep 3, 2024 19:013,85863,976,50641,432,0001,010,0002,531,328
54Sep 3, 2024 19:013,85961,986,11341,434,0001,010,0002,273,280
55Sep 3, 2024 19:013,86164,447,38941,462,0001,011,0002,531,328
56Sep 3, 2024 19:023,86365,526,21241,484,0001,011,0002,449,408
57Sep 3, 2024 18:583,86568,235,58841,499,0001,012,0002,535,424