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 2, 2021 16:08Andrey TsvetkovAndrey TsvetkovScore: 14,088Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:0813,997180,557,925106,980,00046,991,0002,392,064
2May 2, 2021 16:0814,033183,875,891105,249,00049,116,0002,416,640
3May 2, 2021 16:0814,047180,112,019108,366,00046,156,0002,306,048
4May 2, 2021 16:0814,067175,220,630106,822,00047,920,0002,408,448
5May 2, 2021 16:0814,088182,974,488107,981,00046,991,0002,412,544
6May 2, 2021 16:0814,159179,966,639108,822,00046,923,0002,412,544
7May 2, 2021 16:0814,231180,541,136108,372,00048,165,0002,351,104
8May 2, 2021 16:0814,292183,275,210108,143,00049,065,0002,457,600
9May 2, 2021 16:0814,307181,509,176110,261,00047,111,0002,408,448