Option Explicit On
Option Strict On
Imports System
Module LostCoins
Sub Main()
Const LOWEST As Integer = 0
Const HIGHEST As Integer = 5
Dim weights() As Integer = { 2500, 5000, 2268, 5670, 11340, 8100 }
Dim coins() As String = { "Pennies", "Nickels", "Dimes", "Quarters", "HalfBucks", "Bucks" }
Const TARGET As Integer = 304588
Dim i1, i2, i3, i4, i5, i6 As Integer
For i1 = LOWEST To HIGHEST - 5
For i2 = i1 + 1 To HIGHEST - 4
For i3 = i2 + 1 To HIGHEST - 3
For i4 = i3 + 1 To HIGHEST - 2
For i5 = i4 + 1 To HIGHEST - 1
For i6 = i5 + 1 To HIGHEST
If weights(i1) + weights(i2) + weights(i3) + weights(i4) + weights(i5) + weights(i6) = TARGET Then
Console.WriteLine("{0} + {1} + {2} + {3} + {4} + {5} = {6}", weights(i1), weights(i2), weights(i3), weights(i4), weights(i5), weights(i6), TARGET)
End If
Next
Next
Next
Next
Next
Next
End Sub
End Module