Is the Name of This Problem
Problem
Idea
There are a few methods of solving this problem. The simplest way is to create a 2D grid where each point can be a wall, a vampire, a mortal, or a mirror. These 'points' can either be their own objects or can be mapped to a single integer. Then, we simply iterate through every vampire and go in each cardinal direction and see if any mirrors reflect back to it (ignoring all the irrelevant objects).
Code
Solution - Java
package accepted;
import java.util.Scanner;
public class Problem_AL_Is_the_Name_of_This_Problem {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (true) {
String input = scan.nextLine();
String inQuotes = "", outOfQuotes = "";
int index = 0;
if (input.equals("END"))
break;
if (input.charAt(index++) != '"') {
System.out.println("not a quine");
continue;
}
boolean endOfString = false;
while (true) {
if (index + 1 >= input.length()) {
endOfString = true;
break;
}
char c = input.charAt(index++);
if (c == '"') {
break;
}
inQuotes += c;
}
if (endOfString || input.charAt(index) != ' ') {
System.out.println("not a quine");
continue;
}
if (index + 1 < input.length()) {
outOfQuotes = input.substring(++index);
}
if (inQuotes.equals(outOfQuotes)) {
System.out.println("Quine(" + inQuotes + ")");
} else {
System.out.println("not a quine");
}
}
scan.close();
}
}