public override object PartOne(string[] input) { var(coordLines, foldLines) = new SeparatedGroupParser().Parse(input).Two(); var points = ParseCoordinates(coordLines); var folds = ParseFolds(foldLines); var folded = DoFold(points, folds[0]); Console.Out.WriteLine(folded.AsDefinedSizeNotPreservingCoordinates().Dump()); return(folded.AllDefinedCells.Count()); }
public override object PartTwo(string[] input) { var(coordLines, foldLines) = new SeparatedGroupParser().Parse(input).Two(); var points = ParseCoordinates(coordLines); var folds = ParseFolds(foldLines); // var folded = DoFold(points, folds[0]); var folded = points; foreach (var fold in folds) { folded = DoFold(folded, fold); } return(folded.AsDefinedSizeNotPreservingCoordinates().Dump()); }
public void ShouldSupportOtherSeparators() { var input = new[] { "g1 one", "g1 two", "g1 three", "=====", "g2 one", "=====", "g3 one", "g3 two" }; var groups = new SeparatedGroupParser().Parse(input, "=====").Select(x => x.ToList()).ToList(); groups.Should().HaveCount(3); groups[0].Should().Contain("g1 two"); groups[2].Should().Contain("g3 two"); }
public void ShouldAllowNewlineAtEnd() { var input = new[] { "g1 one", "g1 two", "g1 three", "", "g2 one", "", "g3 one", "g3 two", "" }; var groups = new SeparatedGroupParser().Parse(input).Select(x => x.ToList()).ToList(); groups.Should().HaveCount(3); groups[0].Should().Contain("g1 two"); groups[2].Should().Contain("g3 two"); }