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 listSep 27, 2021 20:22Ilya AniskovetsIlya AniskovetsScore: 9,174Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 27, 2021 20:229,135124,472,97999,479,0001,004,0002,289,664
2Sep 27, 2021 20:229,151130,987,431100,658,00002,269,184
3Sep 27, 2021 20:229,152128,588,787100,670,00002,289,664
4Sep 27, 2021 20:229,165127,122,81198,815,0001,996,0002,277,376
5Sep 27, 2021 20:229,166127,014,50499,827,000998,0002,289,664
6Sep 27, 2021 20:229,169128,824,76499,861,000998,0002,289,664
7Sep 27, 2021 20:229,174127,619,24598,916,0001,998,0002,273,280
8Sep 27, 2021 20:229,176126,105,94598,943,0001,998,0002,277,376
9Sep 27, 2021 20:229,189123,827,08099,075,0002,001,0002,363,392
10Sep 27, 2021 20:229,701175,862,790106,712,39102,269,184
11Sep 27, 2021 20:229,711186,974,296106,820,28302,269,184
12Sep 27, 2021 20:229,712167,047,448106,830,37902,256,896