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 22:13Andrey TsvetkovAndrey TsvetkovScore: 12,199Success
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 22:1312,163161,682,258130,798,0002,995,0002,330,624
2Jun 16, 2021 22:1312,167160,444,857130,838,0002,996,0002,502,656
3Jun 16, 2021 22:1312,168159,672,324131,849,0001,997,0002,502,656
4Jun 16, 2021 22:1312,186163,648,066132,045,0002,000,0002,510,848
5Jun 16, 2021 22:1312,187157,386,457132,060,0002,000,0002,330,624
6Jun 16, 2021 22:1312,191159,281,181133,105,0001,000,0002,306,048
7Jun 16, 2021 22:1312,199160,195,427132,185,0002,002,0002,506,752
8Jun 16, 2021 22:1312,200157,029,992133,196,0001,001,0002,510,848
9Jun 16, 2021 22:1312,211190,777,817134,316,37202,179,072
10Jun 16, 2021 22:1312,212187,322,006134,333,83202,306,048
11Jun 16, 2021 22:1312,218157,354,641131,385,0003,008,0002,510,848
12Jun 16, 2021 22:1312,248205,395,168134,731,92402,306,048