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 listDec 11, 2024 21:10E SequeiraE SequeiraScore: 467,178Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 11, 2024 21:10466,2485,156,509,8255,087,758,00040,965,0002,318,336
2Dec 11, 2024 21:10466,3115,165,954,4215,088,437,00040,979,0002,392,064
3Dec 11, 2024 21:10466,9405,165,611,5555,098,363,00037,972,0002,338,816
4Dec 11, 2024 21:10467,0535,164,988,7505,105,608,00031,978,0002,531,328
5Dec 11, 2024 21:10467,1785,169,757,0285,105,982,00032,980,0002,318,336
6Dec 11, 2024 21:10467,5135,178,511,2695,112,673,00029,974,0002,428,928
7Dec 11, 2024 21:10467,6075,174,088,5815,113,698,00029,980,0002,330,624
8Dec 11, 2024 21:10467,6765,185,198,1745,111,462,00032,970,0002,334,720
9Dec 11, 2024 21:10467,7095,178,254,2265,112,836,00031,967,0002,322,432