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.
This is a discussion on Can I make a DataType ? within the C++ Programming forums, part of the General Programming Boards category; to solve "algorithm 196" I want a new DataType(C++ Numeric) which can contain minimum 64 byte. Can it possible? I ...
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 05: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
If I have eight hours for cutting wood, I spend six sharpening my axe.
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.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
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;}