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 16, 2025 01:34Ian MckibbenIan MckibbenScore: 16,656Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 16, 2025 01:3416,626204,185,808175,890,0006,995,0002,306,048
2Jan 16, 2025 01:3416,640208,829,084177,035,0006,001,0002,301,952
3Jan 16, 2025 01:3416,643205,175,543173,065,00010,003,0002,416,640
4Jan 16, 2025 01:3416,650205,699,137177,141,0006,004,0002,449,408
5Jan 16, 2025 01:3416,656208,086,426177,209,0006,007,0002,314,240
6Jan 16, 2025 01:3416,664205,981,710176,290,0007,011,0002,428,928
7Jan 16, 2025 01:3416,690218,661,496175,563,0008,025,0002,273,280
8Jan 16, 2025 01:3416,695208,782,467178,627,0005,017,0002,293,760
9Jan 16, 2025 01:3416,716212,419,959175,886,0007,994,0002,387,968