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:15Andrey TsvetkovAndrey TsvetkovScore: 11,881Success
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:1511,829152,987,743100,095,00030,028,0002,519,040
2May 2, 2021 16:1511,829152,622,80095,089,00035,032,0002,514,944
3May 2, 2021 16:1511,839156,762,05299,178,00031,055,0002,334,720
4May 2, 2021 16:1511,845153,976,79293,213,00037,084,0002,334,720
5May 2, 2021 16:1511,847148,562,33199,242,00031,075,0002,523,136
6May 2, 2021 16:1511,850153,958,635107,288,00023,062,0002,457,600
7May 2, 2021 16:1511,852156,734,40494,266,00036,102,0002,334,720
8May 2, 2021 16:1511,854156,974,036108,331,00022,067,0002,510,848
9May 2, 2021 16:1511,869155,621,63392,395,00038,163,0002,519,040
10May 2, 2021 16:1511,881156,319,146106,750,00023,943,0002,379,776
11May 2, 2021 16:1511,893163,989,664103,856,00026,962,0002,510,848
12May 2, 2021 16:1511,894161,936,77596,879,00033,957,0002,519,040
13May 2, 2021 16:1511,897158,939,195105,897,00024,975,0002,334,720
14May 2, 2021 16:1511,913162,302,51687,030,00044,015,0002,506,752
15May 2, 2021 16:1511,913160,888,435102,037,00029,010,0002,506,752
16May 2, 2021 16:1511,921151,381,60387,087,00044,044,0002,334,720
17May 2, 2021 16:1511,934151,718,421102,216,00029,061,0002,334,720
18May 2, 2021 16:1512,468158,809,608102,114,00035,039,0002,523,136