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:06Yuriy LyfenkoYuriy LyfenkoScore: 5,621Success
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:065,583688,325,50260,421,000990,0002,265,088
2May 19, 2021 19:065,6003,632,908,67461,601,00002,260,992
3May 19, 2021 19:065,6053,901,563,30561,659,00002,265,088
4May 19, 2021 19:065,6134,732,791,07859,751,0001,991,0002,527,232
5May 19, 2021 19:065,615641,916,93160,768,000996,0002,265,088
6May 19, 2021 19:065,616558,112,54560,783,000996,0002,387,968
7May 19, 2021 19:065,621262,584,35861,836,00002,396,160
8May 19, 2021 19:065,6224,521,036,04158,852,0002,992,0002,527,232
9May 19, 2021 19:065,6241,011,375,83758,873,0002,993,0002,527,232
10May 19, 2021 19:065,8641,393,773,86664,502,84002,306,048
11May 19, 2021 19:065,8783,679,707,15964,654,45202,244,608
12May 19, 2021 19:065,895471,732,25264,849,31102,252,800