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 18:58Yurkov AlekseyYurkov AlekseyScore: 6,779Success
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 19:056,76399,695,09172,388,0002,010,0002,519,040
2May 2, 2021 18:586,76499,907,58473,396,0001,005,0002,277,376
3May 2, 2021 19:056,76598,913,67171,395,0003,016,0002,387,968
4May 2, 2021 19:056,765101,402,22773,413,0001,005,0002,277,376
5May 2, 2021 18:586,76696,630,96072,413,0002,011,0002,277,376
6May 2, 2021 18:586,77096,474,63373,464,0001,006,0002,277,376
7May 2, 2021 19:056,774100,951,06073,503,0001,006,0002,531,328
8May 2, 2021 18:586,77597,041,81273,523,0001,007,0002,269,184
9May 2, 2021 19:056,779104,149,79873,561,0001,007,0002,277,376
10May 2, 2021 19:056,779101,334,29372,557,0002,015,0002,277,376
11May 2, 2021 18:586,780100,996,36473,576,0001,007,0002,277,376
12May 2, 2021 18:586,783105,960,02974,611,00002,273,280
13May 2, 2021 19:056,784100,270,85372,610,0002,016,0002,277,376
14May 2, 2021 18:586,787100,131,98174,660,00002,523,136
15May 2, 2021 19:056,78899,693,98873,658,0001,009,0002,351,104
16May 2, 2021 18:586,804102,631,85372,853,0001,995,0002,277,376
17May 2, 2021 19:056,807101,027,10272,880,0001,996,0002,277,376
18May 2, 2021 18:586,81098,154,51572,908,0001,997,0002,277,376