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:53Joad NacerJoad NacerScore: 6,772Success
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:534,492103,997,02949,415,78402,277,376
2Jul 27, 2024 15:534,498122,131,76349,473,34502,285,568
3Jul 27, 2024 15:534,507101,517,87849,575,51102,277,376
4Jul 27, 2024 15:536,76199,895,66174,367,00002,535,424
5Jul 27, 2024 15:536,77094,761,09174,470,00002,428,928
6Jul 27, 2024 15:536,77294,281,64073,486,0001,006,0002,433,024
7Jul 27, 2024 15:536,77299,641,35474,492,00002,428,928
8Jul 27, 2024 15:536,77497,039,19974,519,00002,273,280
9Jul 27, 2024 15:536,77999,014,10673,557,0001,007,0002,535,424
10Jul 27, 2024 15:536,779102,121,56973,571,000994,0002,428,928
11Jul 27, 2024 15:536,77995,819,08973,558,0001,007,0002,514,944
12Jul 27, 2024 15:536,779101,102,72074,574,00002,535,424