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 19:17Ian MckibbenIan MckibbenScore: 605,429Success
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 19:17592,5276,546,911,2676,473,817,00043,978,0002,289,664
2Jan 11, 2025 19:17595,3656,577,859,1766,507,044,00041,968,0002,277,376
3Jan 11, 2025 19:17595,7316,579,731,7626,519,054,00033,984,0002,289,664
4Jan 11, 2025 19:17596,7206,596,144,0146,533,940,00029,981,0002,359,296
5Jan 11, 2025 19:17605,4296,690,031,7536,629,741,00029,980,0002,367,488
6Jan 11, 2025 19:17610,9466,749,210,8726,688,421,00031,982,0002,277,376
7Jan 11, 2025 19:17612,5876,765,166,4306,700,478,00037,980,0002,289,664
8Jan 11, 2025 19:17614,4316,785,037,7836,724,759,00033,983,0002,519,040
9Jan 11, 2025 19:17641,6877,088,823,5797,022,580,00035,982,0002,269,184