Example #1
0
        static void Main(string[] args)
        {
            var state = new PlaneState(
                File.ReadAllLines("input.txt")
                .Select(line => line
                        .Select(c => StateHelper.Parse(c))));

            var stableState = Enumerable.GenerateWithPrevious(state, Next).SkipWhile(el => el.Previous != el.Current)
                              .First().Current;

            Console.WriteLine(stableState.Chairs.Count(ch => ch.State == ChairState.Occupied));

            var stableStateTwo = Enumerable.GenerateWithPrevious(state, NextPartTwo).SkipWhile(el => el.Previous != el.Current)
                                 .First().Current;

            Console.WriteLine(stableStateTwo.Chairs.Count(ch => ch.State == ChairState.Occupied));
        }