813 - действительно выдающееся число
101 101 101 100 100 99 99 99 100 100
101 101 101 100 100 100 100 99 99 99
101 100 100 99 100 100 100 100 100 100 100
101 101 101 100 100 100 99 99 99 100
101 101 101 100 100 100 100 99 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
1 01 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
101 101 101 100 100 100 100 99 99 99
private static final int GROUP_SIZE = 1000;
private static final int BUCKET_SIZE = 10;
private static final double MAX_DEVIATION = BUCKET_SIZE * 1.0;
private static final int NUMBER_TO_TEST = 813;
public static void main(String[] args) {
List<Long> list = LongStream.range(1, 1000).boxed().parallel()
.filter(l -> filter("005001307700020%s", l))
.filter(l -> filter("0050013077%s00020", l))
.filter(l -> filter("00500%s1307700020", l))
.filter(l -> filter("%s005001307700020", l))
.filter(l -> filter("111111111111111%s", l))
.filter(l -> filter("1111111111%s11111", l))
.filter(l -> filter("11111%s1111111111", l))
.filter(l -> filter("%s111111111111111", l))
.filter(l -> filter("222222222222222%s", l))
.filter(l -> filter("2222222222%s22222", l))
.filter(l -> filter("22222%s2222222222", l))
.filter(l -> filter("%s222222222222222", l))
.filter(l -> filter("333333333333333%s", l))
.filter(l -> filter("3333333333%s33333", l))
.filter(l -> filter("33333%s3333333333", l))
.filter(l -> filter("%s333333333333333", l))
.filter(l -> filter("444444444444444%s", l))
.filter(l -> filter("4444444444%s44444", l))
.filter(l -> filter("44444%s4444444444", l))
.filter(l -> filter("%s444444444444444", l))
.filter(l -> filter("555555555555555%s", l))
.filter(l -> filter("5555555555%s55555", l))
.filter(l -> filter("55555%s5555555555", l))
.filter(l -> filter("%s555555555555555", l))
.filter(l -> filter("666666666666666%s", l))
.filter(l -> filter("6666666666%s66666", l))
.filter(l -> filter("66666%s6666666666", l))
.filter(l -> filter("%s666666666666666", l))
.filter(l -> filter("777777777777777%s", l))
.filter(l -> filter("7777777777%s77777", l))
.filter(l -> filter("77777%s7777777777", l))
.filter(l -> filter("%s777777777777777", l))
.filter(l -> filter("888888888888888%s", l))
.filter(l -> filter("8888888888%s88888", l))
.filter(l -> filter("88888%s8888888888", l))
.filter(l -> filter("%s888888888888888", l))
.filter(l -> filter("999999999999999%s", l))
.filter(l -> filter("9999999999%s99999", l))
.filter(l -> filter("99999%s9999999999", l))
.filter(l -> filter("%s999999999999999", l))
.collect(toList());
System.err.println(list);
}
public static boolean filter(String format, long number) {
int[] buckets = new int[BUCKET_SIZE];
for (int i = 0; i < BUCKET_SIZE; i++)
buckets[i] = 0;
for (int i = 0; i < GROUP_SIZE; i++) {
String id = format(format, i);
long l = parseLong(id);
int partition = (int) (l % number % BUCKET_SIZE);
buckets[partition] = buckets[partition] + 1;
}
int sum = 0;
for (int i = 0; i < BUCKET_SIZE; i++)
sum += buckets[i];
int deviation = 0;
for (int i = 0; i < BUCKET_SIZE; i++)
deviation += abs(buckets[i] - sum / BUCKET_SIZE);
if (number == NUMBER_TO_TEST) {
for (int i = 0; i < BUCKET_SIZE; i++)
System.out.println(buckets[i]);
System.out.println("----------------------");
}
return deviation < MAX_DEVIATION;
}