Javascript solution See the Pen Advent of code day one by Vincenzo Marcovecchio (@Vinny92) on CodePen.