Skip to content

Instantly share code, notes, and snippets.

@aligo
Created October 20, 2012 02:51
Show Gist options
  • Save aligo/3921810 to your computer and use it in GitHub Desktop.
Save aligo/3921810 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{
unsigned long int i, temp, base;
unsigned char j, k;
unsigned char count[10];
for( i = 1e9; i < 1e10; i++ )
{
memset(count, 1, 10);
base = 1e9;
temp = i;
for( j = 0; j < 10; j++ )
{
k = temp / base;
temp = temp % base;
base = base / 10;
count[k]++;
if ( count[k] > 9 ) {
goto failed;
}
}
base = 1e9;
temp = i;
for( j = 0; j < 10; j++ )
{
k = temp / base;
temp = temp % base;
base = base / 10;
if ( k == count[j] )
{
if (j == 9)
{
printf("succeeded: %010u\n", i);
}
}
else
{
goto failed;
}
}
failed:;
// printf("tested: %010u\n", i);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment