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:40E SequeiraE SequeiraScore: 461,115Success
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:40459,4935,089,321,2725,014,454,00039,971,0002,453,504
2Dec 11, 2024 21:40459,7865,087,803,5285,020,660,00036,982,0002,531,328
3Dec 11, 2024 21:40460,5925,090,269,3325,030,519,00035,989,0002,527,232
4Dec 11, 2024 21:40460,6895,099,370,0345,031,601,00035,982,0002,342,912
5Dec 11, 2024 21:40461,1155,106,261,2445,035,293,00036,972,0002,392,064
6Dec 11, 2024 21:40461,1465,100,499,6975,033,617,00038,989,0002,445,312
7Dec 11, 2024 21:40461,3545,103,497,7535,037,913,00036,977,0002,531,328
8Dec 11, 2024 21:40461,5265,107,551,4725,043,797,00032,985,0002,342,912
9Dec 11, 2024 21:40462,3545,116,284,2275,047,912,00037,984,0002,461,696