ProjectEuler problem 24 solution - in PDP/8 assembly language
-
I solved this in PDP/8 assembly language PAL/8. It's a brute force loop unrolled for the /8. The answer is in octal so don't panic.
.PAL E24,E24 E 20:31 / examine the answer
20: 0002
21: 0007
22: 0010
23: 0003
24: 0011
25: 0001
26: 0005
27: 0004
30: 0006
31: 0000
sim> G 7600 / back to the monitor
.Recent work for $(DAYJOB) has triggered memories of PDP/8, PAL/8, OS/8, FOTP, PIP, ODT, and the whole suite of stuff from the dark ages [1]. Here's my source code listing:
.TYPE E24.LS
/ PROJECTEULER.NET PROBLEM 24 PAL8-V12B 02-NOV-77 PAGE 1
/ PROJECTEULER.NET PROBLEM 24 / / A PERMUTATION IS AN ORDERED ARRANGEMENT OF OBJECTS. / FOR EXAMPLE, 3124 IS ONE POSSIBLE PERMUTATION OF / THE DIGITS 1, 2, 3 AND 4. IF ALL OF THE PERMUTATIONS / ARE LISTED NUMERICALLY OR ALPHABETICALLY, / WE CALL IT LEXICOGRAPHIC ORDER. / THE LEXICOGRAPHIC PERMUTATIONS OF 0, 1 AND 2 ARE: / / 012 021 102 120 201 210 / / WHAT IS THE MILLIONTH LEXICOGRAPHIC PERMUTATION / OF THE DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8 AND 9? / / PAL/8 DIGITAL EQUIPMENT CORPORATION (DEC) PDP/8 / ASSEMBLY LANGUAGE SOLUTION BY CHUCK ROLKE, 2-NOV-2011 / 0010 \*10
00010 0000 CHKPTR, 0
0020 \*20 / SOLUTION IS CONSTRUCTED HERE
00020 0000 D0, 0
00021 0000 D1, 0
00022 0000 D2, 0
00023 0000 D3, 0
00024 0000 D4, 0
00025 0000 D5, 0
00026 0000 D6, 0
00027 0000 D7, 0
00030 0000 D8, 0
00031 0000 D9, 0
/ COUNTERS
00032 0000 C0, 0
00033 0000 C1, 0
00034 0000 C2, 0
00035 0000 C3, 0
00036 0000 C4, 0
00037 0000 C5, 0
00040 0000 C6, 0
00041 0000 C7, 0
00042 0000 C8, 0
00043 0000 C9, 0
/ SUBR POINTERS
00044 0202 PTR0, S0
00045 0215 PTR1, S1
00046 0233 PTR2, S2
00047 0251 PTR3, S3
00050 0267 PTR4, S4
00051 0305 PTR5, S5
00052 0323 PTR6, S6
00053 0341 PTR7, S7
00054 0400 PTR8, S8
00055 0416 PTR9, S9 -
I solved this in PDP/8 assembly language PAL/8. It's a brute force loop unrolled for the /8. The answer is in octal so don't panic.
.PAL E24,E24 E 20:31 / examine the answer
20: 0002
21: 0007
22: 0010
23: 0003
24: 0011
25: 0001
26: 0005
27: 0004
30: 0006
31: 0000
sim> G 7600 / back to the monitor
.Recent work for $(DAYJOB) has triggered memories of PDP/8, PAL/8, OS/8, FOTP, PIP, ODT, and the whole suite of stuff from the dark ages [1]. Here's my source code listing:
.TYPE E24.LS
/ PROJECTEULER.NET PROBLEM 24 PAL8-V12B 02-NOV-77 PAGE 1
/ PROJECTEULER.NET PROBLEM 24 / / A PERMUTATION IS AN ORDERED ARRANGEMENT OF OBJECTS. / FOR EXAMPLE, 3124 IS ONE POSSIBLE PERMUTATION OF / THE DIGITS 1, 2, 3 AND 4. IF ALL OF THE PERMUTATIONS / ARE LISTED NUMERICALLY OR ALPHABETICALLY, / WE CALL IT LEXICOGRAPHIC ORDER. / THE LEXICOGRAPHIC PERMUTATIONS OF 0, 1 AND 2 ARE: / / 012 021 102 120 201 210 / / WHAT IS THE MILLIONTH LEXICOGRAPHIC PERMUTATION / OF THE DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8 AND 9? / / PAL/8 DIGITAL EQUIPMENT CORPORATION (DEC) PDP/8 / ASSEMBLY LANGUAGE SOLUTION BY CHUCK ROLKE, 2-NOV-2011 / 0010 \*10
00010 0000 CHKPTR, 0
0020 \*20 / SOLUTION IS CONSTRUCTED HERE
00020 0000 D0, 0
00021 0000 D1, 0
00022 0000 D2, 0
00023 0000 D3, 0
00024 0000 D4, 0
00025 0000 D5, 0
00026 0000 D6, 0
00027 0000 D7, 0
00030 0000 D8, 0
00031 0000 D9, 0
/ COUNTERS
00032 0000 C0, 0
00033 0000 C1, 0
00034 0000 C2, 0
00035 0000 C3, 0
00036 0000 C4, 0
00037 0000 C5, 0
00040 0000 C6, 0
00041 0000 C7, 0
00042 0000 C8, 0
00043 0000 C9, 0
/ SUBR POINTERS
00044 0202 PTR0, S0
00045 0215 PTR1, S1
00046 0233 PTR2, S2
00047 0251 PTR3, S3
00050 0267 PTR4, S4
00051 0305 PTR5, S5
00052 0323 PTR6, S6
00053 0341 PTR7, S7
00054 0400 PTR8, S8
00055 0416 PTR9, S9Any idea how much time this would take on a real PDP/8?
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail
-
Any idea how much time this would take on a real PDP/8?
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail
-
I solved this in PDP/8 assembly language PAL/8. It's a brute force loop unrolled for the /8. The answer is in octal so don't panic.
.PAL E24,E24 E 20:31 / examine the answer
20: 0002
21: 0007
22: 0010
23: 0003
24: 0011
25: 0001
26: 0005
27: 0004
30: 0006
31: 0000
sim> G 7600 / back to the monitor
.Recent work for $(DAYJOB) has triggered memories of PDP/8, PAL/8, OS/8, FOTP, PIP, ODT, and the whole suite of stuff from the dark ages [1]. Here's my source code listing:
.TYPE E24.LS
/ PROJECTEULER.NET PROBLEM 24 PAL8-V12B 02-NOV-77 PAGE 1
/ PROJECTEULER.NET PROBLEM 24 / / A PERMUTATION IS AN ORDERED ARRANGEMENT OF OBJECTS. / FOR EXAMPLE, 3124 IS ONE POSSIBLE PERMUTATION OF / THE DIGITS 1, 2, 3 AND 4. IF ALL OF THE PERMUTATIONS / ARE LISTED NUMERICALLY OR ALPHABETICALLY, / WE CALL IT LEXICOGRAPHIC ORDER. / THE LEXICOGRAPHIC PERMUTATIONS OF 0, 1 AND 2 ARE: / / 012 021 102 120 201 210 / / WHAT IS THE MILLIONTH LEXICOGRAPHIC PERMUTATION / OF THE DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8 AND 9? / / PAL/8 DIGITAL EQUIPMENT CORPORATION (DEC) PDP/8 / ASSEMBLY LANGUAGE SOLUTION BY CHUCK ROLKE, 2-NOV-2011 / 0010 \*10
00010 0000 CHKPTR, 0
0020 \*20 / SOLUTION IS CONSTRUCTED HERE
00020 0000 D0, 0
00021 0000 D1, 0
00022 0000 D2, 0
00023 0000 D3, 0
00024 0000 D4, 0
00025 0000 D5, 0
00026 0000 D6, 0
00027 0000 D7, 0
00030 0000 D8, 0
00031 0000 D9, 0
/ COUNTERS
00032 0000 C0, 0
00033 0000 C1, 0
00034 0000 C2, 0
00035 0000 C3, 0
00036 0000 C4, 0
00037 0000 C5, 0
00040 0000 C6, 0
00041 0000 C7, 0
00042 0000 C8, 0
00043 0000 C9, 0
/ SUBR POINTERS
00044 0202 PTR0, S0
00045 0215 PTR1, S1
00046 0233 PTR2, S2
00047 0251 PTR3, S3
00050 0267 PTR4, S4
00051 0305 PTR5, S5
00052 0323 PTR6, S6
00053 0341 PTR7, S7
00054 0400 PTR8, S8
00055 0416 PTR9, S9Nice. I created some PDP assembly code around the same time, some was PDP/8, the majority was PDP/11. Two remarks though: 1. there are more clever ways to do this, they are faster and smarter than simple brute force. 2. Project Euler asks its visitors not to discuss nor disclose a solution, except within the group of members that already solved the particular problem. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
Nice. I created some PDP assembly code around the same time, some was PDP/8, the majority was PDP/11. Two remarks though: 1. there are more clever ways to do this, they are faster and smarter than simple brute force. 2. Project Euler asks its visitors not to discuss nor disclose a solution, except within the group of members that already solved the particular problem. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
Luc Pattyn wrote:
2. Project Euler asks its visitors not to discuss nor disclose a solution, except within the group of members that already solved the particular problem.
Well, a brute force, however optimized, 40 minutes run on an obscure* platform isn't quite a 'solution' to a Project Euler problem, is it? ;) * sorry for actual PDP programmers (aka 'old timers' ;p), it's now quite obscure.
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail
-
I solved this in PDP/8 assembly language PAL/8. It's a brute force loop unrolled for the /8. The answer is in octal so don't panic.
.PAL E24,E24 E 20:31 / examine the answer
20: 0002
21: 0007
22: 0010
23: 0003
24: 0011
25: 0001
26: 0005
27: 0004
30: 0006
31: 0000
sim> G 7600 / back to the monitor
.Recent work for $(DAYJOB) has triggered memories of PDP/8, PAL/8, OS/8, FOTP, PIP, ODT, and the whole suite of stuff from the dark ages [1]. Here's my source code listing:
.TYPE E24.LS
/ PROJECTEULER.NET PROBLEM 24 PAL8-V12B 02-NOV-77 PAGE 1
/ PROJECTEULER.NET PROBLEM 24 / / A PERMUTATION IS AN ORDERED ARRANGEMENT OF OBJECTS. / FOR EXAMPLE, 3124 IS ONE POSSIBLE PERMUTATION OF / THE DIGITS 1, 2, 3 AND 4. IF ALL OF THE PERMUTATIONS / ARE LISTED NUMERICALLY OR ALPHABETICALLY, / WE CALL IT LEXICOGRAPHIC ORDER. / THE LEXICOGRAPHIC PERMUTATIONS OF 0, 1 AND 2 ARE: / / 012 021 102 120 201 210 / / WHAT IS THE MILLIONTH LEXICOGRAPHIC PERMUTATION / OF THE DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8 AND 9? / / PAL/8 DIGITAL EQUIPMENT CORPORATION (DEC) PDP/8 / ASSEMBLY LANGUAGE SOLUTION BY CHUCK ROLKE, 2-NOV-2011 / 0010 \*10
00010 0000 CHKPTR, 0
0020 \*20 / SOLUTION IS CONSTRUCTED HERE
00020 0000 D0, 0
00021 0000 D1, 0
00022 0000 D2, 0
00023 0000 D3, 0
00024 0000 D4, 0
00025 0000 D5, 0
00026 0000 D6, 0
00027 0000 D7, 0
00030 0000 D8, 0
00031 0000 D9, 0
/ COUNTERS
00032 0000 C0, 0
00033 0000 C1, 0
00034 0000 C2, 0
00035 0000 C3, 0
00036 0000 C4, 0
00037 0000 C5, 0
00040 0000 C6, 0
00041 0000 C7, 0
00042 0000 C8, 0
00043 0000 C9, 0
/ SUBR POINTERS
00044 0202 PTR0, S0
00045 0215 PTR1, S1
00046 0233 PTR2, S2
00047 0251 PTR3, S3
00050 0267 PTR4, S4
00051 0305 PTR5, S5
00052 0323 PTR6, S6
00053 0341 PTR7, S7
00054 0400 PTR8, S8
00055 0416 PTR9, S9You just put me in "The Wayback Machine" & selected 1976! When programmers were REAL programmers. No keyboards. Just bit-switch panels. And graphics rendered on oscilloscopes!
-
Luc Pattyn wrote:
2. Project Euler asks its visitors not to discuss nor disclose a solution, except within the group of members that already solved the particular problem.
Well, a brute force, however optimized, 40 minutes run on an obscure* platform isn't quite a 'solution' to a Project Euler problem, is it? ;) * sorry for actual PDP programmers (aka 'old timers' ;p), it's now quite obscure.
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail
Julien Villers wrote:
Well, a brute force, however optimized, 40 minutes run on an obscure* platform isn't quite a 'solution' to a Project Euler problem, is it? ;)
If the code solves the problem on the obscure platform, then it is a solution to the problem.