to solve "algorithm 196" I want a new DataType(C++ Numeric) which can contain minimum 64 byte.
Can it possible?
I think possible, but i don't know How?
Please, Help me.
to solve "algorithm 196" I want a new DataType(C++ Numeric) which can contain minimum 64 byte.
Can it possible?
I think possible, but i don't know How?
Please, Help me.
Last edited by Salem; 12-13-2006 at 06:28 AM. Reason: snip off-board contact information
you create class that internally stores the data, for example as a string, or array of digits, or something else
and you overload all mathimatical operations for your class
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
You mean this algorithm?
http://mathworld.wolfram.com/196-Algorithm.html
If you want big numbers, try
http://www.swox.com/gmp/
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
64-bit... ha ha ha.
196 has been brought to >270,000,000 digits.
You appear to want to solve it using 64-bit numbers... fat chance, mate.
Salem: the 196 problem only involves addition and (decimal) digit reversal. Addition is simple enough to implement on its own, and it would be cumbersome to constantly convert back-and-forth between binary and decimal if one were to use GMP. The crazy people who work on this apparently favour assembly though (ugh ).
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}