[Coco] Minesweeper
Ward Griffiths
wdg3rd at comcast.net
Mon Feb 6 23:15:42 EST 2006
On 02/06/2006 07:23 pm, Arthur Flexser wrote:
> An interesting mathematical problem, more or less equivalent to finding a
> formula for the expected number of dart throws when there are N squares and
> i darts, and a dart must be rethrown if it hits a square already occupied
> by another dart. Any takers?
I recall an assignment like that in my first BASIC course (on an HP) when I
was fresh out of the USAF in '78. Populate a linear array with values equal
to the locations. Randomly swap elements until you get tired. Put a dart in
the coordinates represented by the first i elements.
DIM B(338)
FOR E=1 to 338
B(E)=E
NEXT E
FOR L=1 TO 32767
I=RND(338)
J=RND(338)
T=B(I)
B(I)=B(J)
B(J)=T
NEXT L
--
Ward Griffiths wdg3rd at comcast.net
I think boys might benefit from owning a Barbie doll; every young man
should understand what an expensive proposition it is to cohabitate with
a narcissistic woman built like a stripper. -- Tony Woodlief
More information about the Coco
mailing list