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 20:15Yuriy LyfenkoYuriy LyfenkoScore: 5,622Success
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 20:155,58990,459,33961,478,00002,523,136
2May 16, 2021 12:575,60086,749,11058,573,0003,029,0002,265,088
3May 16, 2021 12:575,60186,528,18161,612,00002,387,968
4May 16, 2021 12:575,60186,219,87459,587,0002,019,0002,392,064
5May 16, 2021 12:575,60287,276,94960,607,0001,010,0002,523,136
6May 16, 2021 18:475,60488,576,85261,644,00002,387,968
7May 16, 2021 12:575,60587,981,14859,632,0002,021,0002,392,064
8May 16, 2021 12:575,60593,468,09259,636,0002,021,0002,396,160
9May 16, 2021 18:475,60991,644,46761,704,00002,379,776
10May 8, 2021 20:155,60985,982,83159,676,0002,022,0002,523,136
11May 16, 2021 12:575,60986,264,22061,696,00002,392,064
12May 16, 2021 12:575,61188,380,34260,711,0001,011,0002,260,992
13May 16, 2021 18:475,61189,631,35860,707,0001,011,0002,260,992
14May 16, 2021 12:575,61890,938,56860,807,000996,0002,396,160
15May 16, 2021 12:575,62191,172,58460,839,000997,0002,523,136
16May 8, 2021 20:155,62192,257,46060,834,000997,0002,396,160
17May 16, 2021 18:475,62188,594,79460,833,000997,0002,523,136
18May 16, 2021 12:575,62189,763,38158,838,0002,991,0002,392,064
19May 16, 2021 12:575,62287,749,24360,847,000997,0002,523,136
20May 8, 2021 20:155,62292,908,35960,840,000997,0002,392,064
21May 16, 2021 18:475,62389,367,07760,857,000997,0002,396,160
22May 16, 2021 18:475,62390,679,86959,853,0001,995,0002,523,136
23May 8, 2021 20:155,62391,116,22358,865,0002,993,0002,392,064
24May 16, 2021 18:475,62488,723,99459,864,0001,995,0002,387,968
25May 16, 2021 12:575,62486,011,15559,867,0001,995,0002,396,160
26May 8, 2021 20:155,62489,512,70760,865,000997,0002,387,968
27May 8, 2021 20:155,62591,612,87159,877,0001,995,0002,387,968
28May 16, 2021 18:475,62689,614,40260,884,000998,0002,523,136
29May 16, 2021 12:575,62885,330,28458,908,0002,995,0002,265,088
30May 8, 2021 20:155,63093,705,68660,930,000998,0002,392,064
31May 16, 2021 12:575,63289,452,41559,957,0001,998,0002,523,136
32May 16, 2021 12:575,63294,952,29960,950,000999,0002,269,184
33May 16, 2021 18:475,63395,046,94059,963,0001,998,0002,469,888
34May 16, 2021 12:575,64089,102,84059,039,0003,001,0002,392,064
35May 8, 2021 20:155,64092,248,71661,035,0001,000,0002,523,136
36May 16, 2021 12:575,73192,991,38861,038,0002,001,0002,400,256