Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Using math, acos(), pi solution in Clear category for Strawberry Fields by H0r4c3
from math import acos, pi
def strawberryfield(a, b, c, d):
result = (a**2 + d**2 - b**2 - c**2) / (2 * (b*c + d*a))
result = acos(result) / pi*180
print(round(result, 1))
return round(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 25, 2022
Comments: