Last answered:

04 Jan 2023

Posted on:

14 Nov 2022

1

Alternative solution

How about: total_slices // 6 + 1 ?

2 answers ( 0 marked as helpful)
Posted on:

02 Jan 2023

0

I thought the same, but it would not work. Sorry.  For example, if we have 3 people who want 12 slices, it will be 12/6+1 = 3 pizzas. Clearly you don't want to order 3 pizzas for 3 people where 2 pizzas are needed.

Posted on:

04 Jan 2023

3

@Josh Actually, the above method works if we add a condition, that is, if the remainder of total_slides/6 ==0, then we do not add 1.

total_slides=4*4
if total_slides % 6 == 0:
    num_pizzas = total_slides/6
else:
    num_pizzas = total_slides // 6 + 1
print(num_pizzas)

#The symbol '%' is modulus which finds the reminder of a division. The symbol '==' checks for equality between left-hand-slide of an equation and right-hand-side of the same equation.

Submit an answer