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

 Coin Collection (Posted on 2004-05-04)
When I went over to see a rare coin collection, I asked the care taker of the coins about them.

"In each box, the number of coins is a perfect square, and each box has a different number of coins."
"How are the coins in your 9 boxes organized?"
"I put them in chronological order by groups. The ancient coins are in boxes A, B, C; my old coins in boxes D, E, F; and my recent coins sit in boxes G, H, I."
"How else are they organized?"
"Well, within each time period (ancient, old, recent), the numbers form an arithmetic sequence, and the common difference is the same for all three time periods."
"How many coins do you have in each box?"
"I'm not sure, but I do know that a newer box would always have more coins that an older box from that time period. For example, feel box A. I have very few coins in that box, less than a dozen."

How many coins are in each box?

 See The Solution Submitted by Gamer Rating: 4.2000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Solution | Comment 5 of 12 |

Boxes A,B,C contained {4, 3364, 6724}.

Boxes D,E.F contained {2116, 5476, 8836}

Boxes G,H,I contained {9409, 12769, 16129}

Visual Basic program used:

Imports System
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
Sub Main()
Randomize()
Dim strGoAgain As String
strGoAgain = "Y"
While strGoAgain = "Y"
Mainline()
Console.WriteLine("Want to try again ? (Y/N)")
End While
End Sub
Sub Mainline()
Dim dblWork1 As Double
Dim dblWork2 As Double
Dim dblWork3 As Double
Dim dblSave As Double
Dim dblNumb1 As Double
Dim dblNumb2 As Double
Dim dblNumb3 As Double
Dim dblNumb4 As Double
Dim dblNumb5 As Double
Dim dblIntervalCount As Double
Dim dblIntervalTotal As Double
Dim dblArray(10000, 4) As Double
Dim dblSubscriptA1 As Double
Dim dblSubscriptA2 As Double
Dim dblSubscriptB1 As Double
Dim dblSubscriptB2 As Double
Dim dblSubscriptC1 As Double
Dim dblSubscriptC2 As Double
dblIntervalCount = 0
dblIntervalTotal = 0
dblSubscriptA1 = 4211949
While dblSubscriptA1 = 4211949
Console.WriteLine("Please enter first range start value.")
End While
dblSubscriptA2 = 4211949
While dblSubscriptA2 = 4211949
Console.WriteLine("Please enter first range end value.")
End While
dblSubscriptB1 = 4211949
While dblSubscriptB1 = 4211949
Console.WriteLine("Please enter second range start value.")
End While
dblSubscriptB2 = 4211949
While dblSubscriptB2 = 4211949
Console.WriteLine("Please enter second range end value.")
End While
dblSubscriptC1 = 4211949
While dblSubscriptC1 = 4211949
Console.WriteLine("Please enter third range start value.")
End While
dblSubscriptC2 = 4211949
While dblSubscriptC2 = 4211949
Console.WriteLine("Please enter third range end value.")
End While
Console.WriteLine("  ")
Console.WriteLine("" & _
"The ranges searched will be " & _
Str(dblSubscriptA1) & " - " & Str(dblSubscriptA2) & "," & _
Str(dblSubscriptB1) & " - " & Str(dblSubscriptB2) & "," & _
Str(dblSubscriptC1) & " - " & Str(dblSubscriptC2))
Console.WriteLine(" ")
For Index01 As Double = 0 To 9999
dblArray(Index01, 0) = 0
dblArray(Index01, 1) = 0
dblArray(Index01, 2) = 0
dblArray(Index01, 3) = 0
Next
For Index1 As Double = dblSubscriptA1 To dblSubscriptA2
For Index2 As Double = dblSubscriptB1 To dblSubscriptB2
For Index3 As Double = dblSubscriptC1 To dblSubscriptC2
dblWork1 = Index1
dblWork2 = Index2
dblWork3 = Index3
If dblWork1 > dblWork2 Then
dblSave = dblWork1
dblWork1 = dblWork2
dblWork2 = dblSave
End If
If dblWork2 > dblWork3 Then
dblSave = dblWork2
dblWork2 = dblWork3
dblWork3 = dblSave
End If
If dblWork1 > dblWork2 Then
dblSave = dblWork1
dblWork1 = dblWork2
dblWork2 = dblSave
End If
IntervalBreak(dblIntervalCount, _
dblIntervalTotal, _
Index1, Index2, Index3, dblArray)
dblNumb1 = dblWork1 ^ 2
dblNumb2 = dblWork2 ^ 2
dblNumb3 = dblWork3 ^ 2
dblNumb4 = dblNumb2 - dblNumb1
dblNumb5 = dblNumb3 - dblNumb2
If dblNumb4 = dblNumb5 And _
(dblNumb1 <> dblNumb2) And _
(dblNumb1 <> dblNumb3) And _
(dblNumb2 <> dblNumb3) Then
TestNumbersInArray(dblNumb1, _
dblNumb2, dblNumb3, dblNumb4, _
dblArray, _
dblIntervalCount, dblIntervalTotal, _
Index1, Index2, Index3)
End If
Next
Next
Next
Console.WriteLine("No hits for these index values")
Console.WriteLine("  ")
End Sub

