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 17, 2021 08:52Andrey TsvetkovAndrey TsvetkovScore: 12,005Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 17, 2021 08:5211,957155,751,367130,523,0001,004,0002,330,624
2Jun 17, 2021 08:5211,987157,324,115128,857,0002,996,0002,330,624
3Jun 17, 2021 08:5211,995161,843,950129,948,0001,999,0002,310,144
4Jun 17, 2021 08:5211,997161,929,874128,964,0002,999,0002,510,848
5Jun 17, 2021 08:5212,002158,218,549130,024,0002,000,0002,506,752
6Jun 17, 2021 08:5212,003160,159,908130,034,0002,000,0002,330,624
7Jun 17, 2021 08:5212,005160,388,482129,056,0003,001,0002,514,944
8Jun 17, 2021 08:5212,006164,573,004130,068,0002,001,0002,330,624
9Jun 17, 2021 08:5212,009158,894,768130,098,0002,001,0002,330,624
10Jun 17, 2021 08:5212,028191,372,031132,303,13602,306,048
11Jun 17, 2021 08:5212,043201,728,887132,478,44702,183,168
12Jun 17, 2021 08:5212,060206,095,705132,658,73802,191,360