Last active
December 17, 2015 03:38
-
-
Save trliner/5544191 to your computer and use it in GitHub Desktop.
Calculate the circumference of a certain number of acres.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQUARE_FEET_PER_ACRE = 43560 | |
def circumference_in_feet_for_number_of_acres(number_of_acres) | |
area = number_of_acres * SQUARE_FEET_PER_ACRE | |
radius = radius_of_area(area) | |
circumference_of_radius(radius) | |
end | |
# Math::PI * (r ** 2) == area | |
# r ** 2 == area / Math::PI | |
# r == Math.sqrt(area / Math::PI) | |
def radius_of_area(area) | |
Math.sqrt(area / Math::PI) | |
end | |
def circumference_of_radius(r) | |
2 * Math::PI * r | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment