-
-
Save aligo/3921810 to your computer and use it in GitHub Desktop.
Revisions
-
aligo revised this gist
Oct 20, 2012 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,7 @@ int main() { unsigned long int i, temp, base; unsigned char j, k; unsigned char count[10]; -
aligo revised this gist
Oct 20, 2012 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,6 @@ int main() unsigned int i; unsigned int temp, base; unsigned char j, k; unsigned char count[10]; for( i = 1e9; i < 1e10; i++ ) @@ -34,8 +33,7 @@ int main() { if (j == 9) { printf("succeeded: %010u\n", i); } } else @@ -44,7 +42,7 @@ int main() } } failed:; // printf("tested: %010u\n", i); } return 0; -
aligo revised this gist
Oct 20, 2012 . 1 changed file with 20 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,32 +3,47 @@ int main() { unsigned int i; unsigned int temp, base; unsigned char j, k; unsigned char str[10]; 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) { sprintf(str, "%010u", i); printf("succeeded: %s\n", str); } } else { goto failed; } } failed:; // printf("tested: %s\n", str); } -
aligo revised this gist
Oct 20, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,17 +7,17 @@ int main() unsigned char str[10]; unsigned char count[10]; for( i = 1e9; i < 1e10; i++ ) { memset(count, 1, 10); sprintf(str, "%010u", i); for( j = 0; j < 10; j++ ) { count[(int)(str[j] - '0')]++; } for( j = 0; j < 10; j++ ) { if ( (int)( str[j] - '0' ) == count[j] ) { if (j == 9) { -
aligo created this gist
Oct 20, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ #include <stdio.h> int main() { unsigned int i; unsigned char j; unsigned char str[10]; unsigned char count[10]; for( i = 0; i < 1e10; i++ ) { memset(count, 0, 10); sprintf(str, "%010u", i); for( j = 0; j < 10; j++ ) { count[(int)(str[j] - '0')]++; } for( j = 0; j < 10; j++ ) { if ( (int)( str[j] - '0' ) == ( count[j] + 1 ) ) { if (j == 9) { printf("succeeded: %s\n", str); } } else { break; } } // printf("tested: %s\n", str); } return 0; }