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 2, 2021 18:46Yuriy LyfenkoYuriy LyfenkoScore: 6,012Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 19:366,00391,760,28565,028,0001,000,0002,281,472
2May 2, 2021 18:466,00686,497,90364,065,0002,002,0002,527,232
3May 2, 2021 19:366,00887,678,84265,084,0001,001,0002,265,088
4May 2, 2021 18:466,00890,682,93764,083,0002,002,0002,527,232
5May 2, 2021 19:366,00987,726,57364,095,0002,002,0002,281,472
6May 2, 2021 19:366,01088,800,48165,114,0001,001,0002,281,472
7May 2, 2021 19:366,01091,343,19164,110,0002,003,0002,289,664
8May 2, 2021 18:466,01089,080,82562,107,0004,006,0002,269,184
9May 2, 2021 18:466,01188,696,30464,114,0002,003,0002,281,472
10May 2, 2021 18:466,01290,417,27964,130,0002,004,0002,281,472
11May 2, 2021 18:466,01488,140,71064,149,0002,004,0002,375,680
12May 2, 2021 18:466,01490,445,55064,150,0002,004,0002,265,088
13May 2, 2021 19:366,02587,781,58464,264,0002,008,0002,269,184
14May 2, 2021 18:466,02687,351,05362,266,0004,017,0002,375,680
15May 2, 2021 19:366,03392,382,28965,357,0001,005,0002,281,472
16May 2, 2021 18:466,03692,764,08964,387,0002,012,0002,269,184
17May 2, 2021 19:366,04387,692,81466,477,00002,281,472
18May 2, 2021 19:366,04689,588,55765,498,0001,007,0002,265,088