()
| 29 | } |
| 30 | |
| 31 | fn part_two() -> i64 { |
| 32 | let mut program = PROGRAM; |
| 33 | program[0] = 2; |
| 34 | let mut cpu = IntCoder::new(&program); |
| 35 | let (mut bx, mut px, mut score) = (0,0,0); |
| 36 | loop { |
| 37 | match cpu.execute() { |
| 38 | ExitCode::Output(x) => { |
| 39 | let y = cpu.execute_until_output(); |
| 40 | let v = cpu.execute_until_output(); |
| 41 | match (x,y,v) { |
| 42 | (-1,0,v) => score = v, |
| 43 | (x,_,3) => px = x, |
| 44 | (x,_,4) => bx = x, |
| 45 | _ => {} |
| 46 | } |
| 47 | }, |
| 48 | ExitCode::AwaitInput => cpu.push_input(cmp_xs(bx,px)), |
| 49 | ExitCode::Halted => break score, |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | fn main() { |
| 55 | let now = Instant::now(); |
nothing calls this directly
no test coverage detected