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 4, 2021 23:25Yurkov AlekseyYurkov AlekseyScore: 10,315Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2021 23:2510,286140,091,324112,150,0001,001,0002,277,376
2May 4, 2021 23:2510,312135,700,529112,431,0001,003,0002,277,376
3May 4, 2021 23:2510,314135,882,231113,455,00002,277,376
4May 4, 2021 23:2510,314134,963,549112,452,0001,004,0002,277,376
5May 4, 2021 23:2510,315140,103,950111,457,0002,008,0002,277,376
6May 4, 2021 23:2510,322136,706,192112,536,0001,004,0002,265,088
7May 4, 2021 23:2510,331146,139,442112,638,0001,005,0002,281,472
8May 4, 2021 23:2510,348138,992,031110,832,0002,995,0002,277,376
9May 4, 2021 23:2510,351144,403,745111,868,0001,997,0002,277,376