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:51Ian MckibbenIan MckibbenScore: 41,145Success
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:5140,960476,353,322441,573,0008,991,0002,306,048
2Jan 11, 2025 21:5141,081474,991,020441,892,0009,997,0002,510,848
3Jan 11, 2025 21:5141,109476,257,226440,194,00012,005,0002,342,912
4Jan 11, 2025 21:5141,122484,828,397442,336,00010,007,0002,498,560
5Jan 11, 2025 21:5141,145478,246,411444,607,0007,992,0002,428,928
6Jan 11, 2025 21:5141,147477,295,001441,622,00010,990,0002,490,368
7Jan 11, 2025 21:5141,152481,548,291438,685,00013,989,0002,334,720
8Jan 11, 2025 21:5141,153476,411,126442,695,0009,993,0002,310,144
9Jan 11, 2025 21:5141,165476,963,877439,817,00012,994,0002,449,408