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

Home > Numbers
3x3 sums (Posted on 2004-05-15) Difficulty: 3 of 5
Fill a 3 by 3 grid with the digits 1 to 9 using the following five rules:

1. The sum of the top row is twice the sum of the center row.

2. The sum of the left column is twice the sum of the center column.

3. The sum of the right column plus twice the sum of the bottom row is equal to the sum of the whole grid.

4. The sum of the bottom row plus twice the sum of the right column is not equal to the sum of the whole grid.

5. The top row is the only row with both odd and even numbers.

Show that there is only one solution.

See The Solution Submitted by Axorion    
Rating: 3.0000 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 1 of 11
The only possible grid is:
 
9 5 8
3 1 7
4 2 6
 
Here is the Visual Basic Console Application Program that proved this. It ran in 6 seconds wall clock time !!!!
 
Imports System
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
    Sub Main()
        Randomize()
        Dim strEndFlag As String
        Dim dblIntervalTotal As Double
        Dim dblIntervalCount As Double
        Console.WriteLine("Beginning program execution at: " & _
        TimeOfDay)
        Console.WriteLine(" ")
        dblIntervalCount = 0
        dblIntervalTotal = 0
        For Index1 As Integer = 1 To 9
            For Index2 As Integer = 1 To 9
                If Index1 <> Index2 Then
                    For Index3 As Integer = 1 To 9
                        If Index3 <> Index1 _
                        And Index3 <> Index2 Then
                            For Index4 As Integer = 1 To 9
                                If Index4 <> Index1 And _
                                Index4 <> Index2 And _
                                Index4 <> Index3 Then
                                    For Index5 As Integer = 1 To 9
                                        If Index5 <> Index1 And _
                                        Index5 <> Index2 And _
                                        Index5 <> Index3 And _
                                        Index5 <> Index4 Then
                                            For Index6 As Integer = 1 To 9
                                                If Index6 <> Index1 And _
                                                Index6 <> Index2 And _
                                                Index6 <> Index3 And _
                                                Index6 <> Index4 And _
                                                Index6 <> Index5 Then
                                                    For Index7 As Integer = 1 To 9
                                                        If Index7 <> Index1 And _
                                                        Index7 <> Index2 And _
                                                        Index7 <> Index3 And _
                                                        Index7 <> Index4 And _
                                                        Index7 <> Index5 And _
                                                        Index7 <> Index6 Then
                                                            For Index8 As Integer = 1 To 9
                                                                If Index8 <> Index1 And _
                                                                Index8 <> Index2 And _
                                                                Index8 <> Index3 And _
                                                                Index8 <> Index4 And _
                                                                Index8 <> Index5 And _
                                                                Index8 <> Index6 And _
                                                                Index8 <> Index7 Then
                                                                    For Index9 As Integer = 1 To 9
                                                                        If Index9 <> Index1 And _
                                                                        Index9 <> Index2 And _
                                                                        Index9 <> Index3 And _
                                                                        Index9 <> Index4 And _
                                                                        Index9 <> Index5 And _
                                                                        Index9 <> Index6 And _
                                                                        Index9 <> Index7 And _
                                                                        Index9 <> Index8 Then
                                                                            EvaluateGrid( _
                                                                            Index1, _
                                                                            Index2, _
                                                                            Index3, _
                                                                            Index4, _
                                                                            Index5, _
                                                                            Index6, _
                                                                            Index7, _
                                                                            Index8, _
                                                                            Index9, _
                                                                            dblIntervalCount, _
                                                                            dblIntervalTotal)
                                                                        End If
                                                                    Next
                                                                End If
                                                            Next
                                                        End If
                                                    Next
                                                End If
                                            Next
                                        End If
                                    Next
                                End If
                            Next
                        End If
                    Next
                End If
            Next
        Next
        Console.WriteLine(" ")
        Console.WriteLine("We have evaluated " _
            & Str(dblIntervalTotal) & " total combinations")
        Console.WriteLine("Search complete...")
        Console.WriteLine(" ")
        Console.WriteLine("Ending program execution at: " & _
        TimeOfDay)
        Console.WriteLine(" ")
        strEndFlag = "?"
        While strEndFlag <> "X"
            Console.WriteLine("Please enter X to exit program")
            strEndFlag = UCase(Console.ReadLine())
        End While
    End Sub
     
    Sub EvaluateGrid(ByRef Index1, ByRef Index2, _
    ByRef Index3, ByRef Index4, ByRef Index5, _
    ByRef Index6, ByRef Index7, ByRef Index8, ByRef Index9, _
    ByRef dblIntervalCount, ByRef dblIntervalTotal)
        Dim intWorkarea1 As Integer
        Dim intWorkarea2 As Integer
        Dim intRow1Odds As Integer
        Dim intRow1Evens As Integer
        Dim intRow2Odds As Integer
        Dim intRow2Evens As Integer
        Dim intRow3Odds As Integer
        Dim intRow3Evens As Integer
        intRow1Odds = 0
        intRow1Evens = 0
        intRow2Odds = 0
        intRow2Evens = 0
        intRow3Odds = 0
        intRow3Evens = 0
        dblIntervalCount += 1
        dblIntervalTotal += 1
        If dblIntervalCount >= 99999 Then
            dblIntervalCount = 0
            Console.WriteLine("We have now on processing cycle " _
            & Str(dblIntervalTotal))
        End If
        If Index1 Mod 2 = 0 Then
            intRow1Evens += 1
        Else
            intRow1Odds += 1
        End If
        If Index2 Mod 2 = 0 Then
            intRow1Evens += 1
        Else
            intRow1Odds += 1
        End If
        If Index3 Mod 2 = 0 Then
            intRow1Evens += 1
        Else
            intRow1Odds += 1
        End If
        If Index4 Mod 2 = 0 Then
            intRow2Evens += 1
        Else
            intRow2Odds += 1
        End If
        If Index5 Mod 2 = 0 Then
            intRow2Evens += 1
        Else
            intRow2Odds += 1
        End If
        If Index6 Mod 2 = 0 Then
            intRow2Evens += 1
        Else
            intRow2Odds += 1
        End If
        If Index7 Mod 2 = 0 Then
            intRow3Evens += 1
        Else
            intRow3Odds += 1
        End If
        If Index8 Mod 2 = 0 Then
            intRow3Evens += 1
        Else
            intRow3Odds += 1
        End If
        If Index9 Mod 2 = 0 Then
            intRow3Evens += 1
        Else
            intRow3Odds += 1
        End If
        intWorkarea1 = Index1 + Index2 + Index3
        intWorkarea2 = 2 * (Index4 + Index5 + Index6)
        If intWorkarea1 <> intWorkarea2 Then
            Exit Sub
        End If
        intWorkarea1 = Index1 + Index4 + Index7
        intWorkarea2 = 2 * (Index2 + Index5 + Index8)
        If intWorkarea1 <> intWorkarea2 Then
            Exit Sub
        End If
        intWorkarea1 = Index3 + Index6 + +Index9 + _
        2 * (Index7 + Index8 + Index9)
        intWorkarea2 = Index1 + Index2 + Index3 + Index4 + Index5 _
        + Index6 + Index7 + Index8 + Index9
        If intWorkarea1 <> intWorkarea2 Then
            Exit Sub
        End If
        intWorkarea1 = Index7 + Index8 + Index9 _
        + 2 * (Index3 + Index6 + Index9)
        If intWorkarea1 = intWorkarea2 Then
            Exit Sub
        End If
        If intRow1Odds = 0 Or intRow1Evens = 0 Then
            Exit Sub
        End If
        If intRow2Odds <> 0 And intRow2Evens <> 0 Then
            Exit Sub
        End If
        If intRow3Odds <> 0 And intRow3Evens <> 0 Then
            Exit Sub
        End If
        Console.WriteLine("Here is a good grid:")
        Console.WriteLine(" ")
        Console.WriteLine(Str(Index1) & " " & Str(Index2) & " " & Str(Index3))
        Console.WriteLine(Str(Index4) & " " & Str(Index5) & " " & Str(Index6))
        Console.WriteLine(Str(Index7) & " " & Str(Index8) & " " & Str(Index9))
        Console.WriteLine(" ")
        Console.WriteLine("Please press ENTER to continue search...")
        Console.ReadLine()
    End Sub
End Module
 
 

 

Edited on May 15, 2004, 1:14 pm
  Posted by Penny on 2004-05-15 12:43:02

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


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

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