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 22, 2021 22:04Yuriy LyfenkoYuriy LyfenkoScore: 3,893Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 22:043,81469,101,04039,956,0001,997,0002,527,232
2May 22, 2021 22:003,82172,637,02441,035,0001,000,0002,396,160
3May 22, 2021 21:523,82467,840,01740,059,0002,002,0002,506,752
4May 22, 2021 22:003,84864,951,88842,324,00002,265,088
5May 22, 2021 21:523,84874,830,00441,320,0001,007,0002,265,088
6May 22, 2021 22:003,84868,013,54840,313,0002,015,0002,383,872
7May 22, 2021 21:523,85965,562,02441,435,0001,010,0002,265,088
8May 22, 2021 22:043,86470,543,54041,488,0001,011,0002,392,064
9May 22, 2021 22:003,86564,849,51841,504,0001,012,0002,265,088
10May 22, 2021 21:523,86970,070,15642,555,00002,527,232
11May 22, 2021 22:003,87372,150,01542,604,00002,265,088
12May 22, 2021 22:043,87575,791,97741,614,0001,014,0002,527,232
13May 22, 2021 22:003,87868,828,75141,641,0001,015,0002,396,160
14May 22, 2021 21:523,88169,030,25242,691,00002,527,232
15May 22, 2021 21:523,88271,757,36042,699,00002,392,064
16May 22, 2021 22:043,88469,759,62542,720,00002,523,136
17May 22, 2021 22:043,89371,164,95442,825,00002,265,088
18May 22, 2021 22:003,89367,591,57840,834,0001,991,0002,523,136
19May 22, 2021 22:003,89369,049,38941,831,000995,0002,383,872
20May 22, 2021 22:043,89572,891,63941,853,000996,0002,269,184
21May 22, 2021 21:523,89669,780,44240,866,0001,993,0002,392,064
22May 22, 2021 22:043,89772,317,93140,874,0001,993,0002,265,088
23May 22, 2021 22:003,89967,614,40041,896,000997,0002,265,088
24May 22, 2021 22:043,901113,743,35842,910,48302,236,416
25May 22, 2021 21:523,909106,245,54543,002,57002,240,512
26May 22, 2021 21:523,91069,857,21542,009,0001,000,0002,379,776
27May 22, 2021 22:043,91274,219,73542,035,0001,000,0002,265,088
28May 22, 2021 21:523,91372,563,43942,038,0001,000,0002,392,064
29May 22, 2021 22:043,91567,972,41442,060,0001,001,0002,527,232
30May 22, 2021 21:523,91997,618,86943,109,07902,236,416
31May 22, 2021 22:003,928104,135,52443,205,86602,240,512
32May 22, 2021 22:043,944108,963,38943,381,71502,224,128
33May 22, 2021 22:003,945113,312,37643,397,94802,232,320
34May 22, 2021 22:043,946111,762,19843,402,41902,236,416
35May 22, 2021 21:523,95299,529,07843,476,11102,244,608
36May 22, 2021 22:003,97697,586,66243,739,89502,236,416