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 2, 2024 18:35Yurkov AlekseyYurkov AlekseyScore: 6,480Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 2, 2024 18:356,45792,034,09469,025,0002,000,0002,289,664
2Jan 2, 2024 18:356,45896,580,12870,042,0001,000,0002,289,664
3Jan 2, 2024 18:356,46395,551,44770,096,0001,001,0002,289,664
4Jan 2, 2024 18:356,46999,325,81269,151,0002,004,0002,523,136
5Jan 2, 2024 18:356,46994,921,48569,154,0002,004,0002,531,328
6Jan 2, 2024 18:356,47697,011,27369,233,0002,006,0002,289,664
7Jan 2, 2024 18:356,48093,687,83369,272,0002,007,0002,273,280
8Jan 2, 2024 18:356,48191,858,28569,282,0002,008,0002,277,376
9Jan 2, 2024 18:356,48496,105,86070,322,0001,004,0002,289,664
10Jan 2, 2024 18:357,380145,719,07381,183,70602,269,184
11Jan 2, 2024 18:357,391134,434,64281,301,26902,269,184
12Jan 2, 2024 18:357,397147,275,94581,367,88502,269,184