Would one of you be kind enough to offer up a particular problem or
subject I may research and respond to?
I am interesting in true to life practical applications of mathematics
as they relate to computation and practical matters and number theory,
but open to any creative challenge.
Thank you,
M. Michael Musatov
http://MeAmI.org
'Search. Complete.'
Have you mastered Suduko? Can you write a computer program to solve all
such puzzles?
In the 3n+C extension of the Collatz Conjecture, how long
is the loop-cycle if C = 2**94 - 3?
>
> Thank you,
>
> M. Michael Musatovhttp://MeAmI.org
>
> 'Search. Complete.'
Sudoku is meant to exercise the brain, not the computer.
Not yet!
Can you write a computer program to solve all > > such puzzles?> >>
>> > Sudoku is meant to exercise the brain, not the computer.
So true! Not to be a cryptic mystic reminscant of a 1980's Martial
Arts Film, but you might say, 'Master the brain before master the
computer!"
Here is what we have: (work in progress)
*****************
[puzzle2.c]
*****************
http://meami.org
###################
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
/* function Declarations */
int input_soduku( char* );
void print_soduku();
int solve_soduku( int );
int is_valid_soduku ( int );
/* Variables (Global) */
int soduku[81];
unsigned long int number_asks;
int list_of_empty_squares[81];
int main(int argc, char* argv[])
{
int i;
if (argc !=2)
{
printf("Enter the soduku as the second argument.\n");
return EXIT_FAILURE;
}
i = input_soduku(argv[1]);
if (!i) return EXIT_FAILURE;
number_tries = 0;
/*for(i=0; i<81; i++) printf("%d\t", list_of_empty_squares[i]);*/
i = solve_soduku(0);
if (!i)
{
printf("Hmmm... If there is a solution to this sudoku puzzle it may be
too hard for me.\n");
return EXIT_FAILURE;
}
printf("\nAwesome. Here is the solution to your Soduku!\n");
print_soduku();
printf("It took me %lu educated guesses. I'm sleepy, now. You?!\n",
number_tries);
fflush(stdout);
return EXIT_SUCCESS;
}
int is_valid_soduku (int index)
{
int i, j, k, m, n;
i = soduku[index];
/*Is the column index in?*/
for (j = index % 9; j<81; j+=9)
{
if ( (soduku[j] == i) && (j!=index) )
{
/*printf("Error:1 %d %d %d\t", index, i, j);*/
return 0;
}
}
/*is the row index in?*/
k= (index/9 + 1)*9;
for (j = (index/9)*9; j<k; j++)
{
if ( (soduku[j] == i) && (j!=index) )
{
/*printf("Error:2 %d %d %d\t", index, i, j);*/
return 0;
}
}
/*is the grid index in?*/
j= (index / 9)/3 *3;
k = (index % 9)/3 *3;
for ( m= j+2; m>=j; m--)
{
for ( n=k+2; n>=k; n--)
{
if ( (soduku[n*9+m] == i) && ((n*9+m)!=index) )
{
/*printf("Error:3 %d %d %d\t", index, i, n*9+m);*/
return 0;
}
}
}
return 1;
}
int solve_soduku(int index)
{
int new_value, empty_square;
empty_square= list_of_empty_squares[index];
if (empty_square == -1) return 1;
for( new_value=1; new_value<=9; new_value++)
{
soduku[ empty_square ] = new_value;
if ( is_valid_soduku(empty_square) )
{
number_tries++;
printf("1");
printf("%d fits in %d\t", new_value, empty_square);
if ( solve_soduku( index+1) ) return 1;
}
}
printf("Nothing fits in %d.\t", empty_square);
soduku[empty_square] = 0;
return 0;
}
void print_soduku()
{
int i, j, k;
for (i=0; i< 81; i++) {
j = i%9;
k = i/9;
if (!j)
{
printf("\n");
if ( (k==3) || (k==6) ) printf("-------------------\n");
}
if ( (j==3) || (j==6) ) printf("|");
if(soduku[i] == 0 )
{
printf( " ");
}
else
{
printf("%d ", soduku[i]);
}
}
printf("\n");
fflush(stdout);
}
int input_soduku( char* file)
{
FILE* inputSoduku;
int i;
int input;
int j=0;
inputSoduku = fopen( file ,"r");
if (!inputSoduku)
{
printf("Could not open Soduku. Let's make sure we have the soduku in
order and try again.\n");
return 0;
}
for (i=0; i< 81; i++)
{
do
{
input = fgetc( inputSoduku );
if (input == EOF)
{
printf("We have reached the end of the file before we've gotten all\n"
"our numbers. Please make sure we have the file in order.\n");
return 0;
}
} while (input<'0' || input>'9');
soduku[i] = input-'0';
if (input == '0')
{
list_of_empty_squares[j++] = i;
}
}
fclose( inputSoduku);
list_of_empty_squares[j] = -1;
printf("The soduku in %s follows.\n", file);
print_soduku();
printf("We are computing the solution. Wait please....\n");
return 1;
This is what I found:
/
//
/
/
Thank you,> >> > M. Michael Musatov http://MeAmI.org. >>>> 'Search.
Complete.'
"Fat, drunk and stupid is no way to go through
life, son." -- Dean Wormer, Animal House
>
> Thank you,> >> > M. Michael Musatovhttp://MeAmI.org. �>>>> 'Search.
> Complete.'
Not yet!
(Rest snipped for length)
It might help to spell it Sudoku.
Now try it with Code Cracker. That's my favourite.
Not yet!
Can you write a computer program to solve all > > such puzzles?> >>
>> > Sudoku is meant to exercise the brain, not the computer.
So true! Not to be a cryptic mystic reminscant of a 1980's Martial
Arts Film, but you might say, 'Master the brain before master the
computer!"
Here is what we have: (work in progress)
Why don't you just provide an algorithm?
An idiot is one who dismissed knowledge or understanding under
prejudice of their own judgment imposed upon others.
--M.Michael Musatov
For my part, the answer to both questions is "yes". There's another,
related question to which I would have to answer differently.