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 listAug 31, 2025 13:52Alex KentAlex KentScore: 397,630Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 31, 2025 13:52396,9434,391,852,4834,334,388,00031,988,0002,285,568
2Aug 31, 2025 13:52397,0554,393,999,5424,321,627,00045,974,0002,510,848
3Aug 31, 2025 13:52397,5004,404,982,0764,333,522,00038,977,0002,510,848
4Aug 31, 2025 13:52397,5994,404,300,4474,342,609,00030,982,0002,277,376
5Aug 31, 2025 13:52397,6304,399,588,0774,339,944,00033,983,0002,285,568
6Aug 31, 2025 13:52397,6314,406,173,8614,337,953,00035,983,0002,277,376
7Aug 31, 2025 13:52398,2454,402,151,5754,340,714,00039,978,0002,277,376
8Aug 31, 2025 13:52398,4754,409,263,7104,348,249,00034,977,0002,265,088
9Aug 31, 2025 13:52399,4104,416,689,0524,360,526,00032,981,0002,519,040