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 22:03Eugene 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 22:0316,150236,880,981177,650,05502,207,744
2Aug 5, 2022 22:0316,165241,178,361177,809,89102,191,360
3Aug 5, 2022 22:0316,186207,958,749176,043,0002,000,0002,535,424
4Aug 5, 2022 22:0316,193203,697,818177,119,0001,000,0002,334,720
5Aug 5, 2022 22:0316,196199,718,746176,152,0002,001,0002,535,424
6Aug 5, 2022 22:0316,199201,821,578177,185,0001,001,0002,334,720
7Aug 5, 2022 22:0316,200254,605,740178,195,69202,207,744
8Aug 5, 2022 22:0316,209198,548,263176,291,0002,003,0002,371,584
9Aug 5, 2022 22:0316,211200,360,436176,318,0002,003,0002,334,720
10Aug 5, 2022 22:0316,223207,871,044178,454,00002,334,720
11Aug 5, 2022 22:0316,225201,206,678177,477,0001,002,0002,535,424
12Aug 5, 2022 22:0316,243206,780,102178,670,00002,334,720