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 16, 2021 22:04Andrey TsvetkovAndrey TsvetkovScore: 12,232Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 16, 2021 22:0412,196159,984,522133,160,0001,001,0002,322,432
2Jun 16, 2021 22:0412,215158,890,971133,367,0001,002,0002,514,944
3Jun 16, 2021 22:0412,219192,033,087134,411,55802,187,264
4Jun 16, 2021 22:0412,219159,443,825132,407,0002,006,0002,310,144
5Jun 16, 2021 22:0412,224157,495,870132,460,0002,006,0002,326,528
6Jun 16, 2021 22:0412,227205,540,928134,496,83702,191,360
7Jun 16, 2021 22:0412,232158,897,041132,542,0002,008,0002,322,432
8Jun 16, 2021 22:0412,233163,504,963131,547,0003,012,0002,506,752
9Jun 16, 2021 22:0412,239162,994,876134,628,00002,326,528
10Jun 16, 2021 22:0412,241159,576,148131,634,0003,014,0002,326,528
11Jun 16, 2021 22:0412,243162,563,872132,661,0002,010,0002,498,560
12Jun 16, 2021 22:0412,248192,657,673134,729,84602,183,168