Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
import algorithm
|
||||
|
||||
type
|
||||
|
||||
Person {.pure.} = enum Baker, Cooper, Fletcher, Miller, Smith
|
||||
Floor = range[1..5]
|
||||
|
||||
var floors: array[Person, Floor] = [Floor 1, 2, 3, 4, 5]
|
||||
|
||||
while true:
|
||||
if floors[Baker] != 5 and
|
||||
floors[Cooper] != 1 and
|
||||
floors[Fletcher] notin [1, 5] and
|
||||
floors[Miller] > floors[Cooper] and
|
||||
abs(floors[Smith] - floors[Fletcher]) != 1 and
|
||||
abs(floors[Fletcher] - floors[Cooper]) != 1:
|
||||
for person, floor in floors:
|
||||
echo person, " lives on floor ", floor
|
||||
break
|
||||
if not floors.nextPermutation():
|
||||
echo "No solution found."
|
||||
break
|
||||
Loading…
Add table
Add a link
Reference in a new issue