Jump to content

Dinesman's multiple-dwelling problem: Difference between revisions

Added Easylang
m (→‎{{header|Wren}}: Minor tidy)
(Added Easylang)
Line 1,393:
 
The output is the same.
 
=={{header|EasyLang}}==
{{trans|11l}}
<syntaxhighlight>
proc nextperm . a[] .
n = len a[]
k = n - 1
while k >= 1 and a[k + 1] <= a[k]
k -= 1
.
if k = 0
a[] = [ ]
return
.
l = n
while a[l] <= a[k]
l -= 1
.
swap a[l] a[k]
k += 1
while k < n
swap a[k] a[n]
k += 1
n -= 1
.
.
for i = 1 to 5
floors[] &= i
.
BAKER = 1
COOPER = 2
FLETCHER = 3
MILLER = 4
SMITH = 5
names$[] = [ "Baker" "Cooper" "Fletcher" "Miller" "Smith" ]
#
repeat
if floors[BAKER] <> 5 and floors[COOPER] <> 1 and floors[FLETCHER] <> 1 and floors[FLETCHER] <> 5
if floors[MILLER] > floors[COOPER] and abs (floors[SMITH] - floors[FLETCHER]) <> 1 and abs (floors[FLETCHER] - floors[COOPER]) <> 1
for i to 5
print names$[i] & " lives on floor " & floors[i]
.
break 1
.
.
nextperm floors[]
until len floors[] = 0
.
</syntaxhighlight>
 
{{out}}
<pre>
Baker lives on floor 3
Cooper lives on floor 2
Fletcher lives on floor 4
Miller lives on floor 5
Smith lives on floor 1
</pre>
 
=={{header|EchoLisp}}==
2,056

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.