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:43Andrey TsvetkovAndrey TsvetkovScore: 12,700Success
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:4312,677161,894,737138,445,0001,003,0002,330,624
2Jun 16, 2021 21:4312,680160,548,666137,476,0002,006,0002,330,624
3Jun 16, 2021 21:4312,682162,918,883138,497,0001,003,0002,510,848
4Jun 16, 2021 21:4312,682162,837,618137,500,0002,007,0002,326,528
5Jun 16, 2021 21:4312,686165,221,756137,539,0002,007,0002,510,848
6Jun 16, 2021 21:4312,699217,794,782139,693,40302,183,168
7Jun 16, 2021 21:4312,700194,783,814139,702,80902,183,168
8Jun 16, 2021 21:4312,713166,880,210137,850,0001,997,0002,375,680
9Jun 16, 2021 21:4312,717168,040,398136,886,0002,997,0002,510,848
10Jun 16, 2021 21:4312,720165,803,255137,926,0001,998,0002,330,624
11Jun 16, 2021 21:4312,728196,173,677140,010,39902,179,072
12Jun 16, 2021 21:4312,734170,745,753138,078,0002,001,0002,330,624