From a85f5cf60fac43384ee32c704798f6185f9d8376 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Wed, 19 Dec 2018 19:00:12 +0100 Subject: [PATCH] day19p2 --- day19p2/Makefile | 8 +++++++ day19p2/input | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ day19p2/main.c | 13 +++++++++++ 3 files changed, 82 insertions(+) create mode 100644 day19p2/Makefile create mode 100644 day19p2/input create mode 100644 day19p2/main.c diff --git a/day19p2/Makefile b/day19p2/Makefile new file mode 100644 index 0000000..b33670e --- /dev/null +++ b/day19p2/Makefile @@ -0,0 +1,8 @@ +CFLAGS := -O3 -Wall -Wextra -std=c17 -D_GNU_SOURCE + +.PHONY: all +all: main + +.PHONY: clean +clean: + rm -f main diff --git a/day19p2/input b/day19p2/input new file mode 100644 index 0000000..d54e8c2 --- /dev/null +++ b/day19p2/input @@ -0,0 +1,61 @@ +#ip 3 +#reg0=1 + +; fn main() +; &1 = ((&1 + 2) ** 2) * 19(&3) * 11 = ((&1 + 2) ** 2) * 209 +; &2 = ((&2 + 2) * 22(&3)) + 20 = &2 * 22 + 64 +; &1 = &1 + &2 +; if (&0 != 0) { +; &2 = ((((27(&3) * 28(&3)) + 29(&3)) * 30(&3)) * 14) * 32(&3) = 10550400 +; &1 = &1 + &2 +; &0 = 0 +; } +; &5 = 1 +; do { +; &4 = 1 +; do { +; if (&5 * &4 == &1) { +; &0 = &0 + &5 +; } +; &4 = &4 + 1 +; } while (&4 <= &1) +; +; &5 = &5 + 1 +; } while (&5 <= &1); + +00: addi 3 16 3 +01: seti 1 9 5 +02: seti 1 1 4 +03: mulr 5 4 2 +04: eqrr 2 1 2 +05: addr 2 3 3 +06: addi 3 1 3 +07: addr 5 0 0 +08: addi 4 1 4 +09: gtrr 4 1 2 +10: addr 3 2 3 +11: seti 2 3 3 +12: addi 5 1 5 +13: gtrr 5 1 2 +14: addr 2 3 3 +15: seti 1 4 3 +16: mulr 3 3 3 +17: addi 1 2 1 +18: mulr 1 1 1 +19: mulr 3 1 1 +20: muli 1 11 1 +21: addi 2 2 2 +22: mulr 2 3 2 +23: addi 2 20 2 +24: addr 1 2 1 +25: addr 3 0 3 +26: seti 0 4 3 +27: setr 3 9 2 +28: mulr 2 3 2 +29: addr 3 2 2 +30: mulr 3 2 2 +31: muli 2 14 2 +32: mulr 2 3 2 +33: addr 1 2 1 +34: seti 0 6 0 +35: seti 0 0 3 diff --git a/day19p2/main.c b/day19p2/main.c new file mode 100644 index 0000000..5c3d891 --- /dev/null +++ b/day19p2/main.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + unsigned r0 = 0; + unsigned r1 = 10551300; + for (unsigned r5 = 1; r5 <= r1; r5++) { + if (r1 % r5 == 0) { + r0 = r0 + r5; + } + } + printf("%d\n", r0); +}