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 10, 2024 07:32E SequeiraE SequeiraScore: 476,951Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 10, 2024 07:32473,5185,243,224,2155,206,697,0001,998,0002,281,472
2Nov 10, 2024 07:32475,1445,254,283,9275,225,586,000999,0002,289,664
3Nov 10, 2024 07:32475,3915,265,121,2055,227,304,0001,998,0002,281,472
4Nov 10, 2024 07:32476,2865,315,023,6535,237,156,0001,994,0002,281,472
5Nov 10, 2024 07:32476,9515,276,405,8615,244,459,0001,999,0002,527,232
6Nov 10, 2024 07:32479,9015,311,794,5795,275,910,0002,998,0002,289,664
7Nov 10, 2024 07:32480,5755,314,990,7035,283,327,0002,998,0002,281,472
8Nov 10, 2024 07:32542,7335,998,099,4695,968,064,0001,998,0002,523,136
9Nov 10, 2024 07:32546,9326,049,010,6676,014,250,0001,998,0002,281,472