## Collective Interview Question

Software Engineer / Developers**Country:**India

**Interview Type:**In-Person

Found 2074 numbers total

```
public class Main {
public static void main ( String [] arguments )
{
int [] digits = new int[6];
int count = checkNextDigits(digits, 0, 0);
System.out.println("Found " + count + " numbers");
}
public static int checkNextDigits(int [] progress, int N, int count) {
if (N == 6) {
String number = "";
for (int i = 0; i < 6; i ++) {
number += progress[i] + ((i < 5) ? "-" : "");
}
System.out.println(number);
return count + 1;
}
for (int i = 0; i <= 9; i ++) {
if (N == 0) {
if (i > 0) {
progress[0] = i;
count = checkNextDigits(progress, 1, count);
}
} else {
int pv = progress[N - 1] == 0 ? 10 : progress[N - 1] - 1;
int cv = i == 0 ? 10 : i - 1;
if (pv == cv)
continue;
int rp = pv % 3;
int dp = pv / 3;
int rc = cv % 3;
int dc = cv / 3;
if (rp == rc || dp == dc) {
boolean occurs = false;
for (int j = 0; j < N + 1; j ++) {
if (progress[j] == i)
occurs = true;
}
if (!occurs) {
progress[N] = i;
count = checkNextDigits(progress, N + 1, count);
}
}
}
}
return count;
}
}
```

- Joris Weimar April 29, 2014