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 listJan 11, 2025 21:45Ian MckibbenIan MckibbenScore: 154,063Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 11, 2025 21:45153,8021,726,125,2921,678,829,00012,990,0002,379,776
2Jan 11, 2025 21:45153,8761,715,004,1691,682,644,0009,997,0002,355,200
3Jan 11, 2025 21:45153,9321,716,622,6671,678,261,00014,993,0002,342,912
4Jan 11, 2025 21:45153,9861,722,279,2481,683,855,0009,993,0002,318,336
5Jan 11, 2025 21:45154,0631,722,646,9051,682,697,00011,997,0002,351,104
6Jan 11, 2025 21:45154,1891,724,108,8181,681,083,00014,991,0002,441,216
7Jan 11, 2025 21:45154,2061,721,059,1481,684,275,00011,994,0002,371,584
8Jan 11, 2025 21:45154,2141,720,349,8261,682,362,00013,994,0002,383,872
9Jan 11, 2025 21:45154,6171,736,619,6471,688,789,00011,998,0002,310,144