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 listJun 20, 2021 14:55Andrey TsvetkovAndrey TsvetkovScore: 11,894Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 14:5511,869154,775,486128,554,0002,008,0002,330,624
2Jun 20, 2021 14:5511,870151,181,482128,560,0002,008,0002,330,624
3Jun 20, 2021 14:5511,880163,304,107129,679,000997,0002,514,944
4Jun 20, 2021 14:5511,880160,386,200128,674,0002,010,0002,330,624
5Jun 20, 2021 14:5511,892157,480,008128,810,0001,997,0002,330,624
6Jun 20, 2021 14:5511,892154,177,037128,815,0001,997,0002,506,752
7Jun 20, 2021 14:5511,894153,688,713128,833,0001,997,0002,506,752
8Jun 20, 2021 14:5511,895168,409,716128,848,0001,997,0002,314,240
9Jun 20, 2021 14:5511,897203,936,480130,864,86802,183,168
10Jun 20, 2021 14:5511,898207,199,173130,880,43502,179,072
11Jun 20, 2021 14:5511,907159,858,200127,977,0002,999,0002,519,040
12Jun 20, 2021 14:5511,920196,065,025131,123,30402,183,168