I used Perl. How do I find out how an integer is represented? (32bit vs 64bit)?
Is the logic ok? ~KeJo On Sun, Sep 13, 2009 at 5:24 PM, Luke Pebody <[email protected]> wrote: > > Maybe you were using a 32-bit integer? > > On Sun, Sep 13, 2009 at 12:51 PM, Ketan Joshi <[email protected]> > wrote: > > FYI, I have handled the special case where there is only one unique char > in > > the number. In that case I assign '1' to that char and return base as 2 > as > > there can not be unary numbers > > ~KeJo > > > > On Sun, Sep 13, 2009 at 5:20 PM, Ketan Joshi <[email protected]> > > wrote: > >> > >> Hi, > >> I used the below logic to solve this: > >> 1) find number of unique chars in the input number. This becomes the > base > >> in which it will have lowest value. > >> 2) assign '1' to first char > >> 3) assign '0' to second unique char that appears in the input num > >> 4) assign 2..base-1 to each unique char that appears in the input in the > >> increasing order > >> -- So cats becomes 1023 and zig becomes 102 > >> 5) result = 0; > >> for (i=0;i++;i<length of num){ > >> result = result * base + number representing char[i] > >> } > >> output result. > >> This logic worked fine for small input. But I got "incorrect" response > for > >> large input. > >> Can someone tell me if this logic is flawed in any sense? > >> Regards, > >> KeJo > >> -- > >> Blog: http://beingkejo.wordpress.com > > > > > > > > -- > > Blog: http://beingkejo.wordpress.com > > > > > > > > > > > -- Blog: http://beingkejo.wordpress.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-codejam" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-code?hl=en -~----------~----~----~----~------~----~------~--~---
