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 19, 2024 11:58Joad NacerJoad NacerError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2024 18:5400000Error: Killed by timeoutstderr
2Apr 19, 2024 18:5400000Error: Killed by timeoutstderr
3Apr 19, 2024 18:5400000Error: Killed by timeoutstderr
4Apr 19, 2024 18:5400000Error: Killed by timeoutstderr
5Apr 19, 2024 18:5300000Error: Killed by timeoutstderr
6Apr 19, 2024 11:584,898117,192,15753,874,67702,265,088
7Apr 19, 2024 11:584,903106,216,02253,938,08902,269,184
8Apr 19, 2024 11:584,906121,018,91353,964,37802,265,088
9Apr 19, 2024 11:586,49192,464,44970,394,0001,005,0002,273,280
10Apr 19, 2024 11:586,49196,507,03370,391,0001,005,0002,289,664
11Apr 19, 2024 11:586,495101,560,38970,444,0001,006,0002,265,088
12Apr 19, 2024 11:586,50294,984,65970,512,0001,007,0002,289,664
13Apr 19, 2024 11:586,503107,369,31571,534,00002,269,184
14Apr 19, 2024 11:586,50895,142,51770,579,0001,008,0002,359,296
15Apr 19, 2024 11:586,530100,118,47869,837,0001,995,0002,277,376
16Apr 19, 2024 11:586,532101,908,02869,852,0001,995,0002,289,664
17Apr 19, 2024 11:586,541101,936,54669,948,0001,998,0002,289,664