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 20, 2021 14:36Andrey TsvetkovAndrey TsvetkovScore: 13,830Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 14:3613,786211,580,113151,648,78502,195,456
2Jun 20, 2021 14:3613,789212,533,731151,680,75202,191,360
3Jun 20, 2021 14:3613,800211,265,957151,799,53802,183,168
4Jun 20, 2021 14:3613,818181,791,575148,001,0004,000,0002,510,848
5Jun 20, 2021 14:3613,826182,313,163148,089,0004,002,0002,510,848
6Jun 20, 2021 14:3613,828180,475,646149,102,0003,002,0002,502,656
7Jun 20, 2021 14:3613,830174,806,068150,130,0002,001,0002,510,848
8Jun 20, 2021 14:3613,831181,040,823150,138,0002,001,0002,322,432
9Jun 20, 2021 14:3613,836171,375,037149,194,0003,003,0002,514,944
10Jun 20, 2021 14:3613,846177,196,942150,299,0002,003,0002,322,432
11Jun 20, 2021 14:3613,852175,409,071152,371,00002,322,432
12Jun 20, 2021 14:3613,868184,360,211149,543,0003,010,0002,322,432