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:36Andrey TsvetkovAndrey TsvetkovScore: 12,339Success
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:3612,310161,773,928134,404,0001,003,0002,514,944
2Jun 16, 2021 21:3612,314158,450,372134,449,0001,003,0002,326,528
3Jun 16, 2021 21:3612,316208,911,000135,474,22502,179,072
4Jun 16, 2021 21:3612,323161,729,836134,545,0001,004,0002,326,528
5Jun 16, 2021 21:3612,323155,484,438135,552,00002,322,432
6Jun 16, 2021 21:3612,326162,056,851134,581,0001,004,0002,322,432
7Jun 16, 2021 21:3612,339197,946,707135,724,33502,187,264
8Jun 16, 2021 21:3612,353161,688,050132,884,0002,997,0002,519,040
9Jun 16, 2021 21:3612,359160,482,226133,949,0001,999,0002,363,392
10Jun 16, 2021 21:3612,368188,343,850136,052,45902,187,264
11Jun 16, 2021 21:3612,373160,412,208133,098,0003,002,0002,322,432
12Jun 16, 2021 21:3612,394157,160,352135,333,0001,002,0002,506,752