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 listJun 4, 2024 16:20Joad NacerJoad NacerScore: 7,326Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2024 16:204,720112,455,20051,919,87302,265,088
2Jun 4, 2024 16:204,726112,370,58351,985,74102,265,088
3Jun 4, 2024 16:204,731108,627,15152,037,03702,281,472
4Jun 4, 2024 16:207,315108,270,77379,457,0001,005,0002,285,568
5Jun 4, 2024 16:207,315105,095,08679,465,0001,005,0002,285,568
6Jun 4, 2024 16:207,316102,906,49380,476,00002,387,968
7Jun 4, 2024 16:207,326107,567,34679,575,0001,007,0002,285,568
8Jun 4, 2024 16:207,326105,627,60180,582,00002,531,328
9Jun 4, 2024 16:207,330112,124,00780,632,00002,285,568
10Jun 4, 2024 16:207,349106,083,66078,845,0001,996,0002,531,328
11Jun 4, 2024 16:207,350110,951,85480,849,00002,273,280
12Jun 4, 2024 16:207,374108,309,49479,108,0002,002,0002,281,472