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 14:44Andrey TsvetkovAndrey TsvetkovScore: 11,865Success
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 14:4411,802158,703,36998,866,00030,958,0002,314,240
2May 1, 2021 14:4411,841154,393,60194,179,00036,068,0002,322,432
3May 1, 2021 14:4411,852156,925,882100,286,00030,086,0002,334,720
4May 1, 2021 14:4411,863149,947,156103,387,00027,101,0002,310,144
5May 1, 2021 14:4411,865153,917,72098,387,00032,126,0002,396,160
6May 1, 2021 14:4411,865150,200,86798,389,00032,127,0002,314,240
7May 1, 2021 14:4411,907161,514,58796,985,00033,994,0002,334,720
8May 1, 2021 14:4411,918153,138,414105,078,00026,019,0002,322,432
9May 1, 2021 14:4412,298159,842,190107,224,00028,058,0002,322,432