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 listApr 18, 2024 23:43Joad NacerJoad NacerScore: 7,915Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2024 23:434,984124,231,33454,820,22102,252,800
2Apr 18, 2024 23:434,991113,303,60854,905,06902,256,896
3Apr 18, 2024 23:434,992120,545,87754,909,94802,260,992
4Apr 18, 2024 23:437,908109,973,92084,984,0001,999,0002,289,664
5Apr 18, 2024 23:437,908111,761,64484,987,0001,999,0002,527,232
6Apr 18, 2024 23:437,910111,976,99085,011,0002,000,0002,269,184
7Apr 18, 2024 23:437,915110,298,47485,060,0002,001,0002,289,664
8Apr 18, 2024 23:437,921117,207,11386,130,0001,001,0002,273,280
9Apr 18, 2024 23:437,923109,872,77985,147,0002,003,0002,347,008
10Apr 18, 2024 23:437,923110,472,75085,148,0002,003,0002,289,664
11Apr 18, 2024 23:437,924112,837,75885,158,0002,003,0002,367,488
12Apr 18, 2024 23:437,928114,332,29685,204,0002,004,0002,289,664