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 21:09Sergey StreminSergey StreminScore: 11,869Success
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 21:0911,854150,262,099104,316,00026,079,0002,469,888
2May 8, 2021 21:0911,863157,897,332102,391,00028,107,0002,289,664
3May 8, 2021 21:0911,864152,915,206108,417,00022,085,0002,289,664
4May 8, 2021 21:0911,864158,028,977106,411,00024,093,0002,289,664
5May 8, 2021 21:0911,869160,880,85699,426,00031,133,0002,289,664
6May 8, 2021 21:0911,880156,495,91499,515,00031,161,0002,281,472
7May 8, 2021 21:0911,892166,596,115105,848,00024,964,0002,289,664
8May 8, 2021 21:0911,895156,911,230105,684,00025,162,0002,289,664
9May 8, 2021 21:0911,910160,655,779104,004,00027,001,0002,289,664