Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Strawberry Fields by Sim0000
from math import acos, degrees
def strawberryfield(a, b, c, d):
return round(degrees(acos((a**2 + d**2 - b**2 - c**2) / (2 * (a * d + b * c)))), 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' ?")
Dec. 9, 2017
Comments: