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