Skip to content

Commit fd52fe7

Browse files
committed
Oh, only three programs are allowed, then I'll hardcode
1 parent 3add9f9 commit fd52fe7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/main/java/com/sbaars/adventofcode2019/days/Day17.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.util.ArrayList;
66
import java.util.Arrays;
7+
import java.util.Collections;
78
import java.util.List;
89
import java.util.stream.Collectors;
910

@@ -54,10 +55,9 @@ private boolean hasAdjecent(char[][] grid, Point pos, char tile) {
5455
public Object part2() throws IOException {
5556
char[][] grid = new char[48][48];
5657
readDay(17);
57-
IntcodeComputer ic = new IntcodeComputer(17, 2);
58+
IntcodeComputer ic = new IntcodeComputer(17, 1);
5859
long res;
5960
int x = 0, y = 0;
60-
int result = 0;
6161
while((res = ic.run()) != IntcodeComputer.STOP_CODE) {
6262
if(res == 10) {
6363
y++;
@@ -92,18 +92,18 @@ public Object part2() throws IOException {
9292
}
9393
good.add(toString(instructions.subList(start, instructions.size())));
9494
good.stream().forEach(System.out::println);
95-
String stuff = "A,B,C,D,E,F,G,H\n" + good.stream().collect(Collectors.joining("\n"))+"\nn\n";
95+
String stuff = "A,A,B,C,B,A,C,B,C,A\nL,6,R,12,L,6,L,8,L,8\nL,6,R,12,R,8,L,8\nL,4,L,4,L,6\nn\n";
9696
System.out.println(stuff);
9797
long[] asciis = stuff.chars().mapToLong(e -> e).toArray();
9898
ic = new IntcodeComputer(17, 2);
9999
ic.setInput(asciis);
100100
System.out.println(Arrays.toString(asciis));
101-
while((res = ic.run()) != IntcodeComputer.STOP_CODE) {
102-
System.out.print((char)res);
101+
while(true) {
102+
if((res = ic.run())>255L)
103+
return res;
103104
}
104-
return 0;
105105
}
106-
106+
107107
public String toString(List<Instruction> i) {
108108
return i.stream().map(Instruction::toString).collect(Collectors.joining(","));
109109
}

src/main/java/com/sbaars/adventofcode2019/intcode/IntcodeComputer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public IntcodeComputer(int day, long...input) throws IOException {
2626
if(day == 2) {
2727
program[1] = input[0];
2828
program[2] = input[1];
29-
} else if(day == 7) {
29+
} else if(day == 17) {
3030
program[0] = input[0];
3131
}
3232
}

0 commit comments

Comments
 (0)