Hmmm.. the extra outputs. You shouldn't print stuff like "Test data:". And
also the answer is followed by a bunch of new lines too. The gcj FAQ should
make it clearer to you.

On Thu, Apr 12, 2018, 10:19 Sahil Shetty <sahilshe...@gmail.com> wrote:

> def change(rcodeC, i):
>
>     holder = rcodeC[i + 1]
>     rcodeC[i + 1] = rcodeC[i]
>     rcodeC[i] = holder
>     return rcodeC
>
> def damage(rcodeD, dmg = 0, count = 0):
>
>     for i in rcodeD:
>
>         if i == 'S': dmg += 2 ** count
>         else: count += 1
>
>     return dmg
>
>
> def main(shield, rcode, hacks = 0, count = 0):
>
>     while damage(rcode) > shield:
>
>         for i in range(len(rcode) - 1):
>
>             try:
>
>                 if rcode[i] == 'C' and rcode[i + 1] != 'C':
>
>                     hacks += 1
>                     rcode = change(rcode, i)
>
>                 try:
>
>                     if all(e == 'C' for e in rcode[rcode.index('C'): -1])
> == True and damage(rcode) > shield: return 'IMPOSSIBLE'
>
>                 except ValueError:
>
>                     if all(e == 'S' for e in rcode[rcode.index('S'): -1])
> == True and damage(rcode) > shield: return 'IMPOSSIBLE'
>
>             except IndexError: None
>
>     return hacks
>
>
> test = int(raw_input("Test data: "))
> print '\n'
> while test < 1 or test > 100: test = int(raw_input("Between 1 and 100: "))
>
> for i in range(test):
>
>     shield = int(raw_input("Shield strength: "))
>     while shield < 1 or shield > (10 ** 9): shield =
> int(raw_input("Between 1 and 10^9: "))
>
>     rcode = raw_input("Robot code: ")
>     while all(i == 'C' or i == 'S' for i in rcode) != True or len(rcode) >
> 30 or len(rcode) < 2: rcode = raw_input("Must be greater than 2 and less
> than 1; only 'C' and 'S': ")
>
>
>     print 'Case #' + str(i + 1) + ':', main(shield, list(rcode)), '\n\n\n'
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-code+unsubscr...@googlegroups.com.
> To post to this group, send email to google-code@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/3ae54184-98c7-4e39-a095-cc45b5cd9b5d%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CANrP2_M2dCssu3F2q6pWLjbpbsHVawqjrtVJdOcCpr3oa2Ns6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to