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:43Ian MckibbenIan MckibbenScore: 18,324Success
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:4318,303228,809,760196,324,0005,008,0002,375,680
2Jan 11, 2025 22:4318,313223,400,985191,424,00010,022,0002,433,024
3Jan 11, 2025 22:4318,321232,594,548185,488,00016,042,0002,326,528
4Jan 11, 2025 22:4318,323231,287,644182,503,00019,052,0002,469,888
5Jan 11, 2025 22:4318,324230,050,270191,535,00010,028,0002,433,024
6Jan 11, 2025 22:4318,325222,152,937191,592,0009,978,0002,314,240
7Jan 11, 2025 22:4318,329228,486,277192,633,0008,982,0002,465,792
8Jan 11, 2025 22:4318,352231,738,592187,881,00013,991,0002,441,216
9Jan 11, 2025 22:4318,399231,210,041195,371,0007,013,0002,486,272