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 listNov 10, 2021 18:34Sergey StreminSergey StreminScore: 5,649Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 10, 2021 18:345,63287,660,92859,956,0001,998,0002,359,296
2Nov 10, 2021 18:345,63287,198,61559,959,0001,998,0002,293,760
3Nov 10, 2021 18:345,63390,973,61359,968,0001,998,0002,363,392
4Nov 10, 2021 18:345,63586,049,54859,982,0001,999,0002,359,296
5Nov 10, 2021 18:345,64093,370,10260,041,0002,001,0002,367,488
6Nov 10, 2021 18:345,64188,422,72060,054,0002,001,0002,359,296
7Nov 10, 2021 18:345,64186,697,74960,045,0002,001,0002,355,200
8Nov 10, 2021 18:345,64484,840,40860,086,0002,002,0002,293,760
9Nov 10, 2021 18:345,64689,381,97262,108,00002,367,488
10Nov 10, 2021 18:345,64687,775,22460,107,0002,003,0002,293,760
11Nov 10, 2021 18:345,64784,891,02460,109,0002,003,0002,367,488
12Nov 10, 2021 18:345,64890,120,83060,123,0002,004,0002,363,392
13Nov 10, 2021 18:345,64992,309,15760,130,0002,004,0002,359,296
14Nov 10, 2021 18:345,65083,732,02860,149,0002,004,0002,293,760
15Nov 10, 2021 18:345,65189,540,57460,157,0002,005,0002,289,664
16Nov 10, 2021 18:345,65386,412,50160,182,0002,006,0002,293,760
17Nov 10, 2021 18:345,66488,012,18160,295,0002,009,0002,293,760
18Nov 10, 2021 18:345,66588,789,73061,311,0001,005,0002,351,104
19Nov 10, 2021 18:345,707134,184,56762,774,47902,207,744
20Nov 10, 2021 18:345,716131,819,64562,878,15002,195,456
21Nov 10, 2021 18:345,724137,330,11462,960,09602,199,552
22Nov 10, 2021 18:345,725131,786,18862,977,38802,195,456
23Nov 10, 2021 18:345,736154,637,79563,094,88802,195,456
24Nov 10, 2021 18:345,742134,495,17663,156,98602,260,992