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 1, 2021 13:13Andrey TsvetkovAndrey TsvetkovScore: 12,483Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2021 13:1312,461160,319,591100,051,00037,019,0002,334,720
2May 1, 2021 13:1312,470160,136,269107,135,00030,037,0002,334,720
3May 1, 2021 13:1312,474159,028,275105,160,00032,049,0002,334,720
4May 1, 2021 13:1312,480162,970,231107,216,00030,060,0002,359,296
5May 1, 2021 13:1312,483160,363,529106,244,00031,071,0002,334,720
6May 1, 2021 13:1312,489163,053,544109,300,00028,077,0002,334,720
7May 1, 2021 13:1312,512163,148,709109,505,00028,129,0002,514,944
8May 1, 2021 13:1312,528162,699,971107,851,00029,958,0002,379,776
9May 1, 2021 13:1312,537165,475,305104,927,00032,977,0002,334,720