Skip to content

Instantly share code, notes, and snippets.

@rvlieshout
Created December 11, 2017 08:40
Show Gist options
  • Save rvlieshout/68fed8d0a5974817791e684c444b32ba to your computer and use it in GitHub Desktop.
Save rvlieshout/68fed8d0a5974817791e684c444b32ba to your computer and use it in GitHub Desktop.
AoC 2017, Day 11
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