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:21Ilya AniskovetsIlya AniskovetsScore: 11,572Success
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:2111,531152,513,176124,839,0001,997,0002,514,944
2Sep 19, 2021 12:2111,531158,837,925125,840,000998,0002,498,560
3Sep 19, 2021 12:2111,537152,266,808124,910,0001,998,0002,494,464
4Sep 19, 2021 12:2111,538152,690,697125,914,000999,0002,514,944
5Sep 19, 2021 12:2111,546150,255,647125,008,0002,000,0002,502,656
6Sep 19, 2021 12:2111,552155,921,120125,068,0002,001,0002,498,560
7Sep 19, 2021 12:2111,572153,643,471125,288,0002,004,0002,289,664
8Sep 19, 2021 12:2111,574155,242,307125,309,0002,004,0002,289,664
9Sep 19, 2021 12:2111,585152,855,630125,427,0002,006,0002,506,752
10Sep 19, 2021 12:2112,397202,811,975136,369,18802,240,512
11Sep 19, 2021 12:2112,429196,797,152136,717,10402,228,224
12Sep 19, 2021 12:2112,434210,348,926136,777,42302,232,320