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 listMay 8, 2025 11:03Aleksey ShvetsAleksey ShvetsScore: 120,430Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2025 11:03120,3361,350,888,5441,317,697,0005,998,0002,428,928
2May 8, 2025 11:03120,3861,350,750,2891,319,245,0004,997,0002,289,664
3May 8, 2025 11:03120,3981,353,311,8831,316,377,0007,996,0002,478,080
4May 8, 2025 11:03120,4071,351,250,6031,319,477,0005,001,0002,301,952
5May 8, 2025 11:03120,4301,356,479,0401,319,731,0004,995,0002,412,544
6May 8, 2025 11:03120,8861,356,010,6461,322,753,0006,998,0002,449,408
7May 8, 2025 11:03121,2241,357,920,0511,328,464,0004,997,0002,445,312
8May 8, 2025 11:03121,5251,370,031,8451,331,784,0004,995,0002,392,064
9May 8, 2025 11:03122,9731,386,821,3031,345,711,0006,993,0002,519,040