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:54Andrey TsvetkovAndrey TsvetkovScore: 12,012Success
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:5411,993160,764,294129,929,0001,998,0002,326,528
2Jun 17, 2021 08:5411,994156,626,306128,939,0002,998,0002,330,624
3Jun 17, 2021 08:5411,998157,302,241129,975,0001,999,0002,330,624
4Jun 17, 2021 08:5412,002157,385,798130,024,0002,000,0002,519,040
5Jun 17, 2021 08:5412,005158,528,391129,059,0003,001,0002,519,040
6Jun 17, 2021 08:5412,009159,853,682130,095,0002,001,0002,330,624
7Jun 17, 2021 08:5412,012161,328,543129,128,0003,002,0002,326,528
8Jun 17, 2021 08:5412,013159,652,182129,135,0003,003,0002,330,624
9Jun 17, 2021 08:5412,023154,480,897130,246,0002,003,0002,330,624
10Jun 17, 2021 08:5412,056193,867,646132,614,68202,187,264
11Jun 17, 2021 08:5412,058194,968,833132,640,12802,183,168
12Jun 17, 2021 08:5412,094196,783,160133,035,89802,191,360