Untitled

From Botched Pig, 1 Year ago, written in Plain Text, viewed 438 times.
URL http://stoicbaby.com/pastebin/view/b5150a7f Embed
Download Paste or View Raw
  1. #!/usr/bin/python
  2.  
  3. def breedTo(cageLimit):
  4.     total = 1
  5.     totalAdults = 1
  6.     fertileAdults = 1
  7.     youngAdults = 0
  8.     babyPairs = 0
  9.     monthNum = 1
  10.     while total < cageLimit:
  11.         # Print each subsequent month's new values
  12.         print(monthNum, totalAdults, babyPairs, total)
  13.         # Increment the monthly value by one
  14.         monthNum = monthNum + 1
  15.         # All of our previous babies become young adults
  16.         youngAdults = babyPairs
  17.         # All of our total adults from the previous month are now fertile
  18.         fertileAdults = totalAdults
  19.         # Each of our fertile adults makes a pair of babies
  20.         babyPairs = fertileAdults
  21.         # Update what our new total adults will be
  22.         totalAdults = fertileAdults + youngAdults
  23.         # Find your total cages being used
  24.         total = totalAdults + babyPairs
  25.     return monthNum;
  26.  
  27. print("Month Adults Babies Total")
  28. # Call the function that determines when we will run out of cages
  29. monthNum = breedTo(500)
  30. print("Cages will run out sometime in month number", monthNum)

Reply to "Untitled"

Here you can reply to the paste above