Skip to content

Instantly share code, notes, and snippets.

@Logxn
Created December 12, 2019 10:48
Show Gist options
  • Save Logxn/e25c2fb71fc0c3236ee4250541c05aaf to your computer and use it in GitHub Desktop.
Save Logxn/e25c2fb71fc0c3236ee4250541c05aaf to your computer and use it in GitHub Desktop.
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