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 8, 2021 15:21Andrey TsvetkovAndrey TsvetkovScore: 8,881Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 8, 2021 15:218,856121,981,06896,414,0001,004,0002,334,720
2Sep 5, 2021 12:348,861122,088,48097,471,00002,543,616
3Sep 5, 2021 12:348,864123,277,59297,507,00002,289,664
4Sep 8, 2021 15:218,872123,849,36695,578,0002,012,0002,396,160
5Sep 5, 2021 12:348,873122,525,62196,593,0001,006,0002,334,720
6Sep 5, 2021 12:348,874123,709,12197,615,00002,293,760
7Sep 8, 2021 15:218,874123,762,49896,605,0001,006,0002,334,720
8Sep 8, 2021 15:218,875123,649,72495,609,0002,012,0002,334,720
9Sep 5, 2021 12:348,876127,347,35796,632,0001,006,0002,334,720
10Sep 8, 2021 15:218,878123,953,57094,638,0003,020,0002,289,664
11Sep 5, 2021 12:348,878126,137,75895,643,0002,013,0002,289,664
12Sep 8, 2021 15:218,879167,657,86997,668,73402,228,224
13Sep 8, 2021 15:218,881126,103,54896,680,0001,007,0002,424,832
14Sep 8, 2021 15:218,892152,977,98897,810,71702,232,320
15Sep 5, 2021 12:348,895126,446,01196,846,000998,0002,289,664
16Sep 5, 2021 12:348,895127,140,29495,848,0001,996,0002,334,720
17Sep 5, 2021 12:348,895122,115,01895,854,0001,996,0002,334,720
18Sep 8, 2021 15:218,900121,166,44095,898,0001,997,0002,408,448
19Sep 8, 2021 15:218,918122,948,69797,101,0001,001,0002,285,568
20Sep 8, 2021 15:218,920126,516,56197,122,0001,001,0002,334,720
21Sep 5, 2021 12:348,920160,132,82998,121,58102,232,320
22Sep 8, 2021 15:218,938172,655,45598,314,26802,236,416
23Sep 5, 2021 12:348,949179,888,70598,443,29102,347,008
24Sep 5, 2021 12:348,954152,369,85098,493,49402,224,128