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 17:58Andrey TsvetkovAndrey TsvetkovScore: 12,025Success
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 17:5811,944154,109,35197,288,00034,100,0002,318,336
2May 2, 2021 17:5811,955155,980,63599,381,00032,123,0002,322,432
3May 2, 2021 17:5611,958162,664,43299,654,00031,889,0002,314,240
4May 2, 2021 17:5811,983158,160,95298,862,00032,954,0002,334,720
5May 2, 2021 17:5611,984156,990,936103,862,00027,963,0002,334,720
6May 2, 2021 17:5611,987157,719,522101,888,00029,967,0002,334,720
7May 2, 2021 17:5611,988155,498,19596,905,00034,965,0002,334,720
8May 2, 2021 17:5611,989159,065,895105,901,00025,975,0002,310,144
9May 2, 2021 17:5812,019155,454,247111,172,00021,032,0002,310,144
10May 2, 2021 17:5612,025155,825,46598,202,00034,070,0002,416,640
11May 2, 2021 17:5812,051156,965,73892,389,00040,169,0002,322,432
12May 2, 2021 17:5612,051158,813,50393,395,00039,165,0002,334,720
13May 2, 2021 17:5812,056157,918,51992,430,00040,187,0002,318,336
14May 2, 2021 17:5612,077158,136,208102,883,00029,966,0002,334,720
15May 2, 2021 17:5612,078157,796,375106,888,00025,972,0002,392,064
16May 2, 2021 17:5812,081160,611,99997,921,00034,972,0002,334,720
17May 2, 2021 17:5812,119155,711,773101,233,00032,073,0002,334,720
18May 2, 2021 17:5812,306158,510,161104,286,00031,085,0002,322,432