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 4, 2024 16:29Joad NacerJoad NacerScore: 16,657Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2024 16:2914,219209,793,632156,413,98402,400,256
2Jun 4, 2024 16:2914,253234,956,688156,780,02802,273,280
3Jun 4, 2024 16:2914,413227,904,742158,543,85902,265,088
4Jun 4, 2024 16:2916,639206,123,961181,032,0002,000,0002,523,136
5Jun 4, 2024 16:2916,640205,699,429181,043,0002,000,0002,285,568
6Jun 4, 2024 16:2916,654205,756,860181,196,0002,002,0002,277,376
7Jun 4, 2024 16:2916,657203,770,571181,229,0002,002,0002,273,280
8Jun 4, 2024 16:2916,658207,501,966182,241,0001,001,0002,273,280
9Jun 4, 2024 16:2916,677207,393,792182,448,0001,002,0002,375,680
10Jun 4, 2024 16:2916,690208,813,243182,585,0001,003,0002,285,568
11Jun 4, 2024 16:2916,725205,256,022181,980,0001,999,0002,371,584
12Jun 4, 2024 16:2916,771207,474,382184,482,00002,527,232