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 8, 2024 00:12Joad NacerJoad NacerScore: 7,364Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2024 00:124,760110,451,28252,357,71502,256,896
2May 8, 2024 00:124,761117,436,31152,369,67502,265,088
3May 8, 2024 00:124,770117,682,72352,467,02202,277,376
4May 8, 2024 00:127,321103,169,97780,532,00002,531,328
5May 8, 2024 00:127,349102,252,81079,840,000998,0002,289,664
6May 8, 2024 00:127,353105,046,46378,882,0001,997,0002,289,664
7May 8, 2024 00:127,364105,126,71079,003,0002,000,0002,289,664
8May 8, 2024 00:127,365106,188,16279,020,0002,000,0002,269,184
9May 8, 2024 00:127,370104,052,05979,073,0002,001,0002,347,008
10May 8, 2024 00:127,373105,715,89780,103,0001,001,0002,273,280
11May 8, 2024 00:127,374106,071,16479,117,0002,002,0002,289,664
12May 8, 2024 00:127,375101,389,93179,121,0002,003,0002,289,664