RosettaCodeData/Task/Dinesmans-multiple-dwelling-problem/Quackery/dinesmans-multiple-dwelling-problem.quackery
2024-07-13 15:19:22 -07:00

38 lines
1.2 KiB
Text

[ stack ] is problem ( --> s )
[ temp share 0 peek ] is baker ( --> n )
[ temp share 1 peek ] is cooper ( --> n )
[ temp share 2 peek ] is fletcher ( --> n )
[ temp share 3 peek ] is miller ( --> n )
[ temp share 4 peek ] is smith ( --> n )
[ temp share size = ] is top ( n --> b )
[ 1 = ] is bottom ( n --> b )
[ > ] is higher ( n n --> b )
[ - abs 1 = ] is adjacent ( n n --> b )
[ if ]done[ ] is exclude ( b --> )
[ not if ]done[ ] is require ( b --> )
[ temp share nested join ] is include ( [ --> [ )
[ ]'[ ' include join
problem put
[]
' [ 1 2 3 4 5 ]
permutations
witheach
[ temp put
problem share do
temp release ]
problem release
say " B C F M S" cr
witheach [ echo cr ] ] is solve ( --> )
solve
[ baker top exclude
cooper bottom exclude
fletcher top
fletcher bottom or exclude
miller cooper higher require
smith fletcher adjacent exclude
fletcher cooper adjacent exclude ]