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, 2021 20:56Sergey StreminSergey StreminScore: 13,531Success
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, 2021 20:5613,472172,623,045128,166,00020,026,0002,289,664
2May 8, 2021 20:5613,509173,319,862117,471,00031,125,0002,289,664
3May 8, 2021 20:5613,530175,310,009117,864,00030,964,0002,379,776
4May 8, 2021 20:5613,531178,674,117117,872,00030,966,0002,289,664
5May 8, 2021 20:5613,531176,836,504121,869,00026,971,0002,289,664
6May 8, 2021 20:5613,549174,060,276115,031,00034,009,0002,367,488
7May 8, 2021 20:5613,552177,374,554118,059,00031,015,0002,289,664
8May 8, 2021 20:5613,557169,923,325117,101,00032,027,0002,289,664
9May 8, 2021 20:5613,902176,266,961124,935,00027,985,0002,289,664