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:40Ian MckibbenIan MckibbenScore: 16,171Success
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:4016,116198,796,239168,264,0009,014,0002,531,328
2Jan 19, 2025 00:4216,125195,139,880172,361,0005,010,0002,535,424
3Jan 19, 2025 00:4216,163202,390,102170,801,0006,991,0002,473,984
4Jan 19, 2025 00:4216,171207,000,934173,880,0003,997,0002,445,312
5Jan 19, 2025 00:4016,176198,628,512170,941,0006,997,0002,441,216
6Jan 19, 2025 00:4016,200203,058,894171,188,0007,007,0002,285,568