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 2, 2021 17:51Yurkov AlekseyYurkov AlekseyScore: 7,244Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 17:507,226101,150,04878,483,0001,006,0002,531,328
2May 2, 2021 17:507,227105,271,07279,499,00002,277,376
3May 2, 2021 17:517,229106,030,26478,514,0001,006,0002,531,328
4May 2, 2021 17:507,232102,737,58079,550,00002,277,376
5May 2, 2021 17:517,235102,771,50577,569,0002,014,0002,527,232
6May 2, 2021 17:517,236109,881,96878,594,0001,007,0002,527,232
7May 2, 2021 17:517,238106,321,80478,607,0001,007,0002,277,376
8May 2, 2021 17:507,243106,946,83178,666,0001,008,0002,277,376
9May 2, 2021 17:507,244106,560,28278,672,0001,008,0002,277,376
10May 2, 2021 17:507,244107,022,38179,687,00002,277,376
11May 2, 2021 17:507,245110,732,65777,674,0002,017,0002,277,376
12May 2, 2021 17:517,246103,265,87277,709,0001,992,0002,269,184
13May 2, 2021 17:517,255106,197,73377,806,0001,995,0002,277,376
14May 2, 2021 17:517,257107,920,44978,827,000997,0002,277,376
15May 2, 2021 17:517,258104,502,98878,839,000997,0002,277,376
16May 2, 2021 17:517,259108,924,87578,849,000998,0002,273,280
17May 2, 2021 17:507,262105,592,55178,883,000998,0002,277,376
18May 2, 2021 17:507,263107,754,44177,891,0001,997,0002,523,136