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 listMay 7, 2025 18:36Aleksey ShvetsAleksey ShvetsScore: 120,509Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 7, 2025 18:36120,1441,344,994,2781,315,590,0005,998,0002,494,464
2May 7, 2025 18:36120,2461,349,048,4281,313,711,0008,998,0002,310,144
3May 7, 2025 18:36120,3251,346,272,2281,319,582,0003,998,0002,424,832
4May 7, 2025 18:36120,3621,351,169,0891,314,984,0008,993,0002,494,464
5May 7, 2025 18:36120,5091,357,133,5741,319,609,0005,993,0002,301,952
6May 7, 2025 18:36120,5541,353,316,4871,321,091,0005,000,0002,428,928
7May 7, 2025 18:36122,8641,378,771,2281,346,503,0004,998,0002,297,856
8May 7, 2025 18:36122,9981,386,858,7421,346,984,0005,999,0002,297,856
9May 7, 2025 18:36124,6031,411,817,2471,366,638,0003,993,0002,334,720