I like this one.
The minimum distance the dog must is to point N
That distance is 300m + (1/2) * 300m = 450m
The maximum distance the dog must run is to point C
That distance is 300m + 300m = 600m
Any point for N < - > C is N + increment * 2,
so in pseudocode:
The hypoteneuse c of this triangle is:Code:// hypoteneuse works only from 302m onward - // otherwise the manDistance is150m for (N1 = 302;N1<=600;N1+=2){ manDistance = hypoteneuse of triangle; dogDistance = 300 + N1; if manDistance > (dogDistance * pi) printf("safe") else printf("ouch"); }
c^2 = (N1)^2 + (150)^2
or
c = sqrt( (N1)^2 + (150)^2 )




Reply With Quote