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file mode 100644 index 0000000..add8284 --- /dev/null +++ b/day02/sol.ivy @@ -0,0 +1,38 @@ +) get "input.ivy" + +test = 3 2 rho "AYBXCZ" + +op inc a = 1 + a +op dec a = -1 + a + +# returns the outcome for the first player (-1 = lose, 0=draw, +1 = win) +# of a round of rps (1-3 = rock, paper, scissors) +op a rps b = dec (inc a - b) mod 3 + +op tonum a = ("ABC" iota a) + ("XYZ" iota a) + +# converts an outcome into a score +op score outcome = + 3 + 3 * outcome + +# scores a round of rps for the first player +op a score b = + outcome = a rps b + a + score outcome + +op parta x = + x = transp tonum x + +/ x[2] score x[1] + +op partb x = + x = tonum transp x + a = x[1] + outcome = -2 + x[2] + b = inc (dec a + outcome) mod 3 + +/ b score a + +parta test +parta input + +partb test +partb input diff --git a/day02/toivy.py b/day02/toivy.py new file mode 100644 index 0000000..d818517 --- /dev/null +++ b/day02/toivy.py @@ -0,0 +1,9 @@ +data = [] +n = 0 +with open("input") as f: + for line in f: + for x in line.split(): + data.append(x) + n += 1 + +print('input = {} {} rho "{}"'.format(n, 2, ''.join(data)))