Guest User

pset2 problem1

a guest
Jan 29th, 2012
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. ## 6a + 9b + 20c = x
  2. ## x >= 50 for all non-negative integers a b c
  3.  
  4. a = 6
  5. b = 9
  6. c = 20
  7.  
  8. aOrders = 0
  9. bOrders = 0
  10. cOrders = 0
  11.  
  12. result = 0
  13.  
  14. for i in range(50,56):                  
  15.     testValue = i
  16.    
  17.     cOrders = 0
  18.     while(cOrders * c < testValue):
  19.         bOrders = 0
  20.    
  21.         while(bOrders * b < testValue):
  22.             aOrders = 0
  23.        
  24.             while(aOrders * a < testValue):
  25.                  if (a*aOrders)+(b*bOrders)+(c*cOrders) == testValue:
  26.                     result = (aOrders,bOrders,cOrders)
  27.                     print str(result) + ' combines to ' + str(testValue)
  28.                 aOrders = aOrders + 1
  29.  
  30.             bOrders = bOrders + 1
  31.            
  32.         cOrders = cOrders + 1
Advertisement
Add Comment
Please, Sign In to add comment