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 listJun 2, 2024 18:12Joad NacerJoad NacerScore: 7,273Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 2, 2024 18:124,728109,508,62052,006,92402,265,088
2Jun 2, 2024 18:124,738107,993,38252,118,17302,269,184
3Jun 2, 2024 18:124,748111,272,96452,232,27902,260,992
4Jun 2, 2024 18:127,263103,402,94078,896,000998,0002,293,760
5Jun 2, 2024 18:127,270103,675,23477,968,0001,999,0002,531,328
6Jun 2, 2024 18:127,271104,614,81577,979,0001,999,0002,293,760
7Jun 2, 2024 18:127,273106,650,24178,007,0002,000,0002,293,760
8Jun 2, 2024 18:127,274102,656,15778,016,0002,000,0002,285,568
9Jun 2, 2024 18:127,278104,741,60878,053,0002,001,0002,523,136
10Jun 2, 2024 18:127,281104,131,47278,087,0002,002,0002,527,232
11Jun 2, 2024 18:127,282101,453,85778,098,0002,002,0002,527,232
12Jun 2, 2024 18:127,282103,123,75279,105,0001,001,0002,285,568