Data update

This commit is contained in:
Ingy döt Net 2025-06-11 20:16:52 -04:00
parent 72eb4943cb
commit 4d5544505c
2347 changed files with 62432 additions and 16731 deletions

View file

@ -1,44 +1,27 @@
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
.
names$[] = [ "Baker" "Cooper" "Fletcher" "Miller" "Smith" ]
BAKER = 1
COOPER = 2
FLETCHER = 3
MILLER = 4
SMITH = 5
names$[] = [ "Baker" "Cooper" "Fletcher" "Miller" "Smith" ]
#
repeat
floors[] = [ 1 2 3 4 5 ]
#
proc check .
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
.
proc permute k .
for i = k to 5
swap floors[i] floors[k]
permute k + 1
swap floors[k] floors[i]
.
if k = 5 : check
.
permute 1