SOLUTION
>>> car = 4
>>>
tricycle = 3
>>> bicycle
= 2
>>> def
lessThanNineTyres(n,c,t,b):
if n == 4:
c += 1
elif n == 3:
t += 1
elif n == 2:
b +=1
else:
if (n == ( car + tricycle)):
c += 1
t += 1
elif (n == (car + bicycle)):
c += 1
b += 1
elif (n == (tricycle + bicycle)):
t += 1
b += 1
else:
if (b > t):
t += 2
b += 1
else:
b += 2
c += 1
countList = [c,t,b]
return countList
>>> c = 0
>>> t = 0
>>> b = 0
>>>
allTogether = 9
>>> n =
input("enter numbers of tyres :")
if n >= 9 :
a = n / allTogether
t += a
c += a
b += a
k = n % allTogether
if k > 1:
countList =[]
countList =
lessThanNineTyres(k,c,t,b)
c += countList[0]
t += countList[1]
b += countList[2]
else:
result = lessThanNineTyres(n,c,t,b)
c += result[0]
t += result[1]
b += result[2]
>>> print
"cars :",c,"\t tricycle :",t,"\t bicycle :",b
No comments:
Post a Comment