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 17:40Joad NacerJoad NacerScore: 7,349Success
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 17:404,891126,437,31953,803,77702,277,376
2Jun 4, 2024 17:404,905113,233,73853,956,17602,277,376
3Jun 4, 2024 17:404,906115,982,52453,965,93202,273,280
4Jun 4, 2024 17:407,346106,190,39880,811,00002,523,136
5Jun 4, 2024 17:407,347108,649,48378,818,0001,995,0002,285,568
6Jun 4, 2024 17:407,348107,170,93878,828,0001,995,0002,285,568
7Jun 4, 2024 17:407,349113,339,34679,837,000997,0002,285,568
8Jun 4, 2024 17:407,349112,519,58479,837,000997,0002,269,184
9Jun 4, 2024 17:407,350104,066,45278,859,0001,996,0002,269,184
10Jun 4, 2024 17:407,351103,956,86778,860,0001,996,0002,285,568
11Jun 4, 2024 17:407,355107,998,22578,913,0001,997,0002,523,136
12Jun 4, 2024 17:407,360102,689,91778,960,0001,999,0002,285,568