This commit is contained in:
2023-12-08 17:10:35 -08:00
parent d5ee7282e9
commit d9980e3b33
10 changed files with 1844 additions and 0 deletions

16
08/part1.pl Normal file
View File

@@ -0,0 +1,16 @@
:- op(700, xfx, l).
:- op(700, xfx, r).
From l To :- From to To-_.
From r To :- From to _-To.
answer(Answer) :- path([], aaa, Path), length(Path, Answer).
path(_, zzz, []) :- !. % getting full path instead of just length for debugging
path(Directions, From, [Move | Cdr]) :-
next_step(Directions, Move, Remain),
G =.. [Move, From, To], G,
path(Remain, To, Cdr).
next_step([Move | Remain], Move, Remain).
next_step([], Move, Remain) :- direction(Str), atom_chars(Str, [Move | Remain]).