• + 0 comments

    Oneliner

    def taumBday(b, w, bc, wc, z):
        return min(
            b * bc + w * wc,  # total price without converstion
            (b + w) * bc + w * z,  # total price while converting black to while
            (b + w) * wc + b * z  # total price while converting white to black
        )
    

    Just calculate three prices: 1. Total Price when gifts are bought at their original price without conversion 2. Total Price when gifts are bought at price of black (bc) and converated to white 3. Total Price when gifts are bought at price of white (wc) and converated to black 4. Just return the minimum cost