Sort by

recency

|

940 Discussions

|

  • + 0 comments

    **Simple Python Solution **

    x = min(bc,wc+z)
    y = min(wc,bc+z)
    return (b*x) + (w*y)
    
  • + 0 comments

    def taumBday(b, w, bc, wc, z): if bc == wc: return (b*bc)+(w*wc) else: if min(bc,wc)+z >= max(bc,wc): return (b*bc)+(w*wc) else: if wc < bc: return ((wc+z)*b)+(w*wc) else: return ((bc+z)*w)+(b*bc)

  • + 0 comments
    public static long taumBday(long noOfBlackGifts, long noOfWhiteGifts, long blackGiftPrice, long whiteGiftPrice, int conversionCost) {
        if(conversionCost < Math.abs(blackGiftPrice-whiteGiftPrice)) {
            if(blackGiftPrice < whiteGiftPrice) {
                whiteGiftPrice = blackGiftPrice + conversionCost;
            } else if(whiteGiftPrice < blackGiftPrice){
                blackGiftPrice = whiteGiftPrice + conversionCost;
            }
        }
        return (noOfBlackGifts * blackGiftPrice) + (noOfWhiteGifts * whiteGiftPrice);
    }
    
  • + 0 comments

    Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-taum-and-bday-problem-solution.html

  • + 1 comment

    Here is my simple c++ solution, you can watch the explanation here : https://youtu.be/T9sxEzAbp-M

    long taumBday(int b, int w, int bc, int wc, int z) {
        long bp = min(bc, wc + z);
        long wp = min(wc, bc + z);
        return bp * b + wp * w;
    }