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 23:24Ian MckibbenIan MckibbenScore: 16,786Success
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 23:2416,764211,741,321177,393,0007,015,0002,420,736
2Jan 11, 2025 23:2416,768205,623,392179,437,0005,012,0002,297,856
3Jan 11, 2025 23:2416,777216,274,287178,533,0006,017,0002,301,952
4Jan 11, 2025 23:2416,779211,414,903179,554,0005,015,0002,301,952
5Jan 11, 2025 23:2416,786212,472,407180,636,0004,014,0002,314,240
6Jan 11, 2025 23:2416,794213,031,105171,749,00012,981,0002,355,200
7Jan 11, 2025 23:2416,798212,614,526178,785,0005,992,0002,428,928
8Jan 11, 2025 23:2416,801215,857,054176,823,0007,992,0002,490,368
9Jan 11, 2025 23:2416,848210,930,588177,310,0008,014,0002,506,752