*
COUNT 81 THIS PROGRAM GENERATES 765 INSTRUCTIONS
TITLE IT SOLVES THE PENTOMINO PROBLEM BY MACRO RECURSION
*
TEST MACRO C,NEXT,XX CONSIDER SQUARE C (RELATIVE TO LEAD).
ZET ARENA-C,1 SEE WHETHER IT IS EMPTY>
IFF K-1,0,0 (FOR OTHER THAN LEAD (C NOT 0)), DO NEXT ITEM,)
TRA XX+1 IF IT IS NOT EMPTY, TRY NEXT CHOICE FOR C.
IFF K-1,0,1 (FOR LEAD (C IS 0), DO NEXT ITEM.)
TCo DO AS DESCRIBED IN TCo MACRO>
STQ ARENA-C,1 INDICATE SQUARE C TO BE OCCUPIED.
K SET K+1 (ADVANCE COUNT OF DEPTH OF MACRO NESTING.)
IRP NEXT (ITERATE ON ITEMS IN NEXT, WHICH IS A LIST.)
IFF K-5,0,0 (FOR DEPTH OF NESTING NOT 5, DO NEXT ITEM.)
TEST NEXT DO AS IN TEST MACRO WITH ARGUMENTS FROM NEXT.
IFF K-5,0,1 (FOR DEPTH OF NESTING EQUAL 5, DO NEXT ITEM.)
FTEST NEXT DO AS IN FTEST MACRO WITH ARGUMENTS FROM NEXT.
IRP (CEASE ITERATING ON ITEMS IN NEXT.)
K SET K-1 (REDUCE COUNT OF DEPTH OF MACRO NESTING.)
XX STZ ARENA-C,1 RESET SQUARE C TO EMPTY.
TEST END SQUARE C AND ITEMS IN NEXT NOW ALL CONSIDERED.
*
TCo MACRO LEAD SQUARE HAS BEEN TESTED.
TXI STEM,1,1 IF NOT EMPTY, TRY NEXT SQUARE AS LEAD.
PXD ,1 IF EMPTY, RECORD ITS NUMBER
STD LEAD,2 AT PROPER PLACE IN LEAD ARRAY, AND
TCo END CONTINUE.
*
FTEST MACRO C,M CONSIDER SQUARE C AND PENTOMINO M.
ZET ARENA-C,1 SEE WHETHER SQUARE C IS EMPTY.
TRA *+9 IF NOT, TRY NEXT CHOICE FOR C. OTHERWISE,
ZET MINO-M SEE WHETHER PENOMINO M IS UNUSED>
TRA *+7 IF NOT, TRY NEXT CHOICE FOR C AND M. OTHERWISE,
STQ ARENA-C,1 INDICATE SQUARE C TO BE OCCUPIED,
STQ MINO-M INDICATE PENTOMINO M TO BE USED,
STL PATT,2 SAVE CURRENT POINT IN SEARCH OF PATTERNS, AND
TXI ROOT,2,1 PROCEED TO TRY TO PLACE ANOTHER PATTERN>
STZ ARENA-C,1 RESET SQUARE C TO EMPTY.
STZ MINO-M RESET PENTOMINO M TO UNUSED STATUS>
FTEST END SQUARE C AND PENTOMINO M HAVE BEEN CONSIDERED>
*
CALL INPUT,ARENA,MINO INITIALIZE ARENA AND MINO ARRAYS.
AXT 1,1 INDEX 1 = NO. OF CURRENT LEAD SQUARE.
AXT 1,2 INDEX 2 = NO. OF PATTERNS ALREADY PLACED + 1.
AXC 1,4 INDEX 4 = -1 ALWAYS.
K SET 1 (K = DEPTH OF MACRO NESTING.)
*
ROOT TXH SOLVED,2,12 SOLUTION FOUND IF 12 PATTERNS ALREADY PLACED.
PXD ,2 SET DECREMENT
XCA OF MQ TO NEW VALUE OF INDEX 2.
*
STEM TEST 00((01((02($ BEGIN SEARCH OF PATTERNS.
ETC (03((04,02)(16,03)(17,11)(18,11)(19,03)))$
ETC (16((15,04)(17,05)(18,07)(32,08)))$
ETC (17((18,05)(33,06)))$
ETC (18((19,04)(34,08)))))(16($
ETC (15((14,04)(31,09)(17,05)(32,01)))$
ETC (17((18,05)(32,05)(33,05)))$
ETC (32((31,12)(33,07)(48,03)))))(17($
ETC (18((19,04)(33,01)(34,09)))$
ETC (33((32,07)(34,12)(49,03)))))))(16((15($
ETC (14((13,03)(30,12)(31,01)(17,11)(32,06)))$
ETC (31((30,09)(17,01)(32,05)(47,04)))$
ETC (17((18,11)(32,10)(33,01)))$
ETC (32((33,01)(48,11)))))(17($
ETC (18((02,07)(19,03)(32,06)(33,01)(34,12)))$
ETC (32((31,01)(33,05)(48,11)))$
ETC (33((34,09)(49,04)))))(32($
ETC (31((30,08)(47,04)(33,06)(48,11)))$
ETC (33((34,08)(48,11)(49,04)))$
ETC (48((47,03)(49,03)(64,02))))))))
*
TIX STEMX,2,1 ALL PATTERNS TRIED WITH CURRENT LEAD, SO
CALL FINISH IF NO PATTERNS ALREADY PLACED, EXIT, ELSE
STEMX CAL LEAD,2 RECALL PREVIOUS NUMBER OF LEAD SQUARE,
PDX ,1 RESTORE IT TO STATUS AS CURRENT LEAD,
PXD ,2 RESET DECREMENT
XCA OF MQ TO REFLECT REDUCTION IN INDEX 2, AND
TRA* PATT,2 RETURN TO EXAMINATION OF PATTERNS.
*
SOLVED CALL OUTPUT,ARENA,MINO SOLUTION OBTAINED, SO OUTPUT IT,
AXC 1,4 RESET INDEX 4 TO -1, AND
TXI STEMX,2,-1 RETURN TO SEARCH FOR NEW 12TH PATTERN.
*
ARENA BES 512 THIS ARRAY CORRESPONDS TO THE SQUARES.
MINO BES 12 THIS ARRAY CORRESPONDS TO THE PENTOMINOS.
LEAD BES 12 THIS IS A PUSHDOWN LIST OF LEAD SQUARES.
DUP 1,12 (SINCE INDEX 4 = -1, INDIRECT ADDRESSING THRU THE
PZE ,4 PATT ARRAY TRANSFERS TO STORED LOCATION + 1.)
PATT BES 0 THIS IS A PUSHDOWN LIST OF PATTERNS.
END SUBROUTINES REQUIRED ARE INPUT, OUTPUT, FINISH.
*