public void PartOne() { while (true) { //_seats.Print(); //Console.WriteLine(); //Console.ReadKey(); var next = ApplyModel(); if (next.Equals(_seats)) { break; } _seats = next; } int cnt = 0; for (int x = 0; x < _seats.Cols(); x++) { for (int y = 0; y < _seats.Rows(); y++) { if (_seats.Get(x, y) == _occupied) { cnt++; } } } Console.WriteLine(cnt); }
public Tile(string[] lines) { var match = Regex.Match(lines[0], @"Tile (\d+):$"); if (!match.Success) throw new Exception(); _id = long.Parse(match.Groups[1].Value); _map = new Tools.Map(lines.ToList().GetRange(1, lines.Length - 1).ToArray()); }
Tools.Map ApplyModel() { var ret = new Tools.Map(_seats.Cols(), _seats.Rows()); for (int x = 0; x < ret.Cols(); x++) { for (int y = 0; y < ret.Rows(); y++) { ret.Set(x, y, NewState(x, y)); } } return(ret); }