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:53Andrey TsvetkovAndrey TsvetkovScore: 11,897Success
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:5311,867151,198,406128,526,0002,008,0002,510,848
2Jun 20, 2021 14:5311,874157,157,421128,605,0002,009,0002,330,624
3Jun 20, 2021 14:5311,876153,695,396129,632,0001,004,0002,514,944
4Jun 20, 2021 14:5311,894157,036,902127,843,0002,996,0002,330,624
5Jun 20, 2021 14:5311,895199,395,331130,848,20102,183,168
6Jun 20, 2021 14:5311,895159,795,557128,844,0001,997,0002,514,944
7Jun 20, 2021 14:5311,897157,578,921128,871,0001,998,0002,330,624
8Jun 20, 2021 14:5311,905209,013,998130,954,69802,183,168
9Jun 20, 2021 14:5311,906203,079,251130,961,44302,187,264
10Jun 20, 2021 14:5311,906153,278,996128,970,0001,999,0002,502,656
11Jun 20, 2021 14:5311,912160,513,709128,034,0003,000,0002,330,624
12Jun 20, 2021 14:5311,959155,109,472129,540,0002,008,0002,510,848