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 listJan 19, 2025 00:42Ian MckibbenIan MckibbenScore: 15,982Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 19, 2025 00:4215,939204,457,822168,317,0007,013,0002,297,856
2Jan 19, 2025 00:4215,952197,516,806171,465,0004,010,0002,367,488
3Jan 19, 2025 00:4215,954204,469,847166,474,0009,025,0002,457,600
4Jan 19, 2025 00:4215,957200,311,776172,514,0003,008,0002,285,568
5Jan 19, 2025 00:4215,982200,342,044162,815,00012,985,0002,445,312
6Jan 19, 2025 00:4215,989198,232,328167,887,0007,994,0002,301,952
7Jan 19, 2025 00:4215,989197,240,364167,890,0007,994,0002,285,568
8Jan 19, 2025 00:4215,991197,838,212170,899,0004,997,0002,355,200
9Jan 19, 2025 00:4215,993200,601,761172,922,0002,998,0002,461,696