Esempio n. 1
0
 char CurrentState(int x, int y)
 {
     if (x < 0 || y < 0 || x >= _seats.Cols() || y >= _seats.Rows())
     {
         return(_boundary);
     }
     return(_seats.Get(x, y));
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }