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:52Joad NacerJoad NacerScore: 6,844Success
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:524,520157,461,72349,719,35202,285,568
2Jul 27, 2024 15:524,538116,714,35049,917,36902,281,472
3Jul 27, 2024 15:524,547114,279,15750,021,54402,285,568
4Jul 27, 2024 15:526,831100,507,66774,143,0001,001,0002,273,280
5Jul 27, 2024 15:526,83496,433,72273,174,0002,004,0002,437,120
6Jul 27, 2024 15:526,84299,053,79074,255,0001,003,0002,273,280
7Jul 27, 2024 15:526,844100,369,22874,276,0001,003,0002,273,280
8Jul 27, 2024 15:526,84799,752,93275,315,00002,273,280
9Jul 27, 2024 15:526,850100,262,45375,350,00002,535,424
10Jul 27, 2024 15:526,85199,325,96874,352,0001,004,0002,535,424
11Jul 27, 2024 15:526,86297,198,44674,472,0001,006,0002,433,024
12Jul 27, 2024 15:526,87296,022,66675,589,00002,514,944