Created
December 12, 2019 10:48
-
-
Save Logxn/e25c2fb71fc0c3236ee4250541c05aaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Adjacent | |
{ | |
public Adjacent() | |
{ | |
int result = 0; | |
for(int i = 264793; i <= 803935; i++) | |
{ | |
char[] number = Integer.toString(i).toCharArray(); | |
int previousDigit = -1; | |
boolean found = false; | |
for(int j = 0; j < number.length; j++) | |
{ | |
int currentDigit = Integer.parseInt(String.valueOf(number[j])); | |
if(currentDigit < previousDigit) | |
{ | |
found = false; | |
break; | |
} | |
if(currentDigit == previousDigit) | |
{ | |
if(j > 0) | |
{ | |
int digitBefore = Integer.parseInt(String.valueOf(number[j - 1])); | |
if(digitBefore == currentDigit) | |
{ | |
if(j < number.length) | |
{ | |
int digitAfter = Integer.parseInt(String.valueOf(number[j + 1])); | |
if(digitAfter == currentDigit) | |
{ | |
found = false; | |
continue; | |
} | |
} | |
} | |
} | |
else if (j < number.length) | |
{ | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment