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 11, 2025 22:25Ian MckibbenIan MckibbenScore: 38,257Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 11, 2025 22:2538,162444,038,967406,787,00012,993,0002,355,200
2Jan 11, 2025 22:2538,214449,755,404409,350,00011,009,0002,502,656
3Jan 11, 2025 22:2538,228447,958,415409,496,00011,013,0002,510,848
4Jan 11, 2025 22:2538,231448,856,207404,560,00015,982,0002,322,432
5Jan 11, 2025 22:2538,257445,965,532410,828,0009,995,0002,330,624
6Jan 11, 2025 22:2538,264452,941,323412,911,0007,998,0002,461,696
7Jan 11, 2025 22:2538,281449,104,896407,088,00014,003,0002,510,848
8Jan 11, 2025 22:2538,328445,894,490411,614,0009,990,0002,326,528
9Jan 11, 2025 22:2538,359446,050,235412,949,0008,998,0002,428,928