Prolog (not complete, not even close, this language is the best)
This commit is contained in:
parent
d4dcadc063
commit
21e6980087
1
prolog/.gitignore
vendored
Normal file
1
prolog/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
problem
|
13
prolog/2015/1/problem.pl
Normal file
13
prolog/2015/1/problem.pl
Normal 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
6
prolog/bin/run
Executable 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
|
Loading…
Reference in New Issue
Block a user