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 11, 2021 05:59Sergey StreminSergey StreminScore: 9,497Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 11, 2021 05:589,458125,239,79385,031,00019,007,0002,469,888
2May 11, 2021 05:599,459129,246,64271,035,00033,016,0002,379,776
3May 11, 2021 05:599,467127,749,90571,092,00033,043,0002,289,664
4May 11, 2021 05:599,468126,223,61970,100,00034,048,0002,281,472
5May 11, 2021 05:599,474126,402,86877,158,00027,055,0002,379,776
6May 11, 2021 05:599,481137,335,36178,215,00026,071,0002,289,664
7May 11, 2021 05:599,483126,774,52275,223,00029,086,0002,375,680
8May 11, 2021 05:589,483126,867,20276,227,00028,083,0002,289,664
9May 11, 2021 05:599,487127,965,65080,273,00024,082,0002,289,664
10May 11, 2021 05:589,494127,728,86273,305,00031,129,0002,289,664
11May 11, 2021 05:599,495126,552,30083,357,00021,090,0002,289,664
12May 11, 2021 05:599,496127,329,15579,350,00025,110,0002,482,176
13May 11, 2021 05:599,496130,010,30675,330,00029,127,0002,281,472
14May 11, 2021 05:589,497128,266,86565,290,00039,174,0002,289,664
15May 11, 2021 05:599,498126,971,52278,355,00026,118,0002,289,664
16May 11, 2021 05:589,499128,070,19375,350,00029,135,0002,383,872
17May 11, 2021 05:589,504125,871,04870,363,00034,176,0002,383,872
18May 11, 2021 05:589,513132,335,75879,488,00025,154,0002,367,488
19May 11, 2021 05:599,515135,153,77367,428,00037,236,0002,289,664
20May 11, 2021 05:599,526130,542,27378,841,00025,947,0002,289,664
21May 11, 2021 05:599,529136,558,80179,866,00024,958,0002,375,680
22May 11, 2021 05:599,529129,878,13869,881,00034,940,0002,379,776
23May 11, 2021 05:589,530131,361,51469,887,00034,943,0002,289,664
24May 11, 2021 05:599,535134,210,24775,921,00028,969,0002,375,680
25May 11, 2021 05:599,551130,479,62976,043,00029,016,0002,379,776
26May 11, 2021 05:599,553128,594,74477,062,00028,022,0002,363,392
27May 11, 2021 05:589,617131,725,47667,866,00037,925,0002,289,664