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 2, 2024 18:03Joad NacerJoad NacerScore: 7,259Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 2, 2024 18:034,726125,463,78951,987,67802,265,088
2Jun 2, 2024 18:034,737113,396,65252,101,66802,260,992
3Jun 2, 2024 18:034,739112,796,88752,133,81902,256,896
4Jun 2, 2024 18:037,239110,914,41878,626,0001,008,0002,293,760
5Jun 2, 2024 18:037,256116,064,93579,816,00002,387,968
6Jun 2, 2024 18:037,259105,619,17377,851,0001,996,0002,531,328
7Jun 2, 2024 18:037,259107,825,78779,850,00002,293,760
8Jun 2, 2024 18:037,264102,507,91677,908,0001,997,0002,293,760
9Jun 2, 2024 18:037,267105,164,55977,934,0001,998,0002,293,760
10Jun 2, 2024 18:037,267105,099,10077,936,0001,998,0002,269,184
11Jun 2, 2024 18:037,274102,715,80678,016,0002,000,0002,293,760
12Jun 2, 2024 18:037,277106,527,15178,041,0002,001,0002,293,760