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 19:17Ian MckibbenIan MckibbenScore: 544,137Success
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 19:17540,9425,982,748,1845,919,392,00030,975,0002,277,376
2Jan 11, 2025 19:17541,8355,988,988,8655,932,208,00027,977,0002,277,376
3Jan 11, 2025 19:17542,4026,000,807,6275,933,442,00032,985,0002,265,088
4Jan 11, 2025 19:17542,5215,996,554,0335,940,747,00026,985,0002,277,376
5Jan 11, 2025 19:17544,1376,015,106,6465,947,522,00037,984,0002,277,376
6Jan 11, 2025 19:17545,8406,040,712,5645,964,273,00039,968,0002,277,376
7Jan 11, 2025 19:17551,1266,089,710,4446,030,402,00031,980,0002,289,664
8Jan 11, 2025 19:17551,1816,089,192,7386,016,018,00046,976,0002,277,376
9Jan 11, 2025 19:17553,5296,114,495,3506,041,842,00046,975,0002,277,376