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

Home > Numbers
From pie to numbers (Posted on 2015-12-27) Difficulty: 3 of 5
Let us use the first 3 digits of PI, i.e. 3,1,4 to create numbers from 1 to 50, using only basic math. operators.
Not all the digits must be used, but none can be repeated.

Examples (out of this range): 52= 13*4; 65=4^3+1; 84=14*3!

Only few numbers cannot be achieved.

Please show your list.

No Solution Yet Submitted by Ady TZIDON    
Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 16 |
The lowest number not found was 32; the others were 39, 45, 46, 49 and 50.

Only the first 25 found for each result were reported by the program, and these are not necessarily the simplest for those numbers with over 25 solutions. I've translated from the RPN (Reverse Polish Notation) output by the program to algebraic form, for one of each of the desired results, choosing one of the simpler cases shown.


  1    1,3!,4!/^
  1    1,3!,4-^
  1    1,3!,4/^
  1    1,3!^
  1    1,3!^,4^
  1    1,3+!,4!-!
  1    1,3+!,4!/
  1    1,3+,4-!
  1    1,3+,4/
  1    1,3,4!/^
  1    1,3,4+^
  1    1,3,4-+!
  1    1,3,4/^
  1    1,3^                1^3=1
  1    1,3^,4^
  1    1,4*,3-
  1    1,4,3!!/^
  1    1,4,3!/^
  1    1,4,3+^
  1    1,4,3-*
  1    1,4,3--!
  1    1,4,3-/
  1    1,4,3-^
  1    1,4,3/^
  1    1,4-,3+!
  2    1,3!*,4-
  2    1,3!,4-*
  2    1,3*!,4-
  2    1,3,4--
  2    1,3-,4+
  2    1,4+,3-
  2    1,4,3-+
  2    3!,1*,4-
  2    3!,1,4*-
  2    3!,1/,4-
  2    3!,1^,4-
  2    3!,4,1*-
  2    3!,4,1-/
  2    3!,4,1/-
  2    3!,4,1^-
  2    3!,4-
  2    3!,4-,1*
  2    3!,4-,1/
  2    3!,4-,1^
  2    3,1*!,4-
  2    3,1,4^-
  2    3,1-                3-1=2
  2    3,1/!,4-
  2    3,1^!,4-
  2    4,1+,3-
  3    1,3!+,4-
  3    1,3!,4-+            1*3=3
  3    1,3*
  3    1,4,3!--
  3    1,4-,3!+
  3    1,4^,3*
  3    3!,1+,4-
  3    3!,1,4-+
  3    3!,4,1--
  3    3!,4-,1+
  3    3,1*                3*1=3
  3    3,1,4^*
  3    3,1,4^/
  3    3,1,4^^
  3    3,1/
  3    3,1^
  3    4!,3!/,1-
  3    4,1,3!^-
  3    4,1,3^-
  3    4,1-
  3    4,1-!,3-
  4    1,3!,4!//
  4    1,3!/,4!*
  4    1,3!^,4*
  4    1,3+
  4    1,3^,4*
  4    1,4!*,3!/
  4    1,4!,3!/*
  4    1,4*
  4    1,4*!,3!/
  4    1,4^,3+
  4    3,1+
  4    3,1,4^+
  4    4!,1*,3!/
  4    4,1*                4*1=4
  4    4,1*!,3!/
  4    4,1,3!^*
  4    4,1,3!^/
  4    4,1,3!^^
  4    4,1,3^*
  4    4,1,3^/
  4    4,1,3^^
  4    4,1/
  4    4,1/!,3!/
  4    4,1^
  4    4,1^!,3!/
  5    1,3!^,4+
  5    1,3^,4+
  5    1,4!,3!/+
  5    1,4+
  5    3!,1,4^-
  5    3!,1-
  5    3!,1-!,4!/
  5    4!,3!/,1+
  5    4,1+                4+1=5
  5    4,1,3!^+
  5    4,1,3^+
  6    1,3!*
  6    1,3!+,4-!
  6    1,3!,4-+!
  6    1,3*!
  6    1,3+!,4/
  6    1,4,3!--!
  6    1,4-,3!+!   <-----  rather weird, deserving of note:
  6    1,4^,3!*                 ((1-4) + 3!)!   
  6    1,4^,3*!
  6    3!                  3!=6
  6    3!,1*
  6    3!,1+,4-!
  6    3!,1,4-+!
  6    3!,1,4^*
  6    3!,1,4^/
  6    3!,1/
  6    3,1*!
  6    3,1+!,4/
  6    3,1,4--
  6    3,1,4^*!
  6    3,1,4^/!
  6    3,1,4^^!
  6    3,1-,4+
  6    3,1/!
  6    3,1^!
  7    1,3!+
  7    1,3*,4+
  7    1,3,4+*
  7    1,4*,3+
  7    1,4,3+*
  7    1,4^,3!+
  7    3!,1+
  7    3!,1,4^+
  7    3,1*,4+
  7    3,1,4*+
  7    3,1/,4+
  7    3,1^,4+
  7    3,4+                3+4=7
  7    3,4+,1*
  7    3,4+,1/
  7    3,4+,1^
  7    3,4,1*+
  7    3,4,1/+
  7    3,4,1^+
  7    31,4!-
  7    4,1*,3+
  7    4,1,3*+
  7    4,1/,3+
  7    4,1^,3+
  7    4,3+
  8    1,3+,4+             1+3+4=8
  8    1,3,4!//
  8    1,3,4++
  8    1,3/,4!*
  8    1,4!*,3/
  8    1,4!,3/*
  8    1,4*!,3/
  8    1,4+,3+
  8    1,4,3++
  8    14,3!-
  8    3,1+,4+
  8    3,1,4++
  8    3,1-,4*
  8    3,4+,1+
  8    3,4,1++
  8    4!,1*,3/
  8    4!,1,3*/
  8    4!,1,3/*
  8    4!,1/,3/
  8    4!,1^,3/
  8    4,1*!,3/
  8    4,1+,3+
  8    4,1,3++
  8    4,1/!,3/
  8    4,1^!,3/
  9    1,4!,3/+
  9    13,4-               13-4=9
  9    3!,1,4--
  9    3!,1-,4+
  9    3!,4+,1-
  9    3!,4,1-+
  9    3,4,1-!+
  9    3,4,1-*
  9    4!,3/,1+
  9    4,1,3!--
  9    4,1-!,3+
  9    4,1-,3!+
  9    4,1-,3*
  9    4,3!+,1-
  9    4,3!,1-+
 10    1,3!*,4+
 10    1,3!,4+*
 10    1,3*!,4+
 10    1,4*,3!+
 10    1,4,3!+*
 10    3!,1*,4+
 10    3!,1,4*+
 10    3!,1/,4+
 10    3!,1^,4+
 10    3!,4+               3!+4=10
 10    3!,4+,1*
 10    3!,4+,1/
 10    3!,4+,1^
 10    3!,4,1*+
 10    3!,4,1/+
 10    3!,4,1^+
 10    3,1*!,4+
 10    3,1/!,4+
 10    3,1^!,4+
 10    4,1*,3!+
 10    4,1,3!*+
 10    4,1,3*!+
 10    4,1/,3!+
 10    4,1^,3!+
 10    4,3,1*!+
 11    1,3!+,4+
 11    1,3!,4++
 11    1,4+,3!+
 11    1,4,3!++
 11    14,3-               14-3=11
 11    3!,1+,4+
 11    3!,1,4++
 11    3!,4+,1+
 11    3!,4,1++
 11    3,4*,1-
 11    4!,13-
 11    4,1+,3!+
 11    4,1,3!++
 11    4,3!+,1+
 11    4,3!,1++
 11    4,3*,1-
 12    1,3*,4*
 12    1,3,4**
 12    1,4*,3*
 12    1,4,3**
 12    3!,4,1-!+
 12    3,1*,4*
 12    3,1,4**
 12    3,1,4//
 12    3,1/,4*
 12    3,1^,4*
 12    3,4*                3*4=12
 12    3,4*,1*
 12    3,4*,1/
 12    3,4*,1^
 12    3,4,1**
 12    3,4,1/*
 12    3,4,1^*
 12    4,1*,3*
 12    4,1,3**
 12    4,1,3//
 12    4,1-!,3!+
 12    4,1/,3*
 12    4,1^,3*
 12    4,3*
 12    4,3*,1*
 13    1,3,4*+             1+3*4=13
 13    1,4,3*+
 13    13
 13    3,4*,1+
 13    4,3*,1+
 14    14                  14
 15    1,4+,3*
 15    3,1,4+*             3*(1+4)=15
 15    3,4,1+*
 15    4,1+,3*
 16    1,3+,4*             (1+3)*4=16
 16    1,3-,4^
 16    3,1+,4*
 16    3,1-,4^
 16    4,1,3+*
 16    4,3,1+*
 16    4,3,1-^
 17    13,4+               13+4=17
 17    14,3+
 17    3,14+
 17    4!,1,3!+-
 17    4!,1-,3!-
 17    4!,3!,1+-
 17    4!,3!-,1-
 17    4,13+
 18    1,4!*,3!-
 18    1,4!,3!-*
 18    1,4*!,3!-
 18    3!,4,1-*
 18    3,4,1-!*
 18    4!,1*,3!-
 18    4!,1,3!*-
 18    4!,1,3*!-
 18    4!,1/,3!-
 18    4!,1^,3!-
 18    4!,3!,1*-
 18    4!,3!,1/-
 18    4!,3!,1^-
 18    4!,3!-              4!-3!=18
 18    4!,3!-,1*
 18    4!,3!-,1/
 18    4!,3!-,1^
 18    4!,3,1*!-
 18    4!,3,1/!-
 18    4!,3,1^!-
 18    4,1*!,3!-
 18    4,1-!,3*
 18    4,1-,3!*
 18    4,1/!,3!-
 18    4,1^!,3!-
 19    1,3!,4!--
 19    1,3!-,4!+
 19    1,4!+,3!-
 19    1,4!,3!-+
 19    4!,1+,3!-
 19    4!,1,3!-+
 19    4!,3!,1--
 19    4!,3!-,1+           4!-3!+1=19
 20    1,3+!,4-
 20    1,4+!,3!/
 20    14,3!+
 20    3!,1-,4*
 20    3!,14+              3!+14=20
 20    3,1+!,4-
 20    4!,1,3+-
 20    4!,1-,3-
 20    4!,3,1+-
 20    4!,3-,1-
 20    4,1+!,3!/
 20    4,3!,1-*
 21    1,4!*,3-
 21    1,4!,3-*
 21    1,4*!,3-
 21    4!,1*,3-
 21    4!,1,3*-
 21    4!,1/,3-
 21    4!,1^,3-
 21    4!,3,1*-
 21    4!,3,1/-
 21    4!,3,1^-
 21    4!,3-               4!-3=21
 21    4!,3-,1*
 21    4!,3-,1/
 21    4!,3-,1^
 21    4,1*!,3-
 21    4,1/!,3-
 21    4,1^!,3-
 22    1,3,4!--
 22    1,3-,4!+
 22    1,4!+,3-
 22    1,4!,3-+
 22    4!,1+,3-
 22    4!,1,3-+
 22    4!,3,1--
 22    4!,3-,1+            4!-3+1=22
 23    3!,4*,1-
 23    4!,1,3!^-
 23    4!,1,3^-
 23    4!,1-
 23    4!,3!/!,1-
 23    4,3!*,1-
 24    1,3!*,4*
 24    1,3!,4!//!
 24    1,3!,4**
 24    1,3!/,4!*!
 24    1,3!^,4!*
 24    1,3!^,4*!
 24    1,3*!,4*
 24    1,3+!               (1+3)!=24 but cut off sol'n 4! would be simpler
 24    1,3^,4!*
 24    1,3^,4*!
 24    1,4!*
 24    1,4!*,3!/!
 24    1,4!,3!/!*
 24    1,4!,3!/*!
 24    1,4*!               -- close, at (1*4)!
 24    1,4*!,3!/!
 24    1,4*,3!*
 24    1,4,3!**
 24    1,4^,3+!
 24    3!,1*,4*
 24    3,1*!,4*
 24    3,1+!
 24    3,1,4^+!
 24    3,1/!,4*
 24    3,1^!,4*
 25    1,3!,4*+
 25    1,3!^,4!+
 25    1,3^,4!+
 25    1,4!+               1+4!=25
 25    1,4!,3!/!+
 25    1,4,3!*+
 25    3!,4*,1+
 25    4!,1+
 25    4!,1,3!^+
 25    4!,1,3^+
 25    4!,3!/!,1+
 25    4,3!*,1+
 26    3,1,4!--
 26    3,1-,4!+
 26    3,4!+,1-
 26    3,4!,1-+
 26    4!,1,3--
 26    4!,1-,3+
 26    4!,3+,1-            4!+3-1=26
 26    4!,3,1-+
 27    1,3*,4!+
 27    1,3,4!+*
 27    1,4!*,3+
 27    1,4!,3+*
 27    1,4*!,3+
 27    3,1*,4!+
 27    3,1,4!*+
 27    3,1,4*!+
 27    3,1/,4!+
 27    3,1^,4!+
 27    3,4!+
 27    3,4!+,1*
 27    3,4!+,1/
 27    3,4!+,1^
 27    3,4!,1*+
 27    3,4!,1/+
 27    3,4!,1^+
 27    3,4,1*!+
 27    3,4,1-^             3^(4-1)=27
 27    3,4,1/!+
 27    3,4,1^!+
 27    31,4-
 27    4,1*!,3+
 27    4,1-,3^
 27    4,1/!,3+
 28    1,3!+,4*
 28    1,3+!,4+
 28    1,3+,4!+
 28    1,3,4!++
 28    1,4!+,3+
 28    1,4!,3++
 28    3!,1+,4*
 28    3,1+!,4+
 28    3,1+,4!+
 28    3,1,4!++
 28    3,4!+,1+
 28    3,4!,1++
 28    4!,1+,3+            4!+1+3=28
 28    4!,1,3++
 28    4!,3+,1+
 28    4!,3,1++
 28    4,1,3!+*
 28    4,1,3+!+
 28    4,3!,1+*
 28    4,3,1+!+
 29    3!!,4!/,1-         Interesting: (3!)!/4! - 1
 29    3!,1,4!--
 29    3!,1-,4!+
 29    3!,4!+,1-
 29    3!,4!,1-+
 29    4!,1,3!--
 29    4!,1-,3!+
 29    4!,3!+,1-
 29    4!,3!,1-+           4!+(3!-1)=29
 30    1,3!!*,4!/
 30    1,3!!,4!/*
 30    1,3!*!,4!/
 30    1,3!*,4!+
 30    1,3!,4!+*
 30    1,3*!!,4!/
 30    1,3*!,4!+
 30    1,4!*,3!+
 30    1,4!,3!!//
 30    1,4!,3!+*
 30    1,4!/,3!!*
 30    1,4*!,3!+
 30    1,4+,3!*            (1+4)*3!=30
 30    3!,1*!,4!/
 30    3!,1*,4!+
 30    3!,1,4+*
 30    3!,1-!,4/
 30    3!,1/!,4!/
 30    3!,1/,4!+
 30    3,1*!!,4!/
 30    3,1*!,4!+
 30    3,1/!!,4!/
 30    3,1/!,4!+
 30    3,1^!!,4!/
 30    3,1^!,4!+
 31    1,3!!,4!/+
 31    1,3!+,4!+
 31    1,3!,4!++
 31    1,4!+,3!+
 31    1,4!,3!++
 31    3!!,4!/,1+
 31    3!,1+,4!+
 31    3!,1,4!++
 31    3!,4!+,1+           3!+4!+1=31
 31    3!,4!,1++
 31    31
 31    4!,1+,3!+
 31    4!,1,3!++
 31    4!,3!+,1+
 31    4!,3!,1++
  
 33    34,1-               34-1=33
 34    1,34*               34*1=34
 34    34
 34    34,1*
 34    34,1/
 34    34,1^
 35    1,34+               1+34=35
 35    31,4+
 35    34,1+
 35    4,31+
 35    41,3!-
 36    3!,4,1-!*           3!*(4-1)!=36
 36    4,1-!,3!*
 37    13,4!+              13+4!=37
 37    4!,13+
 38    41,3-               41-3=38
  
 40    1,4+!,3/            (1+4)!/3=40
 40    4,1+!,3/
 41    41                  41
 42    14,3*               14*3=42
 42    3,14*
 42    43,1-
 43    1,43*
 43    43                  43
 43    43,1*
 43    43,1/
 43    43,1^
 44    1,43+               1+43=44
 44    3,41+
 44    41,3+
 44    43,1+
  
  
 47    3!,41+              3!+41=47
 47    41,3!+
 48    1,3+!,4!+           (1+3)!+4!=48
 48    3,1+!,4!+
 48    3,1-,4!*
 48    4!,1,3+!+
 48    4!,3,1+!+
 48    4!,3,1-*


The above is the sorted and annotated output from:


DefDbl A-Z
Dim crlf$, stack(10), concatable(4), fact(10), solCt(50)
Dim stackPtr, wh, pz As String, expstr As String, lvl

Private Sub Form_Load()
 Form1.Visible = True
 
 pz0 = "134"
 
 f = 1: fact(0) = f
 For i = 1 To 10
   f = f * i
   fact(i) = f
 Next
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 

   pz = pz0
   Text1.Text = Text1.Text & pz & crlf
   h$ = pz
   Do
     stackPtr = 1
     stack(1) = Val(Left(pz, 1)): concatable(1) = 1
     expstr = LTrim(Str(stack(1)))
     wh = 2
     addOn
    
     
     permute pz
   Loop Until pz = h
 
 

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

Sub addOn()
 ReDim sstack(4)
 ReDim sconcatable(4)
 
 DoEvents
        For typ = 0 To 7
   sstackPtr = stackPtr
   sexpstr$ = expstr
   For i = 1 To stackPtr
     sstack(i) = stack(i)
     sconcatable(i) = concatable(i)
     swh = wh
   Next
          good = 1
          Select Case typ
            Case 0 ' concatenate
              If concatable(stackPtr) And wh < 4 Then
                stack(stackPtr) = 10 * stack(stackPtr) + Val(Mid(pz, wh, 1))
                expstr = expstr + Mid(pz, wh, 1)
                wh = wh + 1
              Else
                good = 0
              End If
            Case 1  ' add (+)
              If stackPtr > 1 Then
                stackPtr = stackPtr - 1
                stack(stackPtr) = stack(stackPtr) + stack(stackPtr + 1)
                expstr = expstr + "+"
                concatable(stackPtr) = 0
              Else
                good = 0
              End If
             
             Case 2   ' subtract (-)
              If stackPtr > 1 Then
                stackPtr = stackPtr - 1
                stack(stackPtr) = stack(stackPtr) - stack(stackPtr + 1)
                expstr = expstr + "-"
                concatable(stackPtr) = 0
              Else
                good = 0
              End If
            Case 3  ' multiply (*)
              If stackPtr > 1 Then
                stackPtr = stackPtr - 1
                stack(stackPtr) = stack(stackPtr) * stack(stackPtr + 1)
                expstr = expstr + "*"
                concatable(stackPtr) = 0
              Else
                good = 0
              End If
            Case 4  ' divide (/)
              If stackPtr > 1 And stack(stackPtr) <> 0 Then
                stackPtr = stackPtr - 1
                stack(stackPtr) = stack(stackPtr) / stack(stackPtr + 1)
                expstr = expstr + "/"
                concatable(stackPtr) = 0
              Else
                good = 0
              End If
            Case 5   ' comma
              If wh < 4 Then
                stackPtr = stackPtr + 1
                stack(stackPtr) = Val(Mid(pz, wh, 1))
                concatable(stackPtr) = 1
                expstr = expstr + "," + Mid(pz, wh, 1)
                wh = wh + 1
              Else
                good = 0
              End If
            Case 6  ' power (^)
              If stackPtr > 1 Then
               If stack(stackPtr - 1) <> 0 And stack(stackPtr - 1) < 1000 And stack(stackPtr) >= 0 And stack(stackPtr) < 10 And (stack(stackPtr - 1) > 0 Or stack(stackPtr) = Int(stack(stackPtr))) Then
                stackPtr = stackPtr - 1
                stack(stackPtr) = stack(stackPtr) ^ stack(stackPtr + 1)
                expstr = expstr + "^"
                concatable(stackPtr) = 0
               Else
                 good = 0
               End If
              Else
                good = 0
              End If
            Case 7  ' factorial
              If stack(stackPtr) = Int(stack(stackPtr)) And stack(stackPtr) <= 10 And stack(stackPtr) >= 0 And stack(stackPtr) <> 1 And stack(stackPtr) <> 2 Then
                stack(stackPtr) = fact(stack(stackPtr))
                expstr = expstr + "!"
                concatable(stackPtr) = 0
               Else
                good = 0
              End If
         End Select
          If good Then
            If stackPtr = 1 Then
            
              If stack(stackPtr) <= 50 And stack(stackPtr) > 0 And stack(stackPtr) = Int(stack(stackPtr)) Then
                solCt(stack(stackPtr)) = solCt(stack(stackPtr)) + 1
                If solCt(stack(stackPtr)) < 26 Then
                  Text1.Text = Text1.Text & mform(stack(stackPtr), "##0") & "    " & expstr & crlf
                End If
              End If
            End If
            addOn
          End If
   wh = swh
   expstr = sexpstr
   stackPtr = sstackPtr
   For i = 1 To stackPtr
     stack(i) = sstack(i)
     concatable(i) = sconcatable(i)
   Next
   
     
        Next typ

End Sub

Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function


This was a fairly easy modification from the program to solve the puzzle called 80.  When debugging, the last remaining bug was that it was trying to use the 4th available digit when only three digits were available, and treating the non-existent digit as zero while adding no character to the RPN notation, rather than flagging an error.



Modifying the program to save the shortest (i.e., the first occurrence of that length) solution (when written in RPN), I found the following shortest expressions:

1  1,3^                    1^3
2  3,1-                    3-1
3  1,3*                    1*3
4  1,3+                    1+3
5  1,4+                    1+4
6  3!                      3!
7  3,4+                    3+4
8  4!,3/                   4!/3
9  13,4-                   13-4
10  3!,4+                  3!+4
11  14,3-                  14-3
12  3,4*                   3*4
13  13                     13
14  14                     14
15  1,4+,3*                (1+4)*3
16  1,3+,4*                (1+3)*4
17  13,4+                  13+4
18  4!,3!-                 4!-3!
19  1,3!-,4!+              1-3!+4!
20  14,3!+                 14+3!
21  4!,3-                  4!-3
22  1,3-,4!+               1-3+4!
23  4!,1-                  4!-1
24  4!                     4!
25  1,4!+                  4!+1
26  3,1-,4!+               3-1+4!
27  31,4-                  31-4
28  1,3+,4!+               1+3+4!
29  3!,1-,4!+              3!-1+4!
30  3!,4!+                 3!+4!
31  31                     31
32  
33  34,1-                  34-1
34  34                     34
35  1,34+                  1+34
36  3!,4,1-!*              3!*(4-1)!
37  13,4!+                 13+4!
38  41,3-                  41-3
39  
40  1,4+!,3/               (1+4)!/3
41  41                     41
42  14,3*                  14*3
43  43                     43
44  1,43+                  1+43
45  
46  
47  3!,41+                 3!+41
48  3,1-,4!*               (3-1)*4!
49  
50  

  Posted by Charlie on 2015-12-27 13:40:30
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 (10)
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