You are viewing a single comment's thread. Return to all comments →
That's basically what I did, except in Python.
choc, wrappers = [int(n/c), int(n/c)] while (wrappers >= m): choc+= 1 wrappers -= m wrappers += 1 print(choc)
A better version:
choc = wrappers = n // c while (wrappers >= m): choc+= 1 wrappers -= m - 1 print(choc)
Similar here without iterating every bar/wrapper swap
bars = wrappers = n // c while wrappers >= m: bars += wrappers // m wrappers -= wrappers // m * (m - 1) return bars
Chocolate Feast
You are viewing a single comment's thread. Return to all comments →
That's basically what I did, except in Python.
A better version:
Similar here without iterating every bar/wrapper swap