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 19, 2021 19:04Yuriy LyfenkoYuriy LyfenkoScore: 5,611Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 19, 2021 19:045,5951,798,591,14059,556,0001,985,0002,523,136
2May 19, 2021 19:045,5994,277,133,68759,598,0001,986,0002,260,992
3May 19, 2021 19:045,600543,218,88160,603,000993,0002,269,184
4May 19, 2021 19:045,609609,673,04459,706,0001,990,0002,527,232
5May 19, 2021 19:045,6103,096,577,95060,715,000995,0002,260,992
6May 19, 2021 19:045,6112,448,946,52461,725,00002,527,232
7May 19, 2021 19:045,6112,068,556,58859,734,0001,991,0002,269,184
8May 19, 2021 19:045,6161,589,869,18659,788,0001,992,0002,260,992
9May 19, 2021 19:045,6241,707,023,78161,864,00002,527,232
10May 19, 2021 19:045,8884,053,707,09964,768,64702,244,608
11May 19, 2021 19:045,8901,797,401,23264,786,39502,244,608
12May 19, 2021 19:045,8994,768,283,75664,889,28502,240,512