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:38Andrey TsvetkovAndrey TsvetkovScore: 12,754Success
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:3812,729167,337,714138,017,0002,000,0002,322,432
2Jun 16, 2021 21:3812,733168,579,363138,066,0002,000,0002,322,432
3Jun 16, 2021 21:3812,735162,752,729138,082,0002,001,0002,322,432
4Jun 16, 2021 21:3812,740199,722,410140,143,90702,306,048
5Jun 16, 2021 21:3812,743172,060,261139,175,0001,001,0002,510,848
6Jun 16, 2021 21:3812,754164,511,424137,286,0003,006,0002,289,664
7Jun 16, 2021 21:3812,754167,913,039136,290,0004,008,0002,322,432
8Jun 16, 2021 21:3812,770165,726,606138,461,0002,006,0002,498,560
9Jun 16, 2021 21:3812,776162,513,999140,538,00002,510,848
10Jun 16, 2021 21:3812,781201,539,090140,590,38502,179,072
11Jun 16, 2021 21:3812,786194,199,970140,641,51502,187,264
12Jun 16, 2021 21:3812,803167,833,961137,837,0002,996,0002,322,432