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 16, 2021 18:52Yuriy LyfenkoYuriy LyfenkoScore: 5,602Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 16, 2021 18:495,583354,677,80759,402,0002,013,0002,269,184
2May 16, 2021 18:525,5844,540,046,88061,424,00002,265,088
3May 16, 2021 18:525,5874,480,988,08359,476,0001,982,0002,523,136
4May 16, 2021 18:525,5892,814,517,13561,479,00002,269,184
5May 16, 2021 18:525,5911,139,281,96460,512,000992,0002,383,872
6May 16, 2021 18:525,592564,580,81758,540,0002,976,0002,523,136
7May 16, 2021 18:495,5923,614,524,46260,505,0001,008,0002,519,040
8May 16, 2021 18:525,5933,023,828,41159,534,0001,984,0002,527,232
9May 16, 2021 18:495,593161,945,39561,527,00002,269,184
10May 16, 2021 18:525,595660,232,25161,541,00002,396,160
11May 16, 2021 18:525,5984,686,628,61360,589,000993,0002,523,136
12May 16, 2021 18:525,598843,067,74459,590,0001,986,0002,265,088
13May 16, 2021 18:525,5984,225,759,17359,596,0001,986,0002,523,136
14May 16, 2021 18:525,5991,701,174,88659,605,0001,986,0002,269,184
15May 16, 2021 18:525,5992,320,518,20560,601,000993,0002,260,992
16May 16, 2021 18:525,5993,538,040,86061,590,00002,523,136
17May 16, 2021 18:495,6004,949,559,23460,595,0001,009,0002,265,088
18May 16, 2021 18:495,6022,947,924,06858,640,0002,981,0002,260,992
19May 16, 2021 18:495,6022,045,975,04159,639,0001,987,0002,396,160
20May 16, 2021 18:525,6031,515,551,81859,646,0001,988,0002,523,136
21May 16, 2021 18:525,6032,635,168,33859,650,0001,988,0002,265,088
22May 16, 2021 18:525,6051,921,978,08159,669,0001,988,0002,523,136
23May 16, 2021 18:525,6091,760,651,44760,707,000995,0002,260,992
24May 16, 2021 18:525,610283,487,64360,711,000995,0002,527,232
25May 16, 2021 18:525,6114,180,256,35560,725,000995,0002,260,992
26May 16, 2021 18:525,6123,280,855,27959,741,0001,991,0002,265,088
27May 16, 2021 18:525,6133,308,308,34360,727,0001,012,0002,260,992
28May 16, 2021 18:525,6153,304,248,63360,768,000996,0002,269,184
29May 16, 2021 18:525,6154,530,192,91960,773,000996,0002,527,232
30May 16, 2021 18:495,615831,824,17360,772,000996,0002,269,184
31May 16, 2021 18:525,6163,977,119,52660,761,0001,012,0002,265,088
32May 16, 2021 18:495,6163,666,629,54061,773,00002,269,184
33May 16, 2021 18:525,6171,544,466,59660,791,000996,0002,523,136
34May 16, 2021 18:495,6174,575,961,13960,796,000996,0002,400,256
35May 16, 2021 18:525,6182,525,335,96559,810,0001,993,0002,523,136
36May 16, 2021 18:525,6242,050,729,60660,862,000997,0002,523,136