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 04:54Yuriy LyfenkoYuriy LyfenkoScore: 12,172Success
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 04:4612,141159,816,665132,551,0001,004,0002,527,232
2May 2, 2021 04:4612,141155,794,671133,546,00002,281,472
3May 2, 2021 04:4612,142162,578,406131,551,0002,008,0002,281,472
4May 2, 2021 04:4612,149160,312,270131,626,0002,009,0002,281,472
5May 2, 2021 04:4612,160169,458,509131,763,0001,996,0002,269,184
6May 2, 2021 04:4612,161159,671,546130,780,0002,994,0002,281,472
7May 2, 2021 04:5412,165159,154,168128,819,0004,993,0002,281,472
8May 2, 2021 04:5412,170160,116,706131,874,0001,998,0002,273,280
9May 2, 2021 04:5412,171159,160,588132,887,000999,0002,269,184
10May 2, 2021 04:5412,172157,046,345131,892,0001,998,0002,289,664
11May 2, 2021 04:4612,176160,482,771130,933,0002,998,0002,273,280
12May 2, 2021 04:5412,178157,557,850132,957,000999,0002,367,488
13May 2, 2021 04:5412,187154,981,241132,055,0002,000,0002,351,104
14May 2, 2021 04:4612,189169,220,576133,081,0001,000,0002,523,136
15May 2, 2021 04:4612,189156,479,773132,080,0002,001,0002,269,184
16May 2, 2021 04:5412,194158,290,417132,133,0002,002,0002,281,472
17May 2, 2021 04:5412,199157,734,095132,188,0002,002,0002,269,184
18May 2, 2021 04:5412,212156,307,078132,326,0002,004,0002,281,472