https://learninghub.kx.com/forums/topic/challenge-2-work-out-the-angle
Thank you to everyone who interacted with my last challenge! The replies were greatly appreciated.
My next challenge is for the math lovers. The triangle below, ABC is a right-angled triangle.
M is the mid-point of the hypotenuse AC.
You are given the lengths AB and BC (which are integers).
The task is to work out the angle MBC.
This is my solution:
// reading in 2 sides ab: "I"$read0 0 bc: "I"$read0 0 // finding the distance ac: sqrt((ab*ab)+(bc*bc)) bm: ac % 2.0 mc: bm // equalizing the sides b: mc c: bm a: bc // where b=c // finding the angle in radian angle_b_radian: acos(a % (2*b)) // converting the radian to degree round:{"F"$.Q.f[y]x} angle_b_degree: round[((180 * angle_b_radian) % 3.141593);2] answer: "i"$angle_b_degree show angle_b_degree
I would love to see other approaches to this so if anyone has any comments or suggestions please let me know