Esempio n. 1
0
    static bool CanPutWord(WordPlaceholder placeholder, string word, List <WordPlaceholder> crossings)
    {
        if (word.Length != placeholder.Length)
        {
            return(false);
        }
        if (crossings == null || !crossings.Any())
        {
            return(true);
        }
        foreach (var c in crossings)
        {
            if (c.Word == null)
            {
                continue;
            }
            var crossAt2 = c.CrossWithAt(placeholder);
            var crossAt1 = placeholder.CrossWithAt(c);

            if (word[crossAt1] != c.Word[crossAt2])
            {
                return(false);
            }
        }
        return(true);
    }
Esempio n. 2
0
 public int CrossWithAt(WordPlaceholder p)
 {
     if (Orientation == p.Orientation)
     {
         return(-1);
     }
     if (Orientation == "H" && Start.Y >= p.Start.Y && Start.Y <= p.End.Y)
     {
         return(p.Start.X - Start.X);
     }
     if (Orientation == "V" && Start.X >= p.Start.X && Start.X <= p.End.X)
     {
         var crossingPoint = p.Start.Y - Start.Y;
         return(crossingPoint < Length ? crossingPoint : -1);
     }
     return(-1);
 }