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 listMay 1, 2025 14:02etherealetherealScore: 612,480Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2025 14:02610,2046,743,782,6406,681,259,00030,982,0002,277,376
2May 1, 2025 14:02610,7836,745,483,2126,679,634,00038,974,0002,277,376
3May 1, 2025 14:02611,4816,754,217,0326,685,318,00040,977,0002,277,376
4May 1, 2025 14:02611,7446,753,802,6616,698,199,00030,987,0002,277,376
5May 1, 2025 14:02612,4806,763,574,4896,702,301,00034,980,0002,519,040
6May 1, 2025 14:02614,6396,788,770,4536,719,058,00041,975,0002,277,376
7May 1, 2025 14:02615,8066,812,236,9916,732,889,00040,981,0002,285,568
8May 1, 2025 14:02622,1476,873,203,3956,813,632,00029,985,0002,277,376
9May 1, 2025 14:02628,1506,935,247,6176,871,674,00037,981,0002,277,376