From 5572d13047635b0be38edb6b6e7591f035aabc03 Mon Sep 17 00:00:00 2001 From: rhiannon morris Date: Sat, 3 Dec 2022 06:55:52 +0100 Subject: [PATCH] its not called score --- day3.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/day3.m b/day3.m index d9a6745..bbbcdde 100644 --- a/day3.m +++ b/day3.m @@ -20,8 +20,8 @@ split(X, L, H) :- :- pred common(list(chars)::in, char::out) is nondet. common([S | Ss], C) :- member(C, S), (Ss = [] ; common(Ss, C)). -:- func score(char) = int. -score(C) = I :- +:- func prio(char) = int. +prio(C) = I :- if is_lower(C) then I = to_int(C) - to_int('a') + 1 else @@ -37,23 +37,23 @@ go1(Line, Out) :- if split(to_char_list(Line), Fst, Snd), common([Fst, Snd], C) then - Out = score(C) + Out = prio(C) else die("invalid line: ""%s""", [s(Line)]). :- pred go2(list(string)::in, int::out) is cc_multi. -go2(Lines, Score) :- +go2(Lines, Prio) :- if common(map(to_char_list, Lines), C) then - Score = score(C) + Prio = prio(C) else die("no item in common"). -run(one, Lines, univ(sum(Scores))) :- - map(go1, Lines, Scores). -run(two, Lines, univ(sum(Scores))) :- +run(one, Lines, univ(sum(Prios))) :- + map(go1, Lines, Prios). +run(two, Lines, univ(sum(Prios))) :- if threes(Lines, Groups) then - map(go2, Groups, Scores) + map(go2, Groups, Prios) else die("not a multiple of three lines").