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:03Ian MckibbenIan MckibbenScore: 16,817Success
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:0316,738208,058,758173,116,00011,007,0002,265,088
2Jan 11, 2025 23:0316,763208,388,089178,379,0006,012,0002,506,752
3Jan 11, 2025 23:0316,781210,184,975179,577,0005,016,0002,433,024
4Jan 11, 2025 23:0316,803208,728,980178,839,0005,994,0002,318,336
5Jan 11, 2025 23:0316,817208,469,665174,984,0009,999,0002,301,952
6Jan 11, 2025 23:0316,817208,556,585177,991,0006,999,0002,412,544
7Jan 11, 2025 23:0316,829207,278,567177,114,0008,005,0002,293,760
8Jan 11, 2025 23:0316,838208,483,760180,214,0005,005,0002,342,912
9Jan 11, 2025 23:0316,843213,859,838180,266,0005,007,0002,498,560