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:47Ian MckibbenIan MckibbenScore: 18,288Success
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:4718,229226,400,843189,490,00011,028,0002,326,528
2Jan 11, 2025 22:4718,268225,946,127191,948,0008,997,0002,387,968
3Jan 11, 2025 22:4718,271223,924,665189,982,00010,998,0002,338,816
4Jan 11, 2025 22:4718,274227,658,258191,017,00010,000,0002,342,912
5Jan 11, 2025 22:4718,288224,824,179186,160,00015,012,0002,457,600
6Jan 11, 2025 22:4718,303227,093,349190,318,00011,018,0002,289,664
7Jan 11, 2025 22:4718,303230,071,199190,320,00011,018,0002,375,680
8Jan 11, 2025 22:4718,319229,247,348192,483,0009,022,0002,396,160
9Jan 11, 2025 22:4718,345230,659,687184,810,00016,982,0002,392,064