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:18Ilya AniskovetsIlya AniskovetsScore: 8,879Success
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:188,848121,711,18495,317,0002,006,0002,289,664
2Sep 27, 2021 20:188,859125,750,78296,443,0001,004,0002,289,664
3Sep 27, 2021 20:188,859120,440,24896,442,0001,004,0002,289,664
4Sep 27, 2021 20:148,860119,815,54996,452,0001,004,0002,265,088
5Sep 27, 2021 20:148,862120,506,15796,477,0001,004,0002,289,664
6Sep 27, 2021 20:188,862122,683,02797,486,00002,289,664
7Sep 27, 2021 20:148,865118,573,17396,514,0001,005,0002,269,184
8Sep 27, 2021 20:148,866123,147,58496,516,0001,005,0002,289,664
9Sep 27, 2021 20:148,869122,266,51297,562,00002,277,376
10Sep 27, 2021 20:188,873123,222,32996,594,0001,006,0002,269,184
11Sep 27, 2021 20:188,875127,687,18196,616,0001,006,0002,289,664
12Sep 27, 2021 20:148,878126,802,74097,657,00002,269,184
13Sep 27, 2021 20:188,879131,314,58797,669,00002,289,664
14Sep 27, 2021 20:188,883122,431,65096,704,0001,007,0002,379,776
15Sep 27, 2021 20:148,893122,458,88496,829,000998,0002,351,104
16Sep 27, 2021 20:188,895124,076,26795,851,0001,996,0002,281,472
17Sep 27, 2021 20:148,908121,983,04495,989,0001,999,0002,289,664
18Sep 27, 2021 20:148,916121,788,82897,079,0001,000,0002,269,184
19Sep 27, 2021 20:148,973173,131,95298,705,50802,265,088
20Sep 27, 2021 20:148,977172,613,65598,741,51702,265,088
21Sep 27, 2021 20:188,982158,775,35698,798,55802,273,280
22Sep 27, 2021 20:188,985173,637,03998,840,31302,265,088
23Sep 27, 2021 20:188,988167,461,32598,873,27502,256,896
24Sep 27, 2021 20:149,002167,153,36399,019,00702,260,992