Exemplo n.º 1
0
        static IntPair GetPosition(int idx, int currentX, int currentY)
        {
            IntPair future = mov[idx];
            int     x      = currentX + future.X;
            int     y      = currentY + future.Y;

            if (x > dim || x < 1 || y > dim || y < 1)
            {
                return(null);
            }
            return(new IntPair(x, y));
        }
Exemplo n.º 2
0
        public static bool TopDown(int x, int y)
        {
            IntPair K = new IntPair(x, y);

            if (dp.ContainsKey(K))
            {
                return(dp[K]);
            }

            bool F = false;

            for (int i = 0; i < mov.Length; i++)
            {
                IntPair p = GetPosition(i, x, y);
                if (p != null && !TopDown(p.X, p.Y))
                {
                    F = true;
                }
            }
            dp.Add(K, F);
            return(F);
        }