main.c (928B)
1#include "aoc.h" 2#include "icc.h" 3#include "util.h" 4 5#include <stdlib.h> 6#include <stdio.h> 7 8void 9part1(void) 10{ 11 struct icc icc; 12 int code; 13 14 icc_init(&icc); 15 icc_parse_inst(&icc, aoc.input, aoc.input_size); 16 17 while (icc.state != ICC_HALT) { 18 icc_step_inst(&icc); 19 switch (icc.state) { 20 case ICC_INPUT: 21 icc.in = 1; 22 break; 23 case ICC_OUTPUT: 24 aoc_debug("OUTPUT: %i\n", icc.out); 25 code = icc.out; 26 break; 27 } 28 } 29 30 aoc.answer = aprintf("%i", code); 31 aoc.solution = "15314507"; 32 33 icc_deinit(&icc); 34} 35 36void 37part2(void) 38{ 39 struct icc icc; 40 int code; 41 42 icc_init(&icc); 43 icc_parse_inst(&icc, aoc.input, aoc.input_size); 44 45 while (icc.state != ICC_HALT) { 46 icc_step_inst(&icc); 47 switch (icc.state) { 48 case ICC_INPUT: 49 icc.in = 5; 50 break; 51 case ICC_OUTPUT: 52 aoc_debug("OUTPUT: %i\n", icc.out); 53 code = icc.out; 54 break; 55 } 56 } 57 58 aoc.answer = aprintf("%i", code); 59 aoc.solution = "652726"; 60 61 icc_deinit(&icc); 62}