Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Made by Ji Hyung Kim, Hong Min Lee. Dankook Univ.
- cow_num = 0 # How many Cow
- cow_weight = [] # Cow's weight
- cow_max = 0 # Max number of cows in boat
- weight_sum = 0 # boat weight
- def get_weight(): # Get Cow's Weight
- global cow_weight
- in_weight = int(input("Insert Cow weight> "))
- cow_weight.append(in_weight)
- def start(): # Start Program
- global cow_num
- print("Cow Boat Simulator")
- cow_num = int(input("--How Many Cows?--\n>> "))
- for i in range(0, cow_num): # Get Cow's weight depend on cow's number
- get_weight()
- for i in range(0, cow_num):
- checkcheck = check_sum(cow_weight[i])
- if checkcheck is True:
- print("Adding Cow to Boat!") # Get cows on boat if True
- add_sum(cow_weight[i])
- else:
- print("Can't Add Cow!")
- continue
- def check_sum(weight): # Check presentation of cow's weight
- sum = weight_sum
- cow_instance = weight
- while ((sum!=0) and (cow_instance!=0)):
- if ((sum % 10 + cow_instance % 10) > 9):
- return False
- sum /= 10
- sum = int(sum)
- cow_instance /= 10
- cow_instance = int(cow_instance)
- return True
- def add_sum(weight):
- global cow_max, weight_sum
- weight_sum += weight
- cow_max += 1
- start()
- print(weight_sum)
- print(cow_max)
Add Comment
Please, Sign In to add comment