Thread: Can I make a DataType ?

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    1

    Can I make a DataType ?

    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

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    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

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.

  4. #4
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    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;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 09:51 PM
  2. "Cannot make pipe"
    By crepincdotcom in forum C Programming
    Replies: 5
    Last Post: 08-16-2004, 12:43 PM
  3. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  4. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 01:05 PM
  5. Replies: 6
    Last Post: 04-20-2002, 06:35 PM