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,439Success
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,797133,242,20352,762,33202,269,184
2Jun 4, 2024 17:404,803115,150,62752,834,30702,260,992
3Jun 4, 2024 17:404,806115,811,49052,869,26202,396,160
4Jun 4, 2024 17:407,437107,972,18879,811,0001,995,0002,527,232
5Jun 4, 2024 17:407,438105,544,64280,826,000997,0002,277,376
6Jun 4, 2024 17:407,439110,113,19380,829,000997,0002,531,328
7Jun 4, 2024 17:407,439110,496,23380,836,000997,0002,277,376
8Jun 4, 2024 17:407,440106,896,05279,844,0001,996,0002,269,184
9Jun 4, 2024 17:407,444107,660,14380,882,000998,0002,277,376
10Jun 4, 2024 17:407,447108,299,16979,917,0001,997,0002,527,232
11Jun 4, 2024 17:407,449105,591,31680,936,000999,0002,383,872
12Jun 4, 2024 17:407,450105,692,29279,955,0001,998,0002,281,472