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 listAug 5, 2022 21:56Eugene ZhydzetskiEugene ZhydzetskiScore: 16,200Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 5, 2022 21:5616,146238,372,070177,605,70602,215,936
2Aug 5, 2022 21:5616,147234,535,764177,619,91502,203,648
3Aug 5, 2022 21:5616,152239,329,444177,670,27802,215,936
4Aug 5, 2022 21:5616,193204,737,860177,124,0001,000,0002,334,720
5Aug 5, 2022 21:5616,195198,318,879177,146,0001,000,0002,535,424
6Aug 5, 2022 21:5616,198200,490,607176,173,0002,001,0002,334,720
7Aug 5, 2022 21:5616,200198,570,330177,197,0001,001,0002,535,424
8Aug 5, 2022 21:5616,207204,980,355177,274,0001,001,0002,334,720
9Aug 5, 2022 21:5616,209205,577,620176,294,0002,003,0002,334,720
10Aug 5, 2022 21:5616,216199,050,459176,369,0002,004,0002,334,720
11Aug 5, 2022 21:5616,216201,129,164178,377,00002,535,424
12Aug 5, 2022 21:5616,232203,364,722178,548,00002,535,424