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 listApr 20, 2024 13:07Joad NacerJoad NacerScore: 6,170Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 20, 2024 13:074,801113,956,97452,812,84002,260,992
2Apr 20, 2024 13:074,814118,345,46952,949,62002,269,184
3Apr 20, 2024 13:074,829121,499,49553,116,72602,277,376
4Apr 20, 2024 13:076,12889,764,30466,406,0001,006,0002,289,664
5Apr 20, 2024 13:076,16694,969,07466,825,000997,0002,289,664
6Apr 20, 2024 13:076,16893,979,39666,853,000997,0002,273,280
7Apr 20, 2024 13:076,17093,698,46265,869,0001,996,0002,289,664
8Apr 20, 2024 13:076,17191,519,89866,886,000998,0002,289,664
9Apr 20, 2024 13:076,17394,568,48865,901,0001,997,0002,289,664
10Apr 20, 2024 13:076,17590,561,61566,931,000998,0002,289,664
11Apr 20, 2024 13:076,17991,820,88466,971,000999,0002,289,664
12Apr 20, 2024 13:076,18693,201,12166,048,0002,001,0002,289,664