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 listJul 28, 2024 20:28Andrey LikhachevAndrey LikhachevScore: 11,806Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 28, 2024 20:2811,735158,028,244127,088,0002,001,0002,375,680
2Jul 28, 2024 20:2811,769154,583,256128,455,0001,003,0002,371,584
3Jul 28, 2024 20:2811,784199,557,836129,618,54502,203,648
4Jul 28, 2024 20:2811,785153,460,817128,636,0001,004,0002,367,488
5Jul 28, 2024 20:2811,786196,741,462129,651,14602,207,744
6Jul 28, 2024 20:2811,793192,427,092129,719,10202,211,840
7Jul 28, 2024 20:2811,806158,728,490128,864,000998,0002,363,392
8Jul 28, 2024 20:2811,812157,131,161128,928,000999,0002,289,664
9Jul 28, 2024 20:2811,842150,809,551128,255,0002,003,0002,371,584
10Jul 28, 2024 20:2811,846153,340,129129,303,0001,002,0002,367,488
11Jul 28, 2024 20:2811,856153,054,415129,418,0001,003,0002,371,584
12Jul 28, 2024 20:2811,867155,874,986130,541,00002,375,680