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:10Andrey TsvetkovAndrey TsvetkovScore: 11,802Success
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:1011,711154,971,711102,855,00025,963,0002,314,240
2May 1, 2021 14:1011,761153,893,912104,301,00025,072,0002,433,024
3May 1, 2021 14:1011,775154,526,99994,383,00035,142,0002,322,432
4May 1, 2021 14:1011,802160,616,63794,869,00034,951,0002,334,720
5May 1, 2021 14:1011,802160,346,999107,855,00021,970,0002,334,720
6May 1, 2021 14:1011,807158,339,53699,907,00029,972,0002,334,720
7May 1, 2021 14:1011,813161,034,558105,952,00023,989,0002,334,720
8May 1, 2021 14:1011,829151,499,53595,086,00035,032,0002,469,888
9May 1, 2021 14:1011,879156,628,582100,511,00030,153,0002,334,720