Sort by

recency

|

1289 Discussions

|

  • + 0 comments

    int feast = n/c; int wrappers = n/c; while(wrappers >= m){ wrappers = wrappers - m + 1; feast++; } return feast;

  • + 0 comments

    public static int chocolateFeast(int n, int c, int m) {

        int chacos=n/c;
        int wrappers=chacos;
        while(wrappers>=m)
        {
            var temp=wrappers/m; //used and got chacos
            wrappers%=m; //leftover wrappers
            chacos+=temp; // increasing chacos count
            wrappers+=temp; // As I got new chacos, i will have new wrappers too.     
        }
    
        return chacos;          
    }
    
  • + 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; } auto tinting

  • + 0 comments
    # Chocolate Feast 🍫
    def chocolate_feast(n, c, m):
        chocolates = wrappers = n // c
        while wrappers >= m:
            chocolates += wrappers // m
            wrappers = wrappers % m + wrappers // m
        return chocolates
    
  • + 0 comments
    fun chocolateFeast(money: Int, cost: Int, m: Int): Int {
        // Write your code here
        var total = 0
        var eaten = 0
        total = money / cost
        eaten = total
        var wrappers = total
        do{
            total+=wrappers / m
            wrappers = wrappers % m
            wrappers = wrappers + (total - eaten)
            eaten = total
        }while(wrappers >= m)
        return total
    }