fork download
  1. import java.scanner.*;
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. /* Name of the class has to be "Main" only if the class is public. */
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. Scanner sc = new Scanner(System.in);
  12.  
  13. int firstX;
  14. int firstY;
  15. int secondX;
  16. int secondY;
  17. boolean canContinue = false;
  18. int firstCl = sc.nextInt();
  19. int secondCl = sc.nextInt();
  20. String str = sc.next();
  21. String str1 = sc.next();
  22. sc.close();
  23. if(firstN == secondN){
  24. System.out.println(-1);
  25. }
  26. else{
  27. if((firstCl%2 == 0 && (str.charAt(0) == 'b' || str.charAt(0) == 'd' || str.charAt(0) == 'f' || str.charAt(0) == 'h')) && (secondCl%2 == 0 && (str1.charAt(0) == 'a' || str1.charAt(0) == 'c' || str1.charAt(0) == 'e' || str1.charAt(0) == 'h'))){
  28. canContinue = true;
  29. }
  30.  
  31. if(!canContinue){
  32. System.out.println(-1);
  33. }
  34. else{
  35. firstX = firstCl;
  36. firstY = getCoordinate(str.charAt(0));
  37. secondX = secondCl;
  38. secondY = getCoorinate(str1.charAt(0));
  39. if(firstY - secondY < 0){
  40. int totalY = secondY - firstY;
  41. int totalX = secondX - firstX;
  42. if(totalX < 0){
  43. totalX = totalX * -1;
  44. }
  45. System.out.println(totalX + totalY - 1);
  46. }
  47. }
  48. }
  49. }
  50.  
  51. public static int getCoordinate(char ch){
  52. if(ch == 'a' || ch == 'b'){
  53. return 0;
  54. }
  55. else if(ch == 'c' || ch == 'd'){
  56. return 1;
  57. }
  58. else if(ch == 'e' || ch == 'f'){
  59. return 2;
  60. }
  61. else if(ch == 'g' || ch == 'h'){
  62. return 3;
  63. }
  64. }
  65. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
a1 h8
compilation info
Main.java:1: error: package java.scanner does not exist
import java.scanner.*;
^
Main.java:23: error: cannot find symbol
		if(firstN == secondN){
		   ^
  symbol:   variable firstN
  location: class Ideone
Main.java:23: error: cannot find symbol
		if(firstN == secondN){
		             ^
  symbol:   variable secondN
  location: class Ideone
Main.java:38: error: cannot find symbol
				secondY = getCoorinate(str1.charAt(0));
				          ^
  symbol:   method getCoorinate(char)
  location: class Ideone
4 errors
stdout
Standard output is empty