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:36Ian MckibbenIan MckibbenScore: 187,142Success
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:36186,8122,082,254,2092,053,933,000999,0002,265,088
2Jan 11, 2025 21:36186,8282,085,941,0212,054,106,000999,0002,289,664
3Jan 11, 2025 21:36186,8802,079,233,3912,053,684,0001,998,0002,281,472
4Jan 11, 2025 21:36187,1022,082,416,6842,058,124,00002,273,280
5Jan 11, 2025 21:36187,1422,084,632,2932,057,565,000999,0002,289,664
6Jan 11, 2025 21:36187,2832,094,483,8462,059,117,000999,0002,289,664
7Jan 11, 2025 21:36187,3412,091,255,6792,059,754,000999,0002,281,472
8Jan 11, 2025 21:36187,3452,095,061,6542,058,796,0001,998,0002,281,472
9Jan 11, 2025 21:36187,4232,087,386,4752,059,660,0001,998,0002,523,136