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:50Eugene ZhydzetskiEugene ZhydzetskiScore: 17,027Success
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:5016,933239,920,844186,265,42402,203,648
2Aug 5, 2022 21:5016,942250,472,731186,358,60802,211,840
3Aug 5, 2022 21:5016,973247,424,593186,699,61702,203,648
4Aug 5, 2022 21:5017,011211,723,594185,124,0002,001,0002,531,328
5Aug 5, 2022 21:5017,016212,394,289185,175,0002,001,0002,334,720
6Aug 5, 2022 21:5017,020207,830,707185,216,0002,002,0002,334,720
7Aug 5, 2022 21:5017,027212,027,035185,298,0002,003,0002,334,720
8Aug 5, 2022 21:5017,028210,152,558185,302,0002,003,0002,334,720
9Aug 5, 2022 21:5017,029209,247,106186,314,0001,001,0002,535,424
10Aug 5, 2022 21:5017,031208,259,953186,345,0001,001,0002,334,720
11Aug 5, 2022 21:5017,033208,564,971186,363,0001,001,0002,334,720
12Aug 5, 2022 21:5017,057219,354,428185,621,0002,006,0002,531,328