top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Return the number of all nondistinct occurrences of the words found in the array in all direction?

+2 votes
506 views

Question: C#, Java or VB.Net

Given the following:

public static class PuzzleSolver
{
    public static string[] DICTIONARY = {"OX","CAT","TOY","AT","DOG","CATAPULT","T"};
    static bool IsWord(string testWord)
    {
        if (DICTIONARY.Contains(testWord))

            return true;

        return false;
    }
}

Now Implement the function public static int FindWords(char[,] puzzle), FindWords should return the number of all non-distinct occurrences of the words found in the array, horizontally, vertically or diagonally, and also the reverse in each direction.

Example Input 1:

CAT
XZT
YOT

Example Output 1:

8
(AT, AT, CAT, OX, TOY, T, T, T)

Example Input 2:

CATAPULT
XZTTOYOO
YOTOXTXX  

Example Output 2:

22
posted Aug 20, 2015 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

Given a 2d matrix with characters and a dictionary. Find non-distinct occurrences of the words found in the array, horizontally, vertically or diagonally, and also the reverse in each direction.

+2 votes

Given a string and two words which are present in the string, find the minimum distance between the words

Example:
"the brown quick frog quick the", "the" "quick"
Min Distance: 1

"the quick the brown quick brown the frog", "the" "brown"
Min Distance: 2

C/Java code would be helpful?

+3 votes

Input: arr[] = {5, 5, 10, -10, -20, 40, 50, 35, -20, -50}
Output: 125 (40, 50, 35)

...