/* Actual dubs checking: four lines of code. */
int check(int num, int base) {
int count = 0, digit = num % base;
while (num % base == digit) {
count++; num /= base;
}
return count;
}
void print_(int num, int b) {
int n = 0;
do {
n++;
}while(num/=b);
int i = n;
for(; i > 0; i--) {
putchar(alphabet[num/(int)pow(b,i) % b]);
}
}
int main(int argc, char **argv) {
if (argc != 2) {
fprintf(stderr, "Usage: %s <postnum>\n", argv[0]);
return 1;
}
int postnum = atoi(argv[1]), base, result;
if (postnum <= 0) {
fprintf(stderr, "Invalid post number: %s\n", argv[1]);
return 1;
}
for (base = 2; base < postnum && base < MAX_BASE; base++) {
result = check(postnum, base);
if (result < 2) continue;
if (result >= 10) {
printf("* %ds in base %d: ", result, base);
} else {
printf("* %s in base %d: ", names[result], base);
}
If you check it, mine isn't explicitly for dubs, but returns however many times the (singular) digits repeat from left to right, as a symbolic function (it isn't named or declared etc but it can be ENTERPRISE SCALED to resolve run-time requirements). A function with a wider scope (patterns such as '1212' ie not comparing just singular digits) would require something more sophisticated with more lines but that would mean I would actually have to program.