Jason Tu
BAN USER
Comments (3)
Reputation -5
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Eh, a brute force solution.
# desired_num: desired number of mcnuggets
def get_mcnuggets(desired_num):
current_num = 0
a, b, c = [0, 0, 0]
while 20*c <= desired_num:
b = 0
while 9*b <= desired_num:
a = 0
while 6*a <= desired_num:
current_num = 6*a + 9*b + 20*c
if current_num == desired_num:
return True
a += 1
b += 1
c += 1
return False
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Meh, O(n^2).
- Jason Tu January 17, 2013