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:38Andrey TsvetkovAndrey TsvetkovScore: 12,461Success
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:3812,358163,456,909105,953,00029,986,0002,322,432
2May 1, 2021 13:3812,378160,126,344104,124,00032,038,0002,334,720
3May 1, 2021 13:3812,387156,362,863103,193,00033,062,0002,334,720
4May 1, 2021 13:3812,438163,062,647100,863,00035,951,0002,334,720
5May 1, 2021 13:3812,461168,223,500110,059,00027,014,0002,441,216
6May 1, 2021 13:3812,465162,288,269111,092,00026,021,0002,318,336
7May 1, 2021 13:3812,491164,705,922102,297,00035,102,0002,334,720
8May 1, 2021 13:3812,518169,005,236114,578,00023,116,0002,334,720
9May 1, 2021 13:3812,979167,706,402112,822,00029,952,0002,334,720