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

Home > Numbers
123456789 scrambled (Posted on 2015-03-19) Difficulty: 3 of 5
A^5+B^5+C^5+D^5+E^5=S

Given that the concatenation ABCDE digits is a 9-digit zero-less pandigital number
and so is the sum S - there is only one sum S to make the above equation true.

Find it.

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 6
DefDbl A-Z
Dim crlf$, used(9)


Private Sub Form_Load()
 ChDir "C:\VB5 projects\flooble"
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
  
 Open "1-9scram.txt" For Output As #2
 For a1 = 1 To 5
  used(a1) = 1
  a$ = LTrim(Str(a1))
  For b1 = a1 + 1 To 6
   b$ = LTrim(Str(b1))
   used(b1) = 1
  For c1 = b1 + 1 To 7
   c$ = LTrim(Str(c1))
   used(c1) = 1
  For d1 = c1 + 1 To 8
   d$ = LTrim(Str(d1))
   used(d1) = 1
  For e1 = d1 + 1 To 9
   e$ = LTrim(Str(e1))
   used(e1) = 1
    r$ = ""
    For i = 1 To 9
      If used(i) = 0 Then
        r$ = r$ + Str$(i) ' adds a space and a digit as a string
      End If
    Next
    h$ = r$
    Do
     pix = 0: prt = 1: ix = 0
     pix = ix + 1
     ix = InStr(pix, r, " "): If ix = 0 Then ix = Len(r) + 1
     aval = Val(a$ + Mid(r, pix, ix - pix))
     
     pix = ix + 1
     ix = InStr(pix, r, " "): If ix = 0 Then ix = Len(r) + 1
     bval = Val(b$ + Mid(r, pix, ix - pix))
     
     pix = ix + 1
     ix = InStr(pix, r, " "): If ix = 0 Then ix = Len(r) + 1
     cval = Val(c$ + Mid(r, pix, ix - pix))
     
     pix = ix + 1
     ix = InStr(pix, r, " "): If ix = 0 Then ix = Len(r) + 1
     dval = Val(d$ + Mid(r, pix, ix - pix))
     
     pix = ix + 1
     ix = InStr(pix, r, " "): If ix = 0 Then ix = Len(r) + 1
     eval = Val(e$ + Mid(r, pix, ix - pix))
     
     Print #2, aval
     Print #2, bval
     Print #2, cval
     Print #2, dval
     Print #2, eval
     
     permute r$
    Loop Until r$ = h$
    
   used(e1) = 0
  Next
   used(d1) = 0
  Next
   used(c1) = 0
  Next
   used(b1) = 0
  Next
  used(a1) = 0
 Next
 Close 2

Text1.Text = Text1.Text & "done"
End Sub


was used to find all possible arrangements of the digits 1 throught 9 into 5 groups with at least one digit in each group. The groups are arranged in lexicographic order so that a number beginning with a 1 would appear before any beginning with any other digit; those beginning with 2 would appear before any beginning with any higher digit, etc.

It creates a file that feeds into a UBASIC program which does the raising to powers and addition, and compares the sum to see if it is a 9-digit pandigital with no zeros.

The file that feeds into the UBASIC program starts:

 1 
 26 
 37 
 48 
 59 
 1 
 26 
 37 
 489 
 5 
 1 
 26 
 37 
 49 
 58 
 1 
 26 
 37 
 498 
 5 
 1 
 26 
 378 
 4 
 59 
 1 
 26 
 378 
 49 
 5 
 1 
 26 
 3789 
 4 
 5 
 1 
 26 
 379 
 4 
 58 
 1 
 26 
 379 
 48 
 5 
 1 
 26 
 3798 
 4 
 5 
 1 
 26 
 38 
 4 
 579 
 1 
 26 
 38 
 4 
 597 
 1 
 26 
 38 
 47 
 59 
 1 
 26 
 38 
 479 
 5 
 1 
 26 
 38 
 49 
 57 
 1 
 26 
 38 
 497 
 5 
 1 
 26 
 387 
 4 
 59 
 1 
 26 
 387 
 49 
 5 
 1 
 26 
 3879 
 4 
 5 
 1 
 26 
 389 
 4 
 57 
 1 
 26 
 389 
 47 
 5 
 1 
 26 
 3897 
 4 
 5 
 1 
 26 
 39 
 4 
 578 
 1 
 26 
 39 
 4 
 587 
 1 
 26 
 39 
 47 
 58 
 1 
 26 
 39 
 478 
 5 
 1 
 26 
 39 
 48 
 57 
 1 
 26 
 39 
 487 
 5 
 1 
 26 
 397 
 4 
 58 
 1 
 26 
 397 
 48 
 5 
 1 
 26 
 3978 
 4 
 5 
 1 
 26 
 398 
 4 
 57 
 1 
 26 
 398 
 47 
 5 
 1 
 26 
 3987 
 4 
 5 
 1 
 267 
 3 
 4 
 589 
 1 
 267 
 3 
 4 
 598 
 1 
 267 
 3 
 48 
 59 
 1 
 267 
 3 
 489 
 5 
 1 
 267 
 3 
 49 
 58 
 1 
 267 
 3 
 498 
 5 
 1 
 267 
 38 
 4 
 59 
 1 
 267 
 38 
 49 
 5 
 1 
 267 
 389 
 4 
 5 
 1 
 267 
 39 
 4 
 58 
 
 ...

and ends

...
 5 
 61 
 7 
 8423 
 9 
 5 
 61 
 7 
 843 
 92 
 5 
 61 
 7 
 8432 
 9 
 5 
 61 
 72 
 8 
 934 
 5 
 61 
 72 
 8 
 943 
 
 They are grouped by 5 as every set has 5 numbers. The lowest comes first, so the highest low digit is 5.
 
 The UBASIC program that reads the file and produces the result is:
 
    10   open "1-9scram.txt" for input as #1
    20   repeat
    30     input #1,A,B,C,D,E
    35     a=val(a):b=val(b):c=val(c):d=val(d):e=val(e) 
    40     v=cutspc(str(a^5+b^5+c^5+d^5+e^5))
    50     if len(v)=9 then
    60       :good=1
    70       :for i=1 to 8
    80         :if instr(i+1,v,mid(v,i,1)) > 0 then good=0:cancel for:goto 200:endif
    90       :next i
   100       :if instr(v,"0")>0 then good=0:endif
   110       :if good then
   120          :print a,b,c,d,e,v
   200      rem             
   240   until eof(1)
   250   close

and it finds

17   26   43   58   9      816725493

meaning 17^5 + 26^5 + 43^5 + 58^5 + 9^5  =  816725493.

Of course permutations of A, B, C, D and E will work also.

  Posted by Charlie on 2015-03-19 15:29:27
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