Created
December 11, 2017 08:40
-
-
Save rvlieshout/68fed8d0a5974817791e684c444b32ba to your computer and use it in GitHub Desktop.
AoC 2017, Day 11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Day11 | |
{ | |
class Program | |
{ | |
static int childX = 0; | |
static int childY = 0; | |
static int furthest = 0; | |
static void Main(string[] args) | |
{ | |
var input = File.ReadAllText("input.txt").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); | |
foreach (var childStep in input) | |
{ | |
if (childStep.First() == 'n') | |
{ | |
childY -= 1; | |
} | |
else | |
{ | |
childY += 1; | |
} | |
if (childStep.Last() == 'e') | |
{ | |
childX += 1; | |
} | |
else if (childStep.Last() == 'w') | |
{ | |
childX -= 1; | |
} | |
if (childX > furthest) furthest = childX; | |
if (childY > furthest) furthest = childY; | |
} | |
Console.WriteLine($"Child @ ({childX}, {childY}) steps = {Math.Max(childX, childY)} furthest = {furthest}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment