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 19, 2025 00:43Ian MckibbenIan MckibbenScore: 16,089Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 19, 2025 00:4316,075208,016,614172,832,0003,996,0002,465,792
2Jan 19, 2025 00:4316,075198,061,333165,841,00010,989,0002,453,504
3Jan 19, 2025 00:4316,081204,398,807169,898,0006,995,0002,269,184
4Jan 19, 2025 00:4316,084200,459,533168,929,0007,996,0002,310,144
5Jan 19, 2025 00:4316,089199,785,098171,977,0004,999,0002,285,568
6Jan 19, 2025 00:4316,093200,407,283165,022,00012,001,0002,445,312
7Jan 19, 2025 00:4316,097201,035,586173,064,0004,001,0002,453,504
8Jan 19, 2025 00:4316,138201,744,193170,497,0007,020,0002,457,600
9Jan 19, 2025 00:4316,163206,775,710172,794,0004,994,0002,408,448