I've manually annotated some of the produced RPN (Reverse Polish Notation) with the equivalent algebraic notation. Many of the findings are basically equivalent to others and have not been so annotated.
RPN Algebraic
0269
9,2^,6,0^- 9^2 - 6^0
0246
20,4* 20*4
2,40* 2*40
40,2* 40*2
4,20* 4*20
0468
04,6+,8* (4+6)*8
0,4+,6+,8*
0,4,6++,8*
0,4,6+,8*+ ...variations
06,4+,8*
0,6+,4+,8*
0,6,4++,8*
0,6,4+,8*+
08,4,6+*
0,8+,4,6+*
0,8,4,6+*+
08,6,4+*
0,8+,6,4+*
0,8,6,4+*+
4,06+,8*
4,0+,6+,8*
4,0-,6+,8*
4,0,6++,8*
4,0,6--,8*
40,8,6-*
4,6+,08*
4,6+,0+,8*
4,6+,0-,8*
4,6+,0,8+*
4,6,0++,8*
4,6,0-+,8*
4,6+,8*
4,6+,8*,0+
4,6+,8*,0-
4,6+,8,0+*
4,6+,8,0-*
480,6/ 480/6
6,04+,8*
6,0+,4+,8*
6,0-,4+,8*
6,0,4++,8*
6,0,4--,8*
640,8/ 640/8
6,4+,08*
6,4+,0+,8*
6,4+,0-,8*
6,4+,0,8+*
6,4,0++,8*
6,4,0-+,8*
6,4+,8*
6,4+,8*,0+
6,4+,8*,0-
6,4+,8,0+*
6,4+,8,0-*
80 80
8,04,6+*
8,0+,4,6+*
8,0-,4,6+*
8,0,4+,6+*
8,0,4,6++*
80
8,06,4+*
8,0+,6,4+*
8,0-,6,4+*
8,0,6+,4+*
8,0,6,4++*
8,4,06+*
8,4,0+,6+*
8,4,0-,6+*
8,4,0,6++*
8,4,0,6--*
8,4,6+*
8,4,6+*,0+
8,4,6+*,0-
8,4,6+,0+*
8,4,6+,0-*
8,4,6,0++*
8,4,6,0-+*
8,6,04+*
8,6,0+,4+*
8,6,0-,4+*
8,6,0,4++*
8,6,0,4--*
8,6-,40* (8-6)*40
8,6,4+*
8,6,4+*,0+
8,6,4+*,0-
8,6,4+,0+*
8,6,4+,0-*
8,6,4,0++*
8,6,4,0-+*
0579
05,7,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
9,7,1/+,5*
9,7,1^+,5*
9,7+,5*
9,7+,5*,1*
9,7+,5*,1/
9,7+,5*,1^
9,7+,5,1**
9,7+,5,1/*
9,7+,5,1^*
9,7,5-^,1- 9^(7-5) - 1
1645
16,5* 16*5
5,16*
2359 ............. hmmm, nothing here
5555
55,5,5*+ 55+5*5
5,5*,55+
8249
8,2,4*,9*+ 8 + 2*4*9
8,2,4,9**+
8,2*,9,4-* 2 * 8 * (9-4)
8,2,9*,4*+
8,2,9,4-**
8,2,9,4**+
8,4,2*,9*+
8,4,2,9**+
8,4,9*,2*+
8,4,9,2**+
8,9*,2,4*+
8,9,2*,4*+
8,9,2,4**+
8,9*,4,2*+
8,9,4-*,2*
8,9,4-,2**
8,9,4*,2*+
8,9,4,2**+
92,4-,8- 92-4-8
92,4,8+-
9,2*,4*,8+
9,2,4**,8+
92,8-,4-
92,8,4+- 92-(4+8)
9,4-,2*,8*
9,4-,2,8**
9,4*,2*,8+
9,4,2**,8+
9,4-,8*,2*
9,4-,8,2**
9,8*,2,4*+
9,8*,4,2*+
2,4*,8,9*+
2,4*,9*,8+
2,4*,9,8*+
2,4,9**,8+
2,8*,9,4-*
2,8,9,4-**
2,9*,4*,8+
2,9,4-*,8*
2,9,4-,8**
2,9,4**,8+
4,2*,8,9*+
4,2*,9*,8+
4,2*,9,8*+
4,2,9**,8+
4,9*,2*,8+
4,9,2**,8+
9999
9,9*,9,9/- 9*9 - 9/9
DefDbl A-Z
Dim crlf$, puzz(13) As String, stack(10), concatable(4)
Dim stackPtr, wh, pz As String, expstr As String
Private Sub Form_Load()
Form1.Visible = True
puzz(1) = "0269"
puzz(2) = "0246"
puzz(3) = "0468"
puzz(4) = "0579"
puzz(5) = "0126"
puzz(6) = "1234"
puzz(7) = "1469"
puzz(8) = "1579"
puzz(9) = "1645"
puzz(10) = "2359"
puzz(11) = "5555"
puzz(12) = "8249"
puzz(13) = "9999"
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For pNo = 1 To 13
pz$ = puzz(pNo)
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
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Sub addOn()
ReDim sstack(4)
ReDim sconcatable(4)
DoEvents
For typ = 0 To 6
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 < 5 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 < 5 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
End Select
If good Then
If stackPtr = 1 Then
If stack(stackPtr) = 80 Then
Text1.Text = Text1.Text & " " & expstr & crlf
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
|
Posted by Charlie
on 2015-12-19 13:15:36 |