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 27, 2024 15:54Joad NacerJoad NacerScore: 6,835Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 27, 2024 15:544,521113,985,34749,734,92502,277,376
2Jul 27, 2024 15:544,526100,369,84249,784,95402,285,568
3Jul 27, 2024 15:544,531103,807,74349,845,91702,281,472
4Jul 27, 2024 15:546,83395,608,35374,156,0001,002,0002,428,928
5Jul 27, 2024 15:546,83396,377,04274,159,0001,002,0002,514,944
6Jul 27, 2024 15:546,834102,674,42873,167,0002,004,0002,437,120
7Jul 27, 2024 15:546,83597,964,12674,181,0001,002,0002,535,424
8Jul 27, 2024 15:546,836104,242,84873,187,0002,005,0002,428,928
9Jul 27, 2024 15:546,83999,808,48074,225,0001,003,0002,535,424
10Jul 27, 2024 15:546,84299,626,73775,259,00002,535,424
11Jul 27, 2024 15:546,848100,069,83573,318,0002,008,0002,535,424
12Jul 27, 2024 15:546,855102,836,21973,419,0001,984,0002,531,328