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 listDec 11, 2024 21:20E SequeiraE SequeiraScore: 467,066Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 11, 2024 21:20466,2685,160,732,4665,092,969,00035,978,0002,510,848
2Dec 11, 2024 21:20466,8435,167,521,7905,097,297,00037,979,0002,338,816
3Dec 11, 2024 21:20466,9155,160,501,1545,104,079,00031,981,0002,437,120
4Dec 11, 2024 21:20466,9795,172,819,1495,098,789,00037,976,0002,322,432
5Dec 11, 2024 21:20467,0205,169,104,3035,097,251,00039,970,0002,322,432
6Dec 11, 2024 21:20467,0445,168,099,8385,100,519,00036,967,0002,420,736
7Dec 11, 2024 21:20467,0665,175,561,8525,106,752,00030,974,0002,306,048
8Dec 11, 2024 21:20467,0845,168,212,7985,100,953,00036,970,0002,330,624
9Dec 11, 2024 21:20467,1025,172,621,4835,100,134,00037,986,0002,330,624
10Dec 11, 2024 21:20467,5035,172,975,5715,106,560,00035,975,0002,310,144
11Dec 11, 2024 21:20467,5605,176,588,3135,119,173,00023,982,0002,338,816
12Dec 11, 2024 21:20472,3455,244,491,8495,157,875,00037,925,0002,338,816