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:14Andrey TsvetkovAndrey TsvetkovScore: 17,626Success
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:1417,596218,802,952192,553,0001,002,0002,514,944
2Jun 16, 2021 21:1417,598222,984,308192,579,0001,003,0002,330,624
3Jun 16, 2021 21:1417,606221,706,068191,675,0001,996,0002,523,136
4Jun 16, 2021 21:1417,616261,820,726193,774,38802,306,048
5Jun 16, 2021 21:1417,617219,284,883191,785,0001,997,0002,510,848
6Jun 16, 2021 21:1417,622222,958,892191,841,0001,998,0002,514,944
7Jun 16, 2021 21:1417,626218,399,956191,893,0001,998,0002,375,680
8Jun 16, 2021 21:1417,627222,422,004190,904,0002,998,0002,330,624
9Jun 16, 2021 21:1417,630224,019,740190,933,0002,998,0002,330,624
10Jun 16, 2021 21:1417,630219,078,107191,934,0001,999,0002,330,624
11Jun 16, 2021 21:1417,645258,690,920194,098,68402,306,048
12Jun 16, 2021 21:1417,672253,129,528194,394,81502,195,456