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 17, 2021 08:48Andrey TsvetkovAndrey TsvetkovScore: 12,349Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 17, 2021 08:4812,313154,455,422133,437,0002,006,0002,502,656
2Jun 17, 2021 08:4812,325168,673,647134,572,0001,004,0002,514,944
3Jun 17, 2021 08:4812,328158,631,530133,597,0002,008,0002,330,624
4Jun 17, 2021 08:4812,349190,615,672135,835,33602,195,456
5Jun 17, 2021 08:4812,349164,767,780132,838,0002,996,0002,510,848
6Jun 17, 2021 08:4812,349162,024,715133,841,0001,997,0002,514,944
7Jun 17, 2021 08:4812,349163,569,630134,844,000998,0002,330,624
8Jun 17, 2021 08:4812,356161,931,206132,922,0002,998,0002,330,624
9Jun 17, 2021 08:4812,357161,914,993132,933,0002,998,0002,371,584
10Jun 17, 2021 08:4812,367198,066,994136,039,18602,179,072
11Jun 17, 2021 08:4812,371164,141,664133,075,0003,001,0002,506,752
12Jun 17, 2021 08:4812,372199,932,628136,095,15102,179,072