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 listMay 22, 2021 19:22Yuriy LyfenkoYuriy LyfenkoScore: 3,979Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 21:523,92173,621,74542,127,0001,003,0002,392,064
2May 22, 2021 21:523,92367,587,52741,151,0002,007,0002,392,064
3May 22, 2021 21:523,92868,530,14042,199,0001,004,0002,527,232
4May 22, 2021 19:223,93766,340,24942,304,0001,007,0002,265,088
5May 22, 2021 21:523,94973,844,21543,440,00002,383,872
6May 22, 2021 19:223,95766,115,02242,519,0001,012,0002,387,968
7May 22, 2021 19:223,961118,342,19043,571,27302,232,320
8May 22, 2021 19:223,96670,879,78143,627,00002,527,232
9May 22, 2021 21:523,96667,873,82742,614,0001,014,0002,265,088
10May 22, 2021 21:523,96872,469,06742,638,0001,015,0002,387,968
11May 22, 2021 21:523,96997,853,32243,663,99402,228,224
12May 22, 2021 21:523,972102,744,69643,696,11802,228,224
13May 22, 2021 19:223,979118,627,46443,768,82002,236,416
14May 22, 2021 21:523,98571,186,24342,839,000996,0002,265,088
15May 22, 2021 19:223,98569,646,84442,834,000996,0002,527,232
16May 22, 2021 19:223,98676,650,81142,851,000996,0002,387,968
17May 22, 2021 21:523,98869,309,73141,875,0001,994,0002,396,160
18May 22, 2021 21:523,98969,598,36041,881,0001,994,0002,527,232
19May 22, 2021 19:223,99478,829,77641,933,0001,996,0002,392,064
20May 22, 2021 19:223,99874,977,76841,980,0001,999,0002,265,088
21May 22, 2021 19:224,00370,691,21042,034,0002,001,0002,265,088
22May 22, 2021 19:224,01477,087,63143,154,0001,003,0002,265,088
23May 22, 2021 21:524,026104,992,44544,289,26202,224,128
24May 22, 2021 19:224,031108,951,21844,337,09802,228,224