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 23:30Ian MckibbenIan MckibbenScore: 16,709Success
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 23:3116,653209,957,242179,181,0004,004,0002,433,024
2Jan 11, 2025 23:3116,671212,312,902179,375,0004,008,0002,293,760
3Jan 11, 2025 23:3116,672206,817,741178,383,0005,010,0002,293,760
4Jan 11, 2025 23:3116,682211,580,760179,496,0004,011,0002,289,664
5Jan 11, 2025 23:3116,690213,102,487180,584,0003,009,0002,396,160
6Jan 11, 2025 23:3116,707208,856,877177,749,0006,025,0002,506,752
7Jan 11, 2025 23:3116,709213,318,089176,809,0006,992,0002,506,752
8Jan 11, 2025 23:3116,715208,215,092179,864,0003,996,0002,310,144
9Jan 11, 2025 23:3116,731207,252,559175,043,0009,002,0002,297,856
10Jan 11, 2025 23:3027,038327,521,470290,407,0007,009,0002,301,952
11Jan 11, 2025 23:3027,101322,238,744293,110,0005,001,0002,416,640
12Jan 11, 2025 23:3027,489326,262,023291,362,00011,013,0002,379,776