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 20, 2021 06:12Yuriy LyfenkoYuriy LyfenkoScore: 5,584Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 20, 2021 06:125,55891,156,57860,138,0001,002,0002,387,968
2May 20, 2021 06:045,55889,220,46659,129,0002,004,0002,260,992
3May 20, 2021 06:125,56089,052,86760,154,0001,002,0002,387,968
4May 20, 2021 06:125,56185,241,19060,168,0001,002,0002,260,992
5May 20, 2021 06:045,56681,392,84159,224,0002,007,0002,392,064
6May 20, 2021 06:045,56687,523,75659,220,0002,007,0002,379,776
7May 20, 2021 06:125,57083,922,62260,265,0001,004,0002,523,136
8May 20, 2021 06:125,57089,048,80760,267,0001,004,0002,265,088
9May 20, 2021 06:125,57181,608,77660,280,0001,004,0002,510,848
10May 20, 2021 06:125,57388,924,79761,305,00002,523,136
11May 20, 2021 06:045,57487,053,84460,309,0001,005,0002,387,968
12May 20, 2021 06:125,57481,658,31860,305,0001,005,0002,260,992
13May 20, 2021 06:045,57988,784,38061,368,00002,523,136
14May 20, 2021 06:125,57988,048,87860,360,0001,006,0002,523,136
15May 20, 2021 06:125,58083,696,73461,377,00002,387,968
16May 20, 2021 06:045,58191,362,44860,384,0001,006,0002,260,992
17May 20, 2021 06:125,58282,726,03261,399,00002,400,256
18May 20, 2021 06:045,58388,392,48959,405,0002,013,0002,523,136
19May 20, 2021 06:125,58486,255,50360,419,0001,006,0002,383,872
20May 20, 2021 06:125,58584,712,21760,424,0001,007,0002,260,992
21May 20, 2021 06:125,58684,700,14460,438,0001,007,0002,527,232
22May 20, 2021 06:125,58779,497,76159,444,0002,015,0002,494,464
23May 20, 2021 06:045,58884,075,19459,454,0002,015,0002,523,136
24May 20, 2021 06:125,58985,771,59661,479,00002,265,088
25May 20, 2021 06:045,58986,989,78460,470,0001,007,0002,265,088
26May 20, 2021 06:125,59082,523,42159,478,0002,016,0002,265,088
27May 20, 2021 06:125,59082,930,42057,457,0004,032,0002,523,136
28May 20, 2021 06:125,847128,379,07764,317,40202,244,608
29May 20, 2021 06:125,864132,032,41564,507,78502,236,416
30May 20, 2021 06:045,864126,767,22064,506,68802,244,608
31May 20, 2021 06:045,866133,729,27864,527,63502,244,608
32May 20, 2021 06:125,868123,745,77464,545,22802,248,704
33May 20, 2021 06:125,868132,851,74864,551,70802,240,512
34May 20, 2021 06:125,872125,140,94664,587,59402,236,416
35May 20, 2021 06:045,876124,081,63464,635,95702,244,608
36May 20, 2021 06:125,887119,804,13564,760,49502,240,512