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 22:50Ian MckibbenIan MckibbenScore: 18,092Success
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 22:5018,054224,465,341183,550,00015,045,0002,457,600
2Jan 11, 2025 22:5018,070229,117,605189,780,0008,989,0002,523,136
3Jan 11, 2025 22:5018,085225,900,563183,944,00014,995,0002,273,280
4Jan 11, 2025 22:5018,088227,476,738189,974,0008,998,0002,322,432
5Jan 11, 2025 22:5018,092220,764,883186,015,00013,001,0002,342,912
6Jan 11, 2025 22:5018,100221,620,248190,095,0009,004,0002,330,624
7Jan 11, 2025 22:5018,105225,914,228187,149,00012,009,0002,400,256
8Jan 11, 2025 22:5018,146225,547,114190,574,0009,027,0002,404,352
9Jan 11, 2025 22:5018,157226,827,019191,738,0007,989,0002,437,120