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:17Ilya AniskovetsIlya AniskovetsScore: 8,740Success
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:178,718118,366,82193,901,0001,997,0002,289,664
2Sep 27, 2021 20:178,729117,016,58194,023,0002,000,0002,289,664
3Sep 27, 2021 20:178,734123,064,61994,071,0002,001,0002,273,280
4Sep 27, 2021 20:178,734121,413,53295,072,0001,000,0002,289,664
5Sep 27, 2021 20:178,737125,903,16495,109,0001,001,0002,289,664
6Sep 27, 2021 20:178,739121,257,18894,132,0002,002,0002,289,664
7Sep 27, 2021 20:178,740127,756,97594,138,0002,002,0002,289,664
8Sep 27, 2021 20:178,741118,902,11494,143,0002,003,0002,523,136
9Sep 27, 2021 20:178,757119,820,11794,326,0002,006,0002,289,664
10Sep 27, 2021 20:179,266163,830,934101,921,91702,265,088
11Sep 27, 2021 20:179,275166,511,703102,029,86802,256,896
12Sep 27, 2021 20:179,283161,551,369102,113,54502,260,992