Revision 8470722d-120d-42f2-b890-a6205f14753f - Code Golf Stack Exchange

R, <s>113</s> <s>100</s> 75 bytes
=

 function(N,t,l)(2*l*N)/(t*sum(sample(1e6,N,1)%%t+abs(cospi(runif(N)))*l>t))

Sample output:

 N=1000, t=1000, l=500
 3.037975

 N=10000, t=1000, l=700
 3.11943

 N=100000, t=1000, l=700
 3.140351

Some notes: this can probably be golfed down a bit. The `y` position is not needed in my calculation, so I haven't included it.

AltStyle によって変換されたページ (->オリジナル) /