6
Input 5 integers: Landmark X
& Y
, Starting Point X
& Y
, and View Distance Radius D
Output 1 double: % chance of coming within D
of Landmark (X
,Y
) ("seeing") when walking straight in a random direction from Starting Point (X
,Y
).
Assume that "random direction" shall be a direction uniform on [0,2π], the land is flat, and of course the 'hiker' never turns after he begins moving.
Example: If landmark is at (10,10), starting point is (5,5), and view distance is 20 then the output would be 100% as no matter which direction you walk the landmark will be immediately visible.
1This kinda lost its appeal since you already linked to the solution. – Martin Ender – 2014-07-24T18:23:02.573
@MartinBüttner I hadn't considered that since it is hardly implemented as code... but I suppose I can remove it if people also want to solve the math. – MetaGuru – 2014-07-24T19:08:03.173
@ioSamurai just wanted to let you know that people can still see the math if they choose to look at the revisions - although I don't see any problem with leaving the math there.. people would be able to copy the math from the first answer, and would be challenged with optimizing the space anyways...
– user2813274 – 2014-08-06T15:18:13.467@user2813274 Yeah I didn't think showing the math was an issue anyways because it was really about the coding. – MetaGuru – 2014-08-06T15:24:23.243
2If you want to make this challenging/interesting, i suggest you ban trigonometric functions. Accuracy of probability should also be specified (I suggest to the nearest 1%, given that probability can be from 0 to 100%.) – Level River St – 2014-08-06T15:39:14.450