Skip to content

Instantly share code, notes, and snippets.

@Rimann91
Last active October 25, 2015 20:34
Show Gist options
  • Select an option

  • Save Rimann91/50837ef47bde46a34683 to your computer and use it in GitHub Desktop.

Select an option

Save Rimann91/50837ef47bde46a34683 to your computer and use it in GitHub Desktop.
Calculator for materials needed for garden beds
"""Takes input from user and calculates materials for building garden beds
of a particular demension. User inputs demensions, width length and height
of garden bed in feet, as well as the number of beds to be built. All
outputs are in feet. Outputs include the total number feet needed of 2 by
six lumber to build the beds, and calculates the most effecient use of the
lumber by iterating through a list of standard board lengths."""
# calculates total amount of wood per bed
def amount_wood(length, width, height):
total = 0
length = length * 2
width = width * 2
feet = length + width
if height == 6 or height == .5:
total = feet
elif height == 1:
total = feet * 2
elif height == 1.5:
total = feet * 3
elif height == 2:
total = feet * 4
elif height > 2:
return 'no calculation for height over two'
else:
return 'need specific height in'
return total
#calculate amount of wood for all beds
def times_beds(num_beds):
return feet * num_beds
# determine total amount of side peices needed. Same for long and wide
def amt_sides(height):
sides = 0
if height == 6 or height == .5:
height = 1
elif height == 1:
height = 2
elif height == 1.5:
height = 3
elif height == 2:
height = 4
else:
return 'need specific height in'
sides += height * 2 * num_beds
return sides
# determine most effecient use of materials
def board_size(sides, length, width, board_lengths):
new_boardlist = []
for size in board_lengths:
if size % length * sides >= 0:
new_boardlist.append(size)
else:
if size % length * sides > 24:
sides -= length / sides
new_boardlist.append(24)
for size in board_lengths:
if size % width * sides >= 0:
new_boardlist.append(size)
else:
if size % width * sides > 24:
sides -= width / sides
new_boardlist.append(24)
return new_boardlist
width = float(raw_input('enter width '))
length = float(raw_input('enter length '))
height = float(raw_input('enter height '))
feet = amount_wood(length, width, height)
num_beds = float(raw_input('how many beds of size?'))
sides = amt_sides(height)
board_lengths = [8, 12, 16, 20, 24]
print feet
print times_beds(num_beds)
print ('you need ' + str(sides) +', '+ str(length) +
' foot boards, and ' + str(sides) +', '+ str(width)
+ ' foot boards.')
print board_lengths
print board_size(sides, length, width, board_lengths)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment