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 listNov 20, 2024 02:390xrinegade0xrinegadeScore: 480,030Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 20, 2024 02:39477,7145,283,765,1635,150,914,000103,937,0002,412,544
2Nov 20, 2024 02:39479,1245,303,863,0345,160,464,000109,903,0002,334,720
3Nov 20, 2024 02:39479,2865,306,091,5975,181,211,00090,933,0002,330,624
4Nov 20, 2024 02:39479,7665,311,310,5975,179,498,00097,933,0002,416,640
5Nov 20, 2024 02:39480,0305,310,546,8085,183,400,00096,932,0002,347,008
6Nov 20, 2024 02:39480,2815,317,971,9535,198,136,00084,953,0002,347,008
7Nov 20, 2024 02:39480,6945,324,549,1295,165,732,000121,899,0002,408,448
8Nov 20, 2024 02:39482,8215,341,811,8495,202,116,000108,918,0002,535,424
9Nov 20, 2024 02:39483,3285,347,568,5085,201,686,000114,926,0002,547,712