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 listDec 28, 2023 04:42Kenneth MaplesKenneth MaplesScore: 7,642Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 28, 2023 04:427,374136,589,07781,119,48002,248,704
2Dec 28, 2023 04:427,444133,580,47781,888,42002,248,704
3Dec 28, 2023 04:427,471142,095,43282,176,99402,240,512
4Dec 28, 2023 04:427,633111,483,26481,965,0001,999,0002,527,232
5Dec 28, 2023 04:427,639111,940,35782,026,0002,000,0002,514,944
6Dec 28, 2023 04:427,641112,609,49082,055,0002,001,0002,265,088
7Dec 28, 2023 04:427,642109,168,96182,063,0002,001,0002,396,160
8Dec 28, 2023 04:427,645110,721,10983,095,0001,001,0002,523,136
9Dec 28, 2023 04:427,650112,998,53883,149,0001,001,0002,265,088
10Dec 28, 2023 04:427,690116,164,98283,587,0001,007,0002,383,872
11Dec 28, 2023 04:427,712111,632,18484,831,00002,392,064
12Dec 28, 2023 04:427,712109,189,83482,835,0001,996,0002,265,088