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

Home > Numbers
Pandigital Sum (Posted on 2006-09-19) Difficulty: 3 of 5
Find a 2-digit integer, a 3-digit integer and a 4-digit integer, such that:
  • among them contain all digits 1 - 9
  • each integer is divisible by each of its digits
  • the sum of the three integers is a 4-digit number that is also divisible by each of its digits, which are all different as well
  • See The Solution Submitted by Charlie    
    Rating: 5.0000 (1 votes)

    Comments: ( Back to comment list | You must be logged in to post comments.)
    re(2): Solution | Comment 3 of 5 |
    (In reply to re: Solution by bumble)

    RE: "If you didn't use a program then that's an impressive find! I would like to know the reasoning."

    I used an unimpressive program - hahaha. Reasoning it out would have been impressive.

    But alas, I used brute force.

    The prgram is pretty boring, not too sophisticated at all. It ran in about a second. Here it is:

    Visual Basic Program:

    Imports System
    Imports System.IO
    Imports System.Text
    Imports System.Runtime.InteropServices
    Imports System.Math
    Module Module1
        Dim digit0 As Integer
        Dim digit1 As Integer
        Dim digit2 As Integer
        Dim digit3 As Integer
        Dim digit4 As Integer
        Dim digit5 As Integer
        Dim digit6 As Integer
        Dim digit7 As Integer
        Dim digit8 As Integer
    Sub Main()
            Randomize()
            For digit0 = 1 To 9
                For digit1 = 1 To 9
                    If digit1 <> digit0 Then
                        For digit2 = 1 To 9
                            If digit2 <> digit0 And _
                            digit2 <> digit1 Then
                                For digit3 = 1 To 9
                                    If digit3 <> digit0 And _
                                    digit3 <> digit1 And _
                                    digit3 <> digit2 Then
                                        For digit4 = 1 To 9
                                            If digit4 <> digit0 And _
                                            digit4 <> digit1 And _
                                            digit4 <> digit2 And _
                                            digit4 <> digit3 Then
                                                For digit5 = 1 To 9
                                                    If digit5 <> digit0 And _
                                                    digit5 <> digit1 And _
                                                    digit5 <> digit2 And _
                                                    digit5 <> digit3 And _
                                                    digit5 <> digit4 Then
                                                        For digit6 = 1 To 9
                                                            If digit6 <> digit0 And _
                                                            digit6 <> digit1 And _
                                                            digit6 <> digit2 And _
                                                            digit6 <> digit3 And _
                                                            digit6 <> digit4 And _
                                                            digit6 <> digit5 Then
                                                                For digit7 = 1 To 9
                                                                    If digit7 <> digit0 And _
                                                                    digit7 <> digit1 And _
                                                                    digit7 <> digit2 And _
                                                                    digit7 <> digit3 And _
                                                                    digit7 <> digit4 And _
                                                                    digit7 <> digit5 And _
                                                                    digit7 <> digit6 Then
                                                                        For digit8 = 1 To 9
                                                                            If digit8 <> digit0 And _
                                                                            digit8 <> digit1 And _
                                                                            digit8 <> digit2 And _
                                                                            digit8 <> digit3 And _
                                                                            digit8 <> digit4 And _
                                                                            digit8 <> digit5 And _
                                                                            digit8 <> digit6 And _
                                                                            digit8 <> digit7 Then
                                                                                check_them_out()
                                                                            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
    End Sub
    Sub check_them_out()
            Dim work2 As Double
            Dim work3 As Double
            Dim work4 As Double
            Dim work5 As Double
            Dim work6 As Double
            Dim work7 As Double
            Dim work8 As String
            Dim work9(4) As Integer
            work2 = _
            (digit0 * (10 ^ 0)) + _
            (digit1 * (10 ^ 1))
            work3 = _
            (digit2 * (10 ^ 0)) + _
            (digit3 * (10 ^ 1)) + _
            (digit4 * (10 ^ 2))
            work4 = _
            (digit5 * (10 ^ 0)) + _
            (digit6 * (10 ^ 1)) + _
            (digit7 * (10 ^ 2)) + _
            (digit8 * (10 ^ 3))
            '
            work5 = work2 / digit0
            work6 = Fix(work2 / digit0)
            If work5 <> work6 Then
                Exit Sub
            End If
            work5 = work2 / digit1
            work6 = Fix(work2 / digit1)
            If work5 <> work6 Then
                Exit Sub
            End If
            work5 = work3 / digit2
            work6 = Fix(work3 / digit2)
            If work5 <> work6 Then
                Exit Sub
            End If
            work5 = work3 / digit3
            work6 = Fix(work3 / digit3)
            If work5 <> work6 Then
                Exit Sub
            End If
            work5 = work3 / digit4
            work6 = Fix(work3 / digit4)
            If work5 <> work6 Then
                Exit Sub
            End If
            work5 = work4 / digit5
            work6 = Fix(work4 / digit5)
            If work5 <> work6 Then
                Exit Sub
            End If
            work5 = work4 / digit6
            work6 = Fix(work4 / digit6)
            If work5 <> work6 Then
                Exit Sub
            End If
            work5 = work4 / digit7
            work6 = Fix(work4 / digit7)
            If work5 <> work6 Then
                Exit Sub
            End If
            work5 = work4 / digit8
            work6 = Fix(work4 / digit8)
            If work5 <> work6 Then
                Exit Sub
            End If
            work7 = work2 + work3 + work4
            If work7 < 1000 Or work7 > 9999 Then
                Exit Sub
            End If
            work8 = Str(work7)
            '
            ' Remove leading zero(s) from string:
            work8 = CStr(CInt(work8))
            '
            For index1 As Integer = 1 To Len(work8)
                work9(index1 - 1) = Int(Mid(work8, index1, 1))
                If work9(index1 - 1) = 0 Then
                    Exit Sub
                End If
            Next
            For index0 As Integer = 0 To 2
                For index1 As Integer = index0 + 1 To 3
                    If work9(index0) = work9(index1) Then
                        Exit Sub
                    End If
                Next
            Next
            For index0 As Integer = 0 To 3
                work5 = work7 / work9(index0)
                work6 = Fix(work7 / work9(index0))
                If work5 <> work6 Then
                    Exit Sub
                End If
            Next
            Console.WriteLine(" ")
            Console.WriteLine("Solution:")
            Console.WriteLine(work2 & " " & work3 & " " & work4)
            Console.WriteLine("Sum = " & work7)
    End Sub
    End Module

     

    Edited on September 19, 2006, 10:44 am
      Posted by Penny on 2006-09-19 10:15:26

    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 (23)
    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