Sort by

recency

|

1272 Discussions

|

  • + 0 comments
    def chocolateFeast(n, c, m):
        total_bars=n//c
        wrappers=total_bars 
        while True:
            bars=wrappers//m 
            total_bars+=bars 
            
            wrappers=(wrappers%m)+bars 
            if wrappers//m==0:
                break
        return total_bars 
    
  • + 0 comments

    Here is my Python solution!

    def chocolateFeast(n, c, m):
        wrap = n // c
        total = n // c
        while True:
            if wrap < m:
                return total
            total += wrap // m
            wrap = wrap // m + wrap % m
    
  • + 0 comments

    Here is my easy c++ solution , you can watch the explanation here : https://youtu.be/RZti_qPbiAA

    int chocolateFeast(int n, int c, int m) {
        int result = 0, wrappers = 0;
        while( n >= c){
            result ++;
            wrappers ++;
            n -= c;
            if(wrappers == m){
                result ++;
                wrappers = 1;
            }
        }
        return result;
    }
    
  • + 0 comments

    int chocolateFeast(int n, int c, int m) { int bars=n/c; int wrappers=n/c; while(wrappers>=m){ int new_bar=wrappers/m; bars=bars+new_bar; wrappers=(wrappers%m)+new_bar; } return bars; } see more

  • + 0 comments

    my python solution:

    def chocolateFeast(n, c, m):

    chocolate = int(n/c)
    wr = chocolate
    
    while wr >= m:
        chocolate +=1
        wr -= m
        wr += 1
    return chocolate