Coding challenge

Write some code to estimate the probability that 3 random points on the edges of a square form an obtuse triangle. The law of cosines may help, which is $\cos\theta=(b^2+c^2-a^2)/2bc$. Hint: sketch this first. Draw a square and put the random points $P_1$, $P_2$, and $P_3$ on 3 of its sides. Connect the three points with lines and see the resulting triangle. Apply the law of cosines as needed. (From Cheney, p. 588.)

Type your code here:


Lua reference

See your results here:

Show a friend, family member, or teacher what you've done!

Here is a share link to your code: