cleanup day 8
This commit is contained in:
parent
690f55f0ad
commit
ece9f8cdd2
@ -10,6 +10,8 @@ namespace AdventOfCode {
|
|||||||
|
|
||||||
public class Day08 {
|
public class Day08 {
|
||||||
|
|
||||||
|
public record Instruction(string Op, int Value);
|
||||||
|
|
||||||
public class GameConsole {
|
public class GameConsole {
|
||||||
int accumulator = 0;
|
int accumulator = 0;
|
||||||
int pointer = 0;
|
int pointer = 0;
|
||||||
@ -44,8 +46,6 @@ namespace AdventOfCode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Instruction(string Op, int Value);
|
|
||||||
|
|
||||||
public static int RepairBrokenInstruction(List<Instruction> code) {
|
public static int RepairBrokenInstruction(List<Instruction> code) {
|
||||||
for (int i = 0; i < code.Count(); i++) {
|
for (int i = 0; i < code.Count(); i++) {
|
||||||
if (code[i].Op == "acc") {
|
if (code[i].Op == "acc") {
|
||||||
@ -65,13 +65,13 @@ namespace AdventOfCode {
|
|||||||
throw new Exception("didn't find a valid instruction to repair");
|
throw new Exception("didn't find a valid instruction to repair");
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<Instruction> ParseInstructions(string[] code) {
|
static Instruction ParseInstruction(string line) {
|
||||||
var result = new List<Instruction>();
|
|
||||||
foreach (string line in code) {
|
|
||||||
string[] tokens = line.Split(' ');
|
string[] tokens = line.Split(' ');
|
||||||
result.Add(new Instruction(tokens[0], int.Parse(tokens[1])));
|
return new Instruction(tokens[0], int.Parse(tokens[1]));
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
|
static List<Instruction> ParseInstructions(string[] code) {
|
||||||
|
return code.ToList().Select(ParseInstruction).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Part1() {
|
static int Part1() {
|
||||||
|
Loading…
Reference in New Issue
Block a user