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 06:52Sergey StreminSergey StreminScore: 9,575Success
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 06:529,538133,618,46679,939,00024,981,0002,289,664
2May 11, 2021 06:529,547138,323,16977,015,00028,005,0002,289,664
3May 11, 2021 06:529,552128,322,82973,049,00032,021,0002,289,664
4May 11, 2021 06:529,552128,345,39875,055,00030,022,0002,289,664
5May 11, 2021 06:529,554127,977,78471,065,00034,031,0002,289,664
6May 11, 2021 06:529,561129,621,68769,114,00036,059,0002,289,664
7May 11, 2021 06:529,567128,444,39573,163,00032,071,0002,375,680
8May 11, 2021 06:529,567141,395,26075,172,00030,069,0002,289,664
9May 11, 2021 06:529,571131,349,64878,211,00027,073,0002,289,664
10May 11, 2021 06:529,575127,576,51373,224,00032,098,0002,289,664
11May 11, 2021 06:529,575128,907,86580,250,00025,078,0002,289,664
12May 11, 2021 06:529,578132,325,03777,263,00028,095,0002,375,680
13May 11, 2021 06:529,585126,267,37368,279,00037,152,0002,363,392
14May 11, 2021 06:529,585136,520,98872,301,00033,137,0002,371,584
15May 11, 2021 06:529,587127,514,15278,339,00027,117,0002,289,664
16May 11, 2021 06:529,599137,993,66675,421,00030,168,0002,281,472
17May 11, 2021 06:529,622131,713,31476,884,00028,956,0002,289,664
18May 11, 2021 06:529,648131,001,53674,088,00032,038,0002,281,472