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:34Ian MckibbenIan MckibbenScore: 19,020Success
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:3418,993231,924,566198,930,0009,996,0002,433,024
2Jan 11, 2025 22:3418,994235,853,757192,935,00015,994,0002,453,504
3Jan 11, 2025 22:3419,000236,623,354196,999,00011,999,0002,441,216
4Jan 11, 2025 22:3419,019231,773,238195,200,00014,014,0002,318,336
5Jan 11, 2025 22:3419,020231,592,834201,216,0008,008,0002,273,280
6Jan 11, 2025 22:3419,029235,340,273198,307,00011,017,0002,510,848
7Jan 11, 2025 22:3419,039233,695,499195,398,00014,028,0002,314,240
8Jan 11, 2025 22:3419,040234,169,569201,419,0008,016,0002,322,432
9Jan 11, 2025 22:3419,068241,362,074194,767,00014,982,0002,453,504