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 1, 2021 13:24Andrey TsvetkovAndrey TsvetkovScore: 12,439Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2021 13:2412,394161,022,588110,271,00026,064,0002,334,720
2May 1, 2021 13:2412,404160,878,457105,347,00031,102,0002,334,720
3May 1, 2021 13:2412,408156,755,145111,402,00025,090,0002,334,720
4May 1, 2021 13:2412,438165,069,207106,854,00029,959,0002,490,368
5May 1, 2021 13:2412,439166,014,448107,863,00028,963,0002,510,848
6May 1, 2021 13:2412,467162,053,245106,106,00031,031,0002,334,720
7May 1, 2021 13:2412,467164,577,170106,108,00031,031,0002,334,720
8May 1, 2021 13:2412,468163,893,560106,119,00031,034,0002,506,752
9May 1, 2021 13:2412,492158,706,211107,321,00030,090,0002,334,720