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:22Andrey TsvetkovAndrey TsvetkovScore: 12,270Success
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:2212,233185,957,743134,563,05502,191,360
2Jun 16, 2021 21:2212,254164,004,235132,796,0001,996,0002,322,432
3Jun 16, 2021 21:2212,258216,159,865134,836,31102,179,072
4Jun 16, 2021 21:2212,258163,915,399133,838,000998,0002,322,432
5Jun 16, 2021 21:2212,268163,918,301132,949,0001,999,0002,510,848
6Jun 16, 2021 21:2212,268161,540,954133,949,000999,0002,322,432
7Jun 16, 2021 21:2212,270213,523,735134,971,30202,183,168
8Jun 16, 2021 21:2212,271164,407,677133,977,000999,0002,506,752
9Jun 16, 2021 21:2212,272163,523,201131,988,0002,999,0002,506,752
10Jun 16, 2021 21:2212,272161,596,238131,992,0002,999,0002,510,848
11Jun 16, 2021 21:2212,282161,651,121131,095,0004,002,0002,322,432
12Jun 16, 2021 21:2212,284161,229,992133,120,0002,001,0002,506,752