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:33Andrey TsvetkovAndrey TsvetkovScore: 13,913Success
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:3313,872183,957,327151,584,0001,003,0002,514,944
2Jun 20, 2021 14:3313,877182,660,795151,638,0001,004,0002,519,040
3Jun 20, 2021 14:3313,896176,251,955150,857,0001,998,0002,326,528
4Jun 20, 2021 14:3313,897187,801,819149,871,0002,997,0002,502,656
5Jun 20, 2021 14:3313,906179,491,716150,971,0001,999,0002,326,528
6Jun 20, 2021 14:3313,909184,635,220150,995,0001,999,0002,326,528
7Jun 20, 2021 14:3313,913208,196,959153,040,46002,183,168
8Jun 20, 2021 14:3313,916178,282,787151,075,0002,001,0002,510,848
9Jun 20, 2021 14:3313,919184,369,111152,114,0001,000,0002,510,848
10Jun 20, 2021 14:3313,925225,396,314153,170,88002,179,072
11Jun 20, 2021 14:3313,925179,907,274151,168,0002,002,0002,322,432
12Jun 20, 2021 14:3313,927218,043,667153,193,68802,174,976