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 listJan 16, 2025 01:34Ian MckibbenIan MckibbenScore: 16,099Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 16, 2025 01:3416,072206,053,469167,800,0008,989,0002,322,432
2Jan 16, 2025 01:3416,073203,879,894170,809,0005,993,0002,506,752
3Jan 16, 2025 01:3416,081198,857,598170,892,0005,996,0002,289,664
4Jan 16, 2025 01:3416,081204,334,042166,902,0009,994,0002,510,848
5Jan 16, 2025 01:3416,099200,547,359167,084,00010,005,0002,293,760
6Jan 16, 2025 01:3416,108208,231,732170,178,0007,007,0002,412,544
7Jan 16, 2025 01:3416,109204,971,776169,191,0008,009,0002,510,848
8Jan 16, 2025 01:3416,128198,908,172173,394,0004,009,0002,502,656
9Jan 16, 2025 01:3416,130199,875,770171,415,0006,014,0002,510,848