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:02Ian MckibbenIan MckibbenScore: 41,159Success
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:0241,082476,525,143437,902,00013,996,0002,338,816
2Jan 11, 2025 22:0241,084476,142,927441,929,0009,998,0002,416,640
3Jan 11, 2025 22:0241,086475,905,696436,946,00014,998,0002,490,368
4Jan 11, 2025 22:0241,107478,208,246445,175,0007,002,0002,490,368
5Jan 11, 2025 22:0241,159475,371,176439,755,00012,992,0002,527,232
6Jan 11, 2025 22:0241,167476,995,058438,839,00013,994,0002,338,816
7Jan 11, 2025 22:0241,178476,455,880439,957,00012,998,0002,314,240
8Jan 11, 2025 22:0241,193481,660,744444,116,0009,002,0002,523,136
9Jan 11, 2025 22:0241,200476,424,313438,192,00015,006,0002,478,080