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 2, 2021 16:13Andrey TsvetkovAndrey TsvetkovScore: 11,814Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:1111,742157,158,95497,124,00032,040,0002,334,720
2May 2, 2021 16:1211,748148,891,74095,166,00034,059,0002,453,504
3May 2, 2021 16:1211,759156,892,323104,281,00025,067,0002,334,720
4May 2, 2021 16:1211,772154,690,504103,397,00026,100,0002,334,720
5May 2, 2021 16:1111,774152,859,721104,417,00025,100,0002,334,720
6May 2, 2021 16:1311,775155,180,83897,397,00032,131,0002,334,720
7May 2, 2021 16:1311,788155,547,106101,520,00028,144,0002,334,720
8May 2, 2021 16:1111,790161,420,948101,540,00028,149,0002,461,696
9May 2, 2021 16:1311,803166,197,16597,873,00031,958,0002,334,720
10May 2, 2021 16:1211,804158,327,24097,879,00031,960,0002,334,720
11May 2, 2021 16:1211,807155,707,744102,901,00026,974,0002,322,432
12May 2, 2021 16:1111,809156,048,72993,928,00035,972,0002,334,720
13May 2, 2021 16:1111,811154,870,048107,934,00021,986,0002,453,504
14May 2, 2021 16:1311,814160,136,283103,961,00025,990,0002,334,720
15May 2, 2021 16:1111,815156,660,44387,974,00041,987,0002,285,568
16May 2, 2021 16:1111,820161,150,377105,013,00025,003,0002,330,624
17May 2, 2021 16:1311,821155,323,639108,024,00022,005,0002,334,720
18May 2, 2021 16:1211,824157,071,63797,051,00033,017,0002,334,720
19May 2, 2021 16:1211,825154,255,115103,064,00027,016,0002,449,408
20May 2, 2021 16:1311,829151,345,86890,082,00040,036,0002,334,720
21May 2, 2021 16:1211,843151,876,349104,217,00026,054,0002,457,600
22May 2, 2021 16:1211,846155,019,477105,248,00025,059,0002,519,040
23May 2, 2021 16:1311,853156,288,50998,291,00032,095,0002,457,600
24May 2, 2021 16:1111,853151,767,591110,328,00020,059,0002,334,720
25May 2, 2021 16:1311,861156,184,331101,368,00029,105,0002,334,720
26May 2, 2021 16:1111,861153,905,622102,367,00028,100,0002,334,720
27May 2, 2021 16:1311,874153,842,26799,469,00031,147,0002,334,720