Advertisement
Guest User

Optimizer Problem

a guest
Jan 4th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. from math import floor
  2. value = 2800
  3. h,f,t = 0,0,0
  4.  
  5. if value < 5000:
  6.     if value % 1000 == 0:
  7.         f = f + 1
  8.         h = h + 5
  9.         t = t + int(((value-1000)/1000))
  10.     elif value % 500 == 0:
  11.         f = f + 1
  12.         t = t + int(((value-1000)/1000))
  13.     elif value % 1000 < 500:
  14.         h = h + ((value % 1000)/100)
  15.         t = t + floor(value/1000)
  16.     else:
  17.         f = f + 1
  18.         t = t + floor(value/1000)
  19.         h = h + ((value % 1000)/100) - 5
  20. else:
  21.     if value % 1000 == 0:
  22.         f = f + 2
  23.         t = t + int(((value-1000)/1000))
  24.     elif value % 500 == 0:
  25.         f = f + 1
  26.         t = t + int(((value-1000)/1000))
  27.     elif value % 1000 < 500:
  28.         h = h + ((value % 1000)/100)
  29.         t = t + floor(value/1000)
  30.     else:
  31.         f = f + 1
  32.         t = t + floor(value/1000)
  33.         h = h + ((value % 1000)/100) - 5
  34.  
  35. print("Hundreds = " + str(int(h)))
  36. print("Five Hundreds = " + str(int(f)))
  37. print("Thosuands = " + str(int(t)))
  38. print(str(int(h*100)) + " + " + str(int(f*500)) + " + " + str(int(t*1000)) + " = " + str(value))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement