//Pilate wrote a title also, and put it on the cross. There was written, "JESUS OF NAZARETH, THE KING OF THE JEWS." (John 19:19)
package com.javarush.task.task20.task2027;
import java.util.List;
import java.util.ArrayList;
/*
ÐÑоÑÑвоÑд
*/
public class Solution {
public static void main(String[] args) {
int[][] crossword = new int[][]{
{'f', 'd', 'e', 'r', 'l', 'k'},
{'u', 's', 'a', 'm', 'e', 'o'},
{'l', 'n', 'g', 'r', 'o', 'v'},
{'m', 'l', 'p', 'r', 'r', 'h'},
{'p', 'o', 'e', 'e', 'j', 'j'}
};
detectAllWords(crossword, "home", "same");
/*
ÐжидаемÑй ÑезÑлÑÑаÑ
home - (5, 3) - (2, 0)
same - (1, 1) - (4, 1)
*/
}
public static Word checkNE(int[][] crossword, int startX, int startY, String s) {
int x = startX - 1;
int y = startY - 1;
for (int i = 1; i < s.length(); i++) {
if (x < 0 || y < 0)
return null;
if ((char) crossword[y][x] != s.charAt(i))
return null;
x--;
y--;
}
Word w = new Word(s);
w.setStartPoint(startX, startY);
w.setEndPoint(x + 1, y + 1);
return w;
}
public static Word checkN(int[][] crossword, int startX, int startY, String s) {
int x = startX;
int y = startY - 1;
for (int i = 1; i < s.length(); i++) {
if (y < 0)
return null;
if ((char) crossword[y][x] != s.charAt(i))
return null;
y--;
}
Word w = new Word(s);
w.setStartPoint(startX, startY);
w.setEndPoint(x, y + 1);
return w;
}
public static Word checkNW(int[][] crossword, int startX, int startY, String s) {
int x = startX + 1;
int y = startY - 1;
for (int i = 1; i < s.length(); i++) {
if (x >= crossword[0].length || y < 0)
return null;
if ((char) crossword[y][x] != s.charAt(i))
return null;
x++;
y--;
}
Word w = new Word(s);
w.setStartPoint(startX, startY);
w.setEndPoint(x - 1, y + 1);
return w;
}
public static Word checkE(int[][] crossword, int startX, int startY, String s) {
int x = startX + 1;
int y = startY;
for (int i = 1; i < s.length(); i++) {
if (x >= crossword[0].length)
return null;
if ((char) crossword[y][x] != s.charAt(i))
return null;
x++;
}
Word w = new Word(s);
w.setStartPoint(startX, startY);
w.setEndPoint(x - 1, y);
return w;
}
public static Word checkSE(int[][] crossword, int startX, int startY, String s) {
int x = startX + 1;
int y = startY + 1;
for (int i = 1; i < s.length(); i++) {
if (x >= crossword[0].length || y >= crossword.length)
return null;
if ((char) crossword[y][x] != s.charAt(i))
return null;
x++;
y++;
}
Word w = new Word(s);
w.setStartPoint(startX, startY);
w.setEndPoint(x - 1, y - 1);
return w;
}
public static Word checkS(int[][] crossword, int startX, int startY, String s) {
int x = startX;
int y = startY + 1;
for (int i = 1; i < s.length(); i++) {
if (y >= crossword.length)
return null;
if ((char) crossword[y][x] != s.charAt(i))
return null;
y++;
}
Word w = new Word(s);
w.setStartPoint(startX, startY);
w.setEndPoint(x, y - 1);
return w;
}
public static Word checkSW(int[][] crossword, int startX, int startY, String s) {
int x = startX - 1;
int y = startY + 1;
for (int i = 1; i < s.length(); i++) {
if (x < 0 || y >= crossword.length)
return null;
if ((char) crossword[y][x] != s.charAt(i))
return null;
x--;
y++;
}
Word w = new Word(s);
w.setStartPoint(startX, startY);
w.setEndPoint(x + 1, y - 1);
return w;
}
public static Word checkW(int[][] crossword, int startX, int startY, String s) {
int x = startX - 1;
int y = startY;
for (int i = 1; i < s.length(); i++) {
if (x < 0 || y >= crossword[0].length)
return null;
if ((char) crossword[y][x] != s.charAt(i))
return null;
x--;
}
Word w = new Word(s);
w.setStartPoint(startX, startY);
w.setEndPoint(x + 1, y);
return w;
}
public static List