"I wrote a VB program to perform the tedious logic of combining and eliminating names, genders, and marble counts. (It's a long and laborious program but, thanks to the magic of copy/pasting, it only took a few minutes to write, and it ran in just a few seconds. The bigger my programs are, the faster they run. I won't reproduce it here)....Then I performed the age logic manually."
After being bombarded by numerous requests...
Just kidding. I am posting the code of the program referred to above, in the chance that a real programmer can point out improvements (other than introducing recursive code -- I've given up on that one). It really did take only a few minutes to write. It's not as complicated as it looks.
Imports System
Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
Sub Main()
Randomize()
Dim strexit As String
Console.WriteLine( _
"Start Execution: " & TimeOfDay)
For index01 As Integer = 1 To 5
For index02 As Integer = 1 To 5
For index03 As Integer = 1 To 5
For index04 As Integer = 1 To 5
For index05 As Integer = 1 To 5
If index01 + _
index02 + _
index03 + _
index04 + _
index05 = 15 Then
henry( _
index01, index02, index03, _
index04, index05)
End If
Next
Next
Next
Next
Next
Console.WriteLine( _
"End Execution: " & TimeOfDay)
strexit = " "
While strexit <= " "
Console.WriteLine( _
"Enter any nonblank character to exit")
strexit = LCase(Console.ReadLine())
End While
End Sub
Sub henry( _
ByRef index01, ByRef index02, ByRef index03, _
ByRef index04, ByRef index05)
For index11 As Integer = 1 To 5
If index11 <> index01 Then
For index12 As Integer = 1 To 5
If index12 <> index02 Then
For index13 As Integer = 1 To 5
If index13 <> index03 Then
For index14 As Integer = 1 To 5
If index14 <> index04 Then
For index15 As Integer = 1 To 5
If index15 <> index05 Then
If index11 + _
index12 + _
index13 + _
index14 + _
index15 = 15 And _
(index11 <> 2 And _
index12 <> 2 And _
index13 <> 2 And _
index14 <> 2 And _
index15 <> 2) Then
kirby( _
index01, index02, index03, _
index04, index05, _
index11, index12, index13, _
index14, index15)
End If
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
End Sub
Sub kirby( _
ByRef index01, ByRef index02, ByRef index03, _
ByRef index04, ByRef index05, _
ByRef index11, ByRef index12, ByRef index13, _
ByRef index14, ByRef index15)
For index21 As Integer = 1 To 5
If index21 <> index01 And _
index21 <> index11 Then
For index22 As Integer = 1 To 5
If index22 <> index02 And _
index22 <> index12 Then
For index23 As Integer = 1 To 5
If index23 <> index03 And _
index23 <> index13 Then
For index24 As Integer = 1 To 5
If index24 <> index04 And _
index24 <> index14 Then
For index25 As Integer = 1 To 5
If index25 <> index05 And _
index25 <> index15 Then
If index21 + _
index22 + _
index23 + _
index24 + _
index25 = 15 And _
((index21 Mod 2) = 1 And _
(index22 Mod 2) = 1 And _
(index23 Mod 2) = 0 And _
(index24 Mod 2) = 0 And _
(index25 Mod 2) = 1) Then
iris( _
index01, index02, index03, _
index04, index05, _
index11, index12, index13, _
index14, index15, _
index21, index22, index23, _
index24, index25)
End If
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
End Sub
Sub iris( _
ByRef index01, ByRef index02, ByRef index03, _
ByRef index04, ByRef index05, _
ByRef index11, ByRef index12, ByRef index13, _
ByRef index14, ByRef index15, _
ByRef index21, ByRef index22, ByRef index23, _
ByRef index24, ByRef index25)
For index31 As Integer = 1 To 5
If index31 <> index01 And _
index31 <> index11 And _
index31 <> index21 Then
For index32 As Integer = 1 To 5
If index32 <> index02 And _
index32 <> index12 And _
index32 <> index22 Then
For index33 As Integer = 1 To 5
If index33 <> index03 And _
index33 <> index13 And _
index33 <> index23 Then
For index34 As Integer = 1 To 5
If index34 <> index04 And _
index34 <> index14 And _
index34 <> index24 Then
For index35 As Integer = 1 To 5
If index35 <> index05 And _
index35 <> index15 And _
index35 <> index25 Then
If index31 + _
index32 + _
index33 + _
index34 + _
index35 = 15 And _
(index32 <> 2 And _
index33 <> 3 And _
index34 <> 4) Then
josephine( _
index01, index02, index03, _
index04, index05, _
index11, index12, index13, _
index14, index15, _
index21, index22, index23, _
index24, index25, _
index31, index32, index33, _
index34, index35)
End If
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
End Sub
Sub josephine( _
ByRef index01, ByRef index02, ByRef index03, _
ByRef index04, ByRef index05, _
ByRef index11, ByRef index12, ByRef index13, _
ByRef index14, ByRef index15, _
ByRef index21, ByRef index22, ByRef index23, _
ByRef index24, ByRef index25, _
ByRef index31, ByRef index32, ByRef index33, _
ByRef index34, ByRef index35)
For index41 As Integer = 1 To 5
If index41 <> index01 And _
index41 <> index11 And _
index41 <> index21 And _
index41 <> index31 Then
For index42 As Integer = 1 To 5
If index42 <> index02 And _
index42 <> index12 And _
index42 <> index22 And _
index42 <> index32 Then
For index43 As Integer = 1 To 5
If index43 <> index03 And _
index43 <> index13 And _
index43 <> index23 And _
index43 <> index33 Then
For index44 As Integer = 1 To 5
If index44 <> index04 And _
index44 <> index14 And _
index44 <> index24 And _
index44 <> index34 Then
For index45 As Integer = 1 To 5
If index45 <> index05 And _
index45 <> index15 And _
index45 <> index25 And _
index45 <> index35 Then
If index41 + _
index42 + _
index43 + _
index44 + _
index45 = 15 Then
louise( _
index01, index02, index03, _
index04, index05, _
index11, index12, index13, _
index14, index15, _
index21, index22, index23, _
index24, index25, _
index31, index32, index33, _
index34, index35, _
index41, index42, index43, _
index44, index45)
End If
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
End Sub
Sub louise( _
ByRef index01, ByRef index02, ByRef index03, _
ByRef index04, ByRef index05, _
ByRef index11, ByRef index12, ByRef index13, _
ByRef index14, ByRef index15, _
ByRef index21, ByRef index22, ByRef index23, _
ByRef index24, ByRef index25, _
ByRef index31, ByRef index32, ByRef index33, _
ByRef index34, ByRef index35, _
ByRef index41, ByRef index42, ByRef index43, _
ByRef index44, ByRef index45)
Dim intcount1 As Integer
Dim intcount2 As Integer
Dim intcount3 As Integer
Dim intcount4 As Integer
Dim intcount5 As Integer
intcount1 = 0
intcount2 = 0
intcount3 = 0
intcount4 = 0
intcount5 = 0
If index03 = 3 Then
If index04 > 2 Or _
index05 > 2 Then
Exit Sub
End If
End If
If index13 = 3 Then
If index14 > 2 Or _
index15 > 2 Then
Exit Sub
End If
End If
If index23 = 3 Then
If index24 > 2 Or _
index25 > 2 Then
Exit Sub
End If
End If
If index33 = 3 Then
If index34 > 2 Or _
index35 > 2 Then
Exit Sub
End If
End If
If index43 = 3 Then
If index44 > 2 Or _
index45 > 2 Then
Exit Sub
End If
End If
If index01 = 5 Then
intcount1 += 1
End If
If index11 = 5 Then
intcount1 += 1
End If
If index23 = 3 Then
intcount2 += 1
End If
If index33 = 3 Then
intcount2 += 1
End If
If index43 = 3 Then
intcount2 += 1
End If
If index05 = 5 Then
intcount3 += 1
End If
If index15 = 5 Then
intcount3 += 1
End If
If index01 = 3 And index03 = 5 And index05 = 1 Then
intcount4 += 1
End If
If index11 = 3 And index13 = 5 And index15 = 1 Then
intcount4 += 1
End If
If index21 = 3 And index23 = 5 And index25 = 1 Then
intcount4 += 1
End If
If index31 = 3 And index33 = 5 And index35 = 1 Then
intcount4 += 1
End If
If index41 = 3 And index43 = 5 And index45 = 1 Then
intcount4 += 1
End If
If index02 = (2 * index03) Then
intcount5 += 1
End If
If index12 = (2 * index13) Then
intcount5 += 1
End If
If index22 = (2 * index23) Then
intcount5 += 1
End If
If index32 = (2 * index33) Then
intcount5 += 1
End If
If index42 = (2 * index43) Then
intcount5 += 1
End If
If intcount1 <> 1 Then
Exit Sub
End If
If intcount2 <> 1 Then
Exit Sub
End If
If intcount3 <> 1 Then
Exit Sub
End If
If intcount4 <> 1 Then
Exit Sub
End If
If intcount5 < 2 Then
Exit Sub
End If
Console.WriteLine("Valid Combination: ")
Console.WriteLine( _
"Henry: " & _
index01 & index02 & index03 & index04 & index05 & " ; " & _
"Kirby: " & _
index11 & index12 & index13 & index14 & index15 & " ; " & _
"Iris: " & _
index21 & index22 & index23 & index24 & index25 & " ; " & _
"Josephine: " & _
index31 & index32 & index33 & index34 & index35 & " ; " & _
"Louise: " & _
index41 & index42 & index43 & index44 & index45)
End Sub
End Module