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 19:56Sergey StreminSergey StreminScore: 14,565Success
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 19:5614,529184,812,765131,847,00027,967,0002,289,664
2May 8, 2021 19:5614,532190,817,978128,878,00030,970,0002,379,776
3May 8, 2021 19:5614,543186,756,174129,978,00029,995,0002,289,664
4May 8, 2021 20:0114,546189,575,449132,003,00028,000,0002,289,664
5May 8, 2021 20:0114,549183,743,270132,033,00028,007,0002,289,664
6May 8, 2021 20:0114,554190,837,442130,077,00030,017,0002,281,472
7May 8, 2021 20:0114,558180,531,481131,115,00029,025,0002,289,664
8May 8, 2021 20:0114,558183,117,288124,108,00036,031,0002,289,664
9May 8, 2021 19:5614,560186,865,007133,135,00027,027,0002,371,584
10May 8, 2021 19:5614,565183,332,208130,179,00030,041,0002,379,776
11May 8, 2021 20:0114,569185,598,464131,215,00029,047,0002,375,680
12May 8, 2021 19:5614,573183,940,776128,246,00032,061,0002,375,680
13May 8, 2021 20:0114,579181,223,449133,303,00027,061,0002,375,680
14May 8, 2021 20:0114,579180,231,929130,299,00030,069,0002,375,680
15May 8, 2021 19:5614,581182,859,384132,323,00028,068,0002,371,584
16May 8, 2021 20:0114,586183,135,360131,368,00029,081,0002,289,664
17May 8, 2021 19:5614,588183,273,171129,377,00031,090,0002,289,664
18May 8, 2021 19:5614,598185,692,393134,486,00026,094,0002,367,488