On Sep 13, 1:58 pm, Ketan Joshi <[email protected]> wrote:
> I used Perl. How do I find out how an integer is represented? (32bit vs
> 64bit)?
>
> Is the logic ok?
>

It is. I used the same logic, in python:
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys, psyco
psyco.full()
rdl = sys.stdin.readline

symbols = '1023456789abcdefghijklmnopqrstuvwxyz'

def process():
    """precessing case #"""
    code = rdl().replace('\n','')
    d = {}
    symbol = 0
    trans = ''
    for s in code:
        if not s in d:
            d[s] = symbols[symbol]
            symbol += 1
        trans += d[s]
    base = len(d) if len(d) > 1 else 2
    return int(trans, base)

cases = int(rdl())
for case in xrange(1, cases+1):
    print "Case #%d:"%case, process()

Cool thing in python is that int(string, base) does the conversion for
you :-)

--
http://e.nigma.be/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to