Guest User

Untitled

a guest
Nov 25th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. # Made by Ji Hyung Kim, Hong Min Lee. Dankook Univ.
  2.  
  3.  
  4. cow_num = 0 # How many Cow
  5. cow_weight = [] # Cow's weight
  6. cow_max = 0 # Max number of cows in boat
  7. weight_sum = 0 # boat weight
  8.  
  9.  
  10. def get_weight(): # Get Cow's Weight
  11. global cow_weight
  12. in_weight = int(input("Insert Cow weight> "))
  13. cow_weight.append(in_weight)
  14.  
  15.  
  16.  
  17. def start(): # Start Program
  18. global cow_num
  19. print("Cow Boat Simulator")
  20. cow_num = int(input("--How Many Cows?--\n>> "))
  21. for i in range(0, cow_num): # Get Cow's weight depend on cow's number
  22. get_weight()
  23. for i in range(0, cow_num):
  24. checkcheck = check_sum(cow_weight[i])
  25. if checkcheck is True:
  26. print("Adding Cow to Boat!") # Get cows on boat if True
  27. add_sum(cow_weight[i])
  28. else:
  29. print("Can't Add Cow!")
  30. continue
  31.  
  32.  
  33. def check_sum(weight): # Check presentation of cow's weight
  34. sum = weight_sum
  35. cow_instance = weight
  36. while ((sum!=0) and (cow_instance!=0)):
  37. if ((sum % 10 + cow_instance % 10) > 9):
  38. return False
  39. sum /= 10
  40. sum = int(sum)
  41. cow_instance /= 10
  42. cow_instance = int(cow_instance)
  43. return True
  44.  
  45.  
  46. def add_sum(weight):
  47. global cow_max, weight_sum
  48. weight_sum += weight
  49. cow_max += 1
  50.  
  51.  
  52. start()
  53. print(weight_sum)
  54. print(cow_max)
Add Comment
Please, Sign In to add comment