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:35Eugene ZhydzetskiEugene ZhydzetskiScore: 17,691Success
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:3517,618262,423,558193,796,32502,207,744
2Aug 5, 2022 21:3517,632275,928,120193,948,89102,207,744
3Aug 5, 2022 21:3517,636263,408,634194,000,71002,220,032
4Aug 5, 2022 21:3517,651217,569,513191,154,0003,002,0002,535,424
5Aug 5, 2022 21:3517,675217,510,848193,423,0001,002,0002,334,720
6Aug 5, 2022 21:3517,689218,337,148194,580,00002,387,968
7Aug 5, 2022 21:3517,691225,972,953193,598,0001,003,0002,334,720
8Aug 5, 2022 21:3517,707220,843,252192,778,0001,997,0002,334,720
9Aug 5, 2022 21:3517,707221,101,504193,780,000998,0002,334,720
10Aug 5, 2022 21:3517,709223,367,101193,796,000998,0002,535,424
11Aug 5, 2022 21:3517,747221,236,934194,211,0001,001,0002,535,424
12Aug 5, 2022 21:3517,752217,781,928193,265,0002,002,0002,334,720