mirror of
https://github.com/ckaczor/Advent2019.git
synced 2026-01-13 17:22:15 -05:00
Day 11 - Part 1
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Advent
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var direction = 0;
|
||||
var paintCount = 0;
|
||||
|
||||
while (!robot.Halted)
|
||||
{
|
||||
@@ -21,11 +22,52 @@ namespace Advent
|
||||
|
||||
var currentColor = panels.ContainsKey(key) ? panels[key] : 0;
|
||||
|
||||
var color = robot.Execute(0);
|
||||
var turn = robot.Execute(0);
|
||||
var color = robot.Execute(currentColor);
|
||||
|
||||
if (color != currentColor && !panels.ContainsKey(key))
|
||||
paintCount++;
|
||||
|
||||
panels[key] = color;
|
||||
|
||||
var turn = robot.Execute(0);
|
||||
|
||||
switch (turn)
|
||||
{
|
||||
case 0:
|
||||
direction -= 90;
|
||||
|
||||
if (direction < 0)
|
||||
direction += 360;
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction += 90;
|
||||
|
||||
if (direction >= 360)
|
||||
direction -= 360;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
y++;
|
||||
break;
|
||||
case 90:
|
||||
x++;
|
||||
break;
|
||||
case 180:
|
||||
y--;
|
||||
break;
|
||||
case 270:
|
||||
x--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine(paintCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +96,7 @@ namespace Advent
|
||||
|
||||
_setPhase = true;
|
||||
|
||||
var writeValue = _memory[_instructionPointer + 1];
|
||||
|
||||
SetValue(inputValue, _memory[_instructionPointer + 3], mode3);
|
||||
SetValue(inputValue, _memory[_instructionPointer + 1], mode1);
|
||||
|
||||
_instructionPointer += 2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user