diff --git a/day2.m b/day2.m index 3354d15..d291e4d 100644 --- a/day2.m +++ b/day2.m @@ -28,15 +28,10 @@ :- mode parser(I) == (pred(out(I), in, out) is semidet). :- mode parser == parser(ground). -:- pred hand1(move::out, chars::in, chars::out) is semidet. -hand1(rock) --> ['A']. -hand1(paper) --> ['B']. -hand1(scissors) --> ['C']. - -:- pred hand2(move::out, chars::in, chars::out) is semidet. -hand2(rock) --> ['X']. -hand2(paper) --> ['Y']. -hand2(scissors) --> ['Z']. +:- pred hand(move::out, chars::in, chars::out) is semidet. +hand(rock) --> ['A']; ['X']. +hand(paper) --> ['B']; ['Y']. +hand(scissors) --> ['C']; ['Z']. :- pred result(result::out, chars::in, chars::out) is semidet. result(you) --> ['X']. @@ -44,15 +39,14 @@ result(draw) --> ['Y']. result(me) --> ['Z']. :- pred two(parser(T)::parser, parser(U)::parser, - T::out, U::out, - chars::in, chars::out) is semidet. + T::out, U::out, chars::in, chars::out) is semidet. two(P, Q, A, B) --> P(A), [' '], Q(B). :- pred line1(moves::out, chars::in, chars::out) is semidet. -line1(A - B) --> two(hand1, hand2, A, B). +line1(A - B) --> two(hand, hand, A, B). :- pred line2(move_res::out, chars::in, chars::out) is semidet. -line2(A - B) --> two(hand1, result, A, B). +line2(A - B) --> two(hand, result, A, B). :- pred parse_line(parser(T)::parser, string::in, T::out) is semidet.