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 listMay 27, 2021 13:13Yurkov AlekseyYurkov AlekseyScore: 11,282Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 27, 2021 13:1311,259152,390,396121,849,0001,997,0002,281,472
2May 27, 2021 13:1311,264146,949,937121,911,0001,998,0002,277,376
3May 27, 2021 13:1311,267146,547,439121,942,0001,999,0002,281,472
4May 27, 2021 13:1311,268147,034,986120,945,0002,998,0002,269,184
5May 27, 2021 13:1311,268149,037,257121,946,0001,999,0002,265,088
6May 27, 2021 13:1311,273145,960,015121,004,0003,000,0002,277,376
7May 27, 2021 13:1311,282146,627,739122,102,0002,001,0002,277,376
8May 27, 2021 13:1311,286150,187,111122,146,0002,002,0002,277,376
9May 27, 2021 13:1311,287149,063,509122,152,0002,002,0002,281,472
10May 27, 2021 13:1311,578175,537,236127,360,91602,265,088
11May 27, 2021 13:1311,590167,922,018127,490,00802,195,456
12May 27, 2021 13:1311,608201,569,622127,688,75202,281,472