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 listNov 20, 2024 02:390xrinegade0xrinegadeScore: 606,754Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 20, 2024 02:39595,9656,587,133,7046,517,635,00037,980,0002,281,472
2Nov 20, 2024 02:39597,0936,602,006,9736,539,032,00028,986,0002,281,472
3Nov 20, 2024 02:39600,6666,639,214,8876,574,335,00032,986,0002,265,088
4Nov 20, 2024 02:39604,8456,683,727,5096,612,313,00040,983,0002,289,664
5Nov 20, 2024 02:39606,7546,707,878,3166,636,311,00037,984,0002,281,472
6Nov 20, 2024 02:39607,5616,710,204,4036,653,197,00029,978,0002,281,472
7Nov 20, 2024 02:39609,3986,735,105,4886,660,401,00042,976,0002,514,944
8Nov 20, 2024 02:39611,3676,762,151,3696,683,064,00041,969,0002,289,664
9Nov 20, 2024 02:39611,8056,761,376,9586,694,873,00034,983,0002,265,088