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 19:13Yurkov AlekseyYurkov AlekseyScore: 6,778Success
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:066,75795,478,25373,327,0001,004,0002,523,136
2May 2, 2021 19:066,76897,835,65071,433,0003,018,0002,277,376
3May 2, 2021 19:136,769101,875,88474,460,00002,277,376
4May 2, 2021 19:136,77097,335,25674,467,00002,277,376
5May 2, 2021 19:136,773102,536,79074,508,00002,277,376
6May 2, 2021 19:066,77396,488,27972,490,0002,013,0002,277,376
7May 2, 2021 19:066,774102,335,15173,503,0001,006,0002,277,376
8May 2, 2021 19:136,77597,157,65273,522,0001,007,0002,277,376
9May 2, 2021 19:066,77895,979,91573,548,0001,007,0002,277,376
10May 2, 2021 19:066,77895,873,99373,556,0001,007,0002,265,088
11May 2, 2021 19:136,783101,042,57974,612,00002,277,376
12May 2, 2021 19:136,783101,519,45373,609,0001,008,0002,531,328
13May 2, 2021 19:066,785104,536,05773,625,0001,008,0002,277,376
14May 2, 2021 19:136,787102,106,32372,642,0002,017,0002,277,376
15May 2, 2021 19:066,79098,725,50273,682,0001,009,0002,277,376
16May 2, 2021 19:136,793105,987,17672,726,0001,992,0002,273,280
17May 2, 2021 19:136,803101,486,45372,843,0001,995,0002,523,136
18May 2, 2021 19:066,804104,493,24972,852,0001,995,0002,523,136