Sub TestNumbersInArray(ByRef dblNumb1, _
ByRef dblNumb2, ByRef dblNumb3, ByRef dblNumb4, ByRef dblArray, _
ByRef dblIntervalCount, ByRef dblIntervalTotal, _
ByRef Index1, ByRef Index2, ByRef Index3)
Dim dblTab1 As Double
Dim dblTab2 As Double
Dim dblTab3 As Double
Dim dblDiff1 As Double
Dim dblTab4 As Double
Dim dblTab5 As Double
Dim dblTab6 As Double
Dim dblDiff2 As Double
Dim strTableHit As String
strTableHit = "N"
For Index001 As Double = 0 To 9999
IntervalBreak(dblIntervalCount, _
dblIntervalTotal, _
Index1, Index2, Index3, dblArray)
If dblArray(Index001, 0) = 0 Then
dblArray(Index001, 0) = dblNumb1
dblArray(Index001, 1) = dblNumb2
dblArray(Index001, 2) = dblNumb3
dblArray(Index001, 3) = dblNumb4
Exit Sub
End If
If dblArray(Index001, 0) = dblNumb1 And _
dblArray(Index001, 1) = dblNumb2 And _
dblArray(Index001, 2) = dblNumb3 Then
strTableHit = "Y"
End If
If Index001 = 9999 Then
Console.WriteLine("Work table size exceeded....")
Console.WriteLine("Press Enter to stop execution")
End
End If
dblTab1 = dblArray(Index001, 0)
dblTab2 = dblArray(Index001, 1)
dblTab3 = dblArray(Index001, 2)
dblDiff1 = dblArray(Index001, 3)
If dblNumb4 = dblDiff1 Then
For Index002 As Double = 0 To 9999
dblTab4 = dblArray(Index002, 0)
dblTab5 = dblArray(Index002, 1)
dblTab6 = dblArray(Index002, 2)
dblDiff2 = dblArray(Index002, 3)
If dblTab4 = 0 Then
Exit For
End If
IntervalBreak(dblIntervalCount, _
dblIntervalTotal, Index1, Index2, Index3, _
dblArray)
If dblNumb4 = dblDiff2 Then
DisplayResults(dblNumb1, dblNumb2, dblNumb3, _
dblTab1, dblTab2, dblTab3, _
dblTab4, dblTab5, dblTab6)
End If
Next
End If
Next
End Sub

Sub IntervalBreak(ByRef dblIntervalcount, ByRef dblIntervalTotal, _
ByRef Index1, ByRef Index2, ByRef Index3, ByRef dblArray)
dblIntervalcount += 1
dblIntervalTotal += 1
If dblIntervalcount > 999999 Then
dblIntervalcount = 0
Console.WriteLine("" & _
"We have now completed " & _
Str(dblIntervalTotal) & " cycles")
Console.WriteLine("Indexes are: " & _
Str(Index1) & " " & Str(Index2) & " " & Str(Index3))
End If
End Sub

Sub DisplayResults(ByRef dblNumb1, ByRef dblNumb2, ByRef dblNumb3, _
ByRef dblTab1, ByRef dblTab2, ByRef dblTab3, _
ByRef dblTab4, ByRef dblTab5, ByRef dblTab6)
If (dblNumb1 = dblTab1) And _
(dblNumb2 = dblTab2) And _
(dblNumb3 = dblTab3) Then
Exit Sub
End If
If (dblNumb1 = dblTab4) And _
(dblNumb2 = dblTab5) And _
(dblNumb3 = dblTab6) Then
Exit Sub
End If
If (dblTab1 = dblTab4) And _
(dblTab2 = dblTab5) And _
(dblTab3 = dblTab6) Then
Exit Sub
End If
Console.WriteLine("Eureka !!")
Console.WriteLine("" & _
Str(dblNumb1) & " " & _
Str(dblNumb2) & " " & _
Str(dblNumb3))
Console.WriteLine("" & _
Str(dblTab1) & " " & _
Str(dblTab2) & " " & _
Str(dblTab3))
Console.WriteLine("" & _
Str(dblTab4) & " " & _
Str(dblTab5) & " " & _
Str(dblTab6))
Console.WriteLine("" & _
End Sub
End Module

Edited on May 4, 2004, 4:58 pm

Edited on May 4, 2004, 5:03 pm
 Posted by Penny on 2004-05-04 16:55:20

 Search: Search body:
Forums (0)