Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
acos, degrees solution in Clear category for Strawberry Fields by kurosawa4434
from math import acos, degrees
def strawberryfield(a, b, c, d):
result = acos( (a**2 + d**2 - c**2 - b**2) / (2 * (a * d + c * b)))
return round(degrees(result), 1)
# These "asserts" are used for self-checking only and not for an auto-testing
if __name__ == '__main__':
assert(strawberryfield(100, 100, 100, 100) == 90) , "square"
assert(strawberryfield(150, 100, 150, 100) == 90) , "rectangle"
assert(strawberryfield(150, 100, 50, 100) == 60) , "trapezium"
assert(strawberryfield(203, 123, 82, 117) == 60.8) , "quadrilateral"
print("Looks good so far! . . . How does 'Check' ?")
April 20, 2018
Comments: