Rel: There is a bell curve here to contend with. It's not a linear ramp.

hoon:

Dim D(1 To 8) As Integer

Dim C(1 To 5) As Integer

Dim Matches As Long

Dim Total As Long

Total = 0

Matches = 0

D(1) = 0

Do

D(1) = D(1) + 1 '' All possable sides of die 1

D(2) = 0

Do

D(2) = D(2) + 1 '' All possable sides of die 2

D(3) = 0

Do

D(3) = D(3) + 1 '' All possable sides of die 3

D(4) = 0

Do

D(4) = D(4) + 1 '' All possable sides of die 4

D(5) = 0

Do

D(5) = D(5) + 1 '' All possable sides of die 5

D(6) = 0

Do

D(6) = D(6) + 1 '' All possable sides of die 6

D(7) = 0

Do

D(7) = D(7) + 1 '' All possable sides of die 7

D(8) = 0

Do

D(8) = D(8) + 1 '' All possable sides of die 8

Total = Total + 1 '' Increase total combination count

C(1) = 0

Do

C(1) = C(1) + 1 '' All possable dice

C(2) = C(1)

Do

C(2) = C(2) + 1 '' All possable dice

C(3) = C(2)

Do

C(3) = C(3) + 1 '' All possable dice

C(4) = C(3)

Do

C(4) = C(4) + 1 '' All possable dice

C(5) = C(4)

Do

C(5) = C(5) + 1 '' All possable dice

'' Check dice 1=2, 1=3, 1=4, 1=5

If (D(C(1)) = D(C(2))) And (D(C(1)) = D(C(3))) And (D(C(1)) = D(C(4))) And (D(C(1)) = D(C(5))) Then

'' Check die 1 = 4

If D(1) = 4 Then Matches = Matches + 1

End If

Loop Until C(5) = 8

Loop Until C(4) = 7

Loop Until C(3) = 6

Loop Until C(2) = 5

Loop Until C(1) = 4

Loop Until D(8) = 6

Loop Until D(7) = 6

Loop Until D(6) = 6

Loop Until D(5) = 6

Loop Until D(4) = 6

Loop Until D(3) = 6

Loop Until D(2) = 6

Loop Until D(1) = 6

Print "Of"; Total; "combinations, statistically, 5 of 8 dice equalling 4 will match"; Matches; "times."

End

Compiling this in VB6 to take advantage of my Athlon, it only took 10 seconds (10.3584, but who cares?

)

Anyway, this is the output:

Of 1679616 combinations, statistically, 5 of 8 dice equalling 4 will match 12096 times.

A 'random' version can be done as follows (but it's inaccurate):

Dim D(1 To 8) As Integer

Dim C(1 To 5) As Integer

Dim Matches As Long

Dim Total As Long

Randomize Timer '' Seed random number generator

Matches = 0

For Total = 0 To 999

D(1) = Int(Rnd * 6) + 1

D(2) = Int(Rnd * 6) + 1

D(3) = Int(Rnd * 6) + 1

D(4) = Int(Rnd * 6) + 1

D(5) = Int(Rnd * 6) + 1

D(6) = Int(Rnd * 6) + 1

D(7) = Int(Rnd * 6) + 1

D(8) = Int(Rnd * 6) + 1

C(1) = 0

Do

C(1) = C(1) + 1 '' All possable dice

C(2) = C(1)

Do

C(2) = C(2) + 1 '' All possable dice

C(3) = C(2)

Do

C(3) = C(3) + 1 '' All possable dice

C(4) = C(3)

Do

C(4) = C(4) + 1 '' All possable dice

C(5) = C(4)

Do

C(5) = C(5) + 1 '' All possable dice

'' Check dice 1=2, 1=3, 1=4, 1=5

If (D(C(1)) = D(C(2))) And (D(C(1)) = D(C(3))) And (D(C(1)) = D(C(4))) And (D(C(1)) = D(C(5))) Then

'' Check die 1 = 4

If D(1) = 4 Then Matches = Matches + 1

End If

Loop Until C(5) = 8

Loop Until C(4) = 7

Loop Until C(3) = 6

Loop Until C(2) = 5

Loop Until C(1) = 4

Next Total

Print "Of"; Total; "combinations, statistically, 5 of 8 dice equalling 4 will match"; Matches; "times."

End

Running it several times, I got the following results:

Of 1000 combinations, statistically, 5 of 8 dice equalling 4 will match 19 times.

Of 1000 combinations, statistically, 5 of 8 dice equalling 4 will match 16 times.

Of 1000 combinations, statistically, 5 of 8 dice equalling 4 will match 3 times.

Of 1000 combinations, statistically, 5 of 8 dice equalling 4 will match 9 times.

Of 1000 combinations, statistically, 5 of 8 dice equalling 4 will match 15 times.

Of 1000 combinations, statistically, 5 of 8 dice equalling 4 will match 1 times.

Of 1000 combinations, statistically, 5 of 8 dice equalling 4 will match 2 times.

As you can see, it is not accurate at all.