Prolog (not complete, not even close, this language is the best)

This commit is contained in:
Bill Rossi 2023-12-19 16:11:49 -05:00
parent d4dcadc063
commit 21e6980087
3 changed files with 20 additions and 0 deletions

1
prolog/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
problem

13
prolog/2015/1/problem.pl Normal file
View File

@ -0,0 +1,13 @@
main :-
open('../data/2015/1/input.txt',read,InStream),
get_char(InStream,NextChar),
navigateStairs(NextChar, InStream, 0).
navigateStairs(end_of_file, _, Floor) :-
Floor.
navigateStairs(40, InStream, Floor) :- % opening paren
get_char(InStream,NextChar),
navigateStairs(NextChar, InStream, Floor + 1).
navigateStairs(41, InStream, Floor) :- % closing paren
get_char(InStream,NextChar),
navigateStairs(NextChar, InStream, Floor - 1).

6
prolog/bin/run Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
year=$1
day=$2
gplc -o $year/$day/problem $year/$day/problem.pl && time $year/$day/problem