All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
points or pigeons in square? (Posted on 2019-08-05) Difficulty: 2 of 5
Given 5 points inside a square of side 10 cm, what is the probability that at least two of the points are within 8cm of each other?

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
re(2): computer soln Comment 8 of 8 |
(In reply to re: computer soln by Daniel)

Right you both are! 10*sqrt(2)/2<8 (do'h!)


There was a bug as you found. The output of the new code is below! 
D'oh! (Trick problem, much like the rope between the poles.....)

 exp?

7 64

 cnt =            0

 10000000 1.0000000000000 0.0000000000000

 exp?

8 64

 cnt =            0

100000000 1.0000000000000 0.0000000000000


        program sq5

        implicit none

        integer good,seed,pa(2,10),i,j,exp,big,cnt

        real*8 dd,x(5),y(5),dx2,dy2,d,prob,prob1,xbig

        data pa/1,2,1,3,1,4,1,5,2,3,2,4,2,5,3,4,3,5,4,5/

        seed=time8()

        call srand(seed)

1       print*,'exp?'

        read*,exp,dd

        big=10**exp

        xbig=big

        if(exp.eq.0)stop

        cnt=0

           do i=1,big

                do j=1,5

                x(j)=10*rand()

                y(j)=10*rand()

                enddo

                do j=1,10

                dx2=(x(pa(1,j))-x(pa(2,j)))**2

                dy2=(y(pa(1,j))-y(pa(2,j)))**2

                d=dx2+dy2

c       print*,i,d

                   if(d.lt.dd)go to 3

                enddo

           cnt=cnt+1

3          enddo

        print*,'cnt = ',cnt


        prob=(big-1.d0*cnt)/xbig

        prob1=1.d0-prob

        print4,big,prob,prob1

4       format(i9,2(1x,f15.13))

        go to 1

        end


Edited on August 5, 2019, 10:57 pm
  Posted by Steven Lord on 2019-08-05 22:56:45

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information