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 11, 2021 14:30Sergey StreminSergey StreminScore: 9,292Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 11, 2021 14:309,257130,633,57772,874,00028,950,0002,375,680
2May 11, 2021 14:309,264126,869,99969,932,00031,968,0002,289,664
3May 11, 2021 14:309,283126,278,40374,080,00028,030,0002,289,664
4May 11, 2021 14:309,292131,907,17970,143,00032,065,0002,281,472
5May 11, 2021 14:309,292124,454,75168,139,00034,069,0002,375,680
6May 11, 2021 14:309,298126,155,42767,185,00035,097,0002,289,664
7May 11, 2021 14:309,299126,852,14971,205,00031,089,0002,379,776
8May 11, 2021 14:309,321126,852,38971,366,00031,160,0002,375,680
9May 11, 2021 14:309,571126,937,73678,211,00027,073,0002,486,272