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 listSep 5, 2023 07:36mmalczakmmalczakScore: 588,446Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2023 07:36578,2966,451,180,6806,361,251,48602,252,800
2Sep 5, 2023 07:36579,5876,440,144,5616,375,457,95702,248,704
3Sep 5, 2023 07:36582,8626,480,490,6536,411,487,45802,256,896
4Sep 5, 2023 07:36588,4466,540,787,5206,472,909,33602,252,800
5Sep 5, 2023 07:36611,4116,791,835,4256,725,517,09602,248,704
6Sep 5, 2023 07:36611,7946,788,342,9256,729,738,20802,244,608