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

Home > Numbers
Sums and Letters (Posted on 2005-04-27) Difficulty: 2 of 5
I wrote down five different two-digit numbers:

  • My age
  • My house number
  • The sum of those first two numbers
  • The difference between those first two numbers
  • Half of one of those first four numbers

I chose to write down the names of the numbers in letters rather than use digits (e.g. "thirty six").
Surprisingly, I noticed that each of the five numbers had the same number of letters in its name.

What were the last three numbers I wrote?

No Solution Yet Submitted by Sam    
Rating: 3.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re(4): No Subject - Correction | Comment 10 of 13 |
(In reply to re(3): No Subject - Correction by Kathy)

I fixed my program and got the same answer as the others before me had gotten.  I used VB.NET to solve it.  Here's my code:

Public Class Form1

Inherits System.Windows.Forms.Form

 

Private Nines() As String

Private Tens() As String

Private Elevens() As String

Private NinesList As New ArrayList

Private TensList As New ArrayList

Private ElevensList As New ArrayList

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.FillArrayLists()

lblSource.Text = Me.FindAnswer()

End Sub

Private Sub FillArrayLists()

Dim aString As String

Dim sString As String

sString = txtNines.Text

Nines = sString.Split(", ")

For Each aString In Nines

NinesList.Add(Convert.ToDecimal(aString))

Next

sString = txtTens.Text

Tens = sString.Split(", ")

For Each aString In Tens

TensList.Add(Convert.ToDecimal(aString))

Next

sString = txtElevens.Text

Elevens = sString.Split(", ")

For Each aString In Elevens

ElevensList.Add(Convert.ToDecimal(aString))

Next

End Sub

Private Function FindAnswer() As String

Dim i1 As Decimal

Dim i2 As Decimal

Dim Half As Decimal

For Each i1 In NinesList

For Each i2 In NinesList

If i2 > i1 Then

If NinesList.Contains(i1 + i2) And _

NinesList.Contains(i2 - i1) And _

(NinesList.Contains(i1 / 2) Or _

NinesList.Contains(i2 / 2) Or _

NinesList.Contains((i1 + i2) / 2) Or _

NinesList.Contains((i2 - i1) / 2)) Then

If NinesList.Contains(i1 / 2) Then

Half = i1 / 2

ElseIf NinesList.Contains(i2 / 2) Then

Half = i2 / 2

ElseIf NinesList.Contains((i1 + i2) / 2) Then

Half = (i1 + i2) / 2

ElseIf NinesList.Contains((i2 - i1) / 2) Then

Half = (i2 - i1) / 2

End If

Me.DisplayResults(i1, i2, i1 + i2, i2 - i1, Half)

Return "Nines List"

Exit Function

End If

End If

Next i2

Next i1

For Each i1 In TensList

For Each i2 In TensList

If i2 > i1 Then

If TensList.Contains(i1 + i2) And _

TensList.Contains(i2 - i1) And _

(TensList.Contains(i1 / 2) Or _

TensList.Contains(i2 / 2) Or _

TensList.Contains((i1 + i2) / 2) Or _

TensList.Contains((i2 - i1) / 2)) Then

If TensList.Contains(i1 / 2) Then

Half = i1 / 2

ElseIf TensList.Contains(i2 / 2) Then

Half = i2 / 2

ElseIf TensList.Contains((i1 + i2) / 2) Then

Half = (i1 + i2) / 2

ElseIf TensList.Contains((i2 = i1) / 2) Then

Half = (i2 - i1) / 2

End If

Me.DisplayResults(i1, i2, i1 + i2, i2 - i1, Half)

Return "Tens List"

Exit Function

End If

End If

Next i2

Next i1

For Each i1 In ElevensList

For Each i2 In ElevensList

If i2 > i1 Then

If ElevensList.Contains(i1 + i2) And _

ElevensList.Contains(i2 - i1) And _

(ElevensList.Contains(i1 / 2) Or _

ElevensList.Contains(i2 / 2) Or _

ElevensList.Contains((i1 + i2) / 2) Or _

ElevensList.Contains((i2 - i1) / 2)) Then

If ElevensList.Contains(i1 / 2) Then

Half = i1 / 2

ElseIf ElevensList.Contains(i2 / 2) Then

Half = i2 / 2

ElseIf ElevensList.Contains((i1 + i2) / 2) Then

Half = (i1 + i2) / 2

ElseIf ElevensList.Contains((i2 - i1) / 2) Then

Half = Half = (i2 - i1) / 2

End If

Me.DisplayResults(i1, i2, i1 + i2, i2 - i1, Half)

Return "Elevens List"

Exit Function

End If

End If

Next i2

Next i1

Return "Null"

End Function

Private Sub DisplayResults(ByVal Num1 As Integer, ByVal Num2 As Integer, ByVal Sum As Integer, ByVal Diff As Integer, ByVal Half As Integer)

lblNum1.Text = Num1.ToString

lblNum2.Text = Num2.ToString

lblSum.Text = Sum.ToString

lblDiff.Text = Diff.ToString

lblHalf.Text = Half.ToString

End Sub

End Class


  Posted by Kathy on 2005-04-28 00:27:21
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information