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 19, 2021 12:01Ilya AniskovetsIlya AniskovetsScore: 15,188Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 19, 2021 12:0115,117194,072,344166,292,00002,293,760
2Sep 19, 2021 12:0115,160196,401,725165,758,000998,0002,293,760
3Sep 19, 2021 12:0115,163193,101,922164,791,0001,997,0002,494,464
4Sep 19, 2021 12:0115,175194,087,108164,930,0001,999,0002,285,568
5Sep 19, 2021 12:0115,176191,819,107164,941,0001,999,0002,293,760
6Sep 19, 2021 12:0115,181189,585,017164,989,0001,999,0002,293,760
7Sep 19, 2021 12:0115,188190,376,151165,069,0002,000,0002,281,472
8Sep 19, 2021 12:0115,207199,284,542165,271,0002,003,0002,285,568
9Sep 19, 2021 12:0115,217196,515,409166,388,0001,002,0002,293,760
10Sep 19, 2021 12:0116,218227,537,372178,401,11602,244,608
11Sep 19, 2021 12:0116,237231,382,860178,610,52102,232,320
12Sep 19, 2021 12:0116,264255,515,302178,904,61302,232,320