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:28Ian MckibbenIan MckibbenScore: 26,953Success
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:2826,865325,936,202278,486,00017,029,0002,351,104
2Jan 11, 2025 22:2826,898323,183,416282,885,00012,994,0002,334,720
3Jan 11, 2025 22:2826,903320,364,446280,942,00014,996,0002,342,912
4Jan 11, 2025 22:2826,932322,234,903284,245,00012,010,0002,326,528
5Jan 11, 2025 22:2826,953327,798,929287,470,0009,014,0002,347,008
6Jan 11, 2025 22:2826,967327,369,788285,647,00010,986,0002,433,024
7Jan 11, 2025 22:2826,971320,256,752287,692,0008,990,0002,293,760
8Jan 11, 2025 22:2826,977320,721,605275,763,00020,982,0002,314,240
9Jan 11, 2025 22:2826,990322,468,621282,897,00013,994,0002,310,144