This commit is contained in:
Max Headroom 2022-12-02 16:00:43 +01:00
parent 56f51ca599
commit d5b828b1b9
3 changed files with 2564 additions and 0 deletions

32
2/advanced.nix Normal file
View file

@ -0,0 +1,32 @@
with import <nixpkgs/lib>;
let
input = fileContents ./input.txt;
splitStr = pattern: flip pipe [
(strings.split pattern)
(filter isString)
];
score = myAction: opponentShape: {
X.A = 0 + 3;
X.B = 0 + 1;
X.C = 0 + 2;
Y.A = 3 + 1;
Y.B = 3 + 2;
Y.C = 3 + 3;
Z.A = 6 + 2;
Z.B = 6 + 3;
Z.C = 6 + 1;
}.${myAction}.${opponentShape};
in
pipe input [
(splitStr "\n")
(map (flip pipe [
(splitStr " ")
elemAt
(get: score (get 1) (get 0))
]))
(foldl' add 0)
]

32
2/basic.nix Normal file
View file

@ -0,0 +1,32 @@
with import <nixpkgs/lib>;
let
input = fileContents ./input.txt;
splitStr = pattern: flip pipe [
(strings.split pattern)
(filter isString)
];
score = myShape: opponentShape: {
X.A = 3 + 1;
X.B = 0 + 1;
X.C = 6 + 1;
Y.A = 6 + 2;
Y.B = 3 + 2;
Y.C = 0 + 2;
Z.A = 0 + 3;
Z.B = 6 + 3;
Z.C = 3 + 3;
}.${myShape}.${opponentShape};
in
pipe input [
(splitStr "\n")
(map (flip pipe [
(splitStr " ")
elemAt
(get: score (get 1) (get 0))
]))
(foldl' add 0)
]

2500
2/input.txt Normal file

File diff suppressed because it is too large Load diff