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 listJun 16, 2021 21:32Andrey TsvetkovAndrey TsvetkovScore: 12,079Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 16, 2021 21:3212,055162,629,192130,607,0001,994,0002,310,144
2Jun 16, 2021 21:3212,067159,228,224130,726,0002,011,0002,494,464
3Jun 16, 2021 21:3212,068161,191,153130,756,0001,996,0002,506,752
4Jun 16, 2021 21:3212,071159,005,982131,774,0001,005,0002,330,624
5Jun 16, 2021 21:3212,073163,624,792131,795,0001,006,0002,502,656
6Jun 16, 2021 21:3212,073163,259,167130,790,0002,012,0002,330,624
7Jun 16, 2021 21:3212,079159,129,504131,858,0001,006,0002,330,624
8Jun 16, 2021 21:3212,088200,720,605132,970,16702,314,240
9Jun 16, 2021 21:3212,090159,881,112131,978,0001,007,0002,330,624
10Jun 16, 2021 21:3212,091164,938,424132,005,0001,000,0002,498,560
11Jun 16, 2021 21:3212,101190,730,342133,106,53002,183,168
12Jun 16, 2021 21:3212,106193,270,175133,162,82802,187,264