HI, there I didn't actually understand your message, but I'll share my code
I hope It'll explain.
def para(list):
ans = ""
for i in range(len(list)):
if i==0:
ans+="("*int(list[i][0])
else:
if int(list[i][0])>int(list[i-1][0]):
ans+="("*(int(list[i][0])-int(list[i-1][0]))
else:
ans+= ")"*(int(list[i-1][0])-int(list[i][0]))
ans+=list[i]
ans+=")"*int(list[-1][0])
return ans
T = int(input())
for x in range(T):
S = input()
word = ""
w = []
for y in range(len(S)):
word+=S[y]
if y == len(S)-1:
break
elif S[y]==S[y+1]:
continue
else:
w.append(word)
word = ""
w.append(word)
print("Case #{}: {}".format(x+1,para(w)))
On Sun, Apr 25, 2021 at 8:58 PM Neil Agarwal <[email protected]>
wrote:
> Hi all,
>
> Could someone please explain to me the output of the following Perl code
> in Code Jam's test run mode? The system gives "BCD" instead of "ABCD",
> and I have not been able to reproduce this behavior anywhere else.
>
> $S1 = "1((((((7(9))))))";
> $S2 = "1((((((7(9)))))";
>
> print "A" if $S1 =~ /[89]+/;
> print "B" if $S1 =~ /[9]+/;
> print "C" if $S2 =~ /[89]+/;
> print "D" if $S2 =~ /[9]+/;
>
> FWIW, I was having trouble getting my solution to the "Nesting Depth"
> problem from the 2020 Qualification Round accepted, and eventually narrowed
> it down to this.
>
>
> https://codingcompetitions.withgoogle.com/codejam/round/000000000019fd27/0000000000209a9f
>
> Thank you!
>
> Neil
>
> --
> -- You received this message because you are subscribed to the Google
> Groups Code Jam 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 https://groups.google.com/d/forum/google-code?hl=en
> ---
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/155d7fef-6996-4260-92c4-02c96380cdc4n%40googlegroups.com
> <https://groups.google.com/d/msgid/google-code/155d7fef-6996-4260-92c4-02c96380cdc4n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
-- You received this message because you are subscribed to the Google Groups
Code Jam 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
https://groups.google.com/d/forum/google-code?hl=en
---
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/CADsNCNkY4xGugOEGrEzJhBtaBz%3DzKT80O6UouJy-FUG75U%3DesQ%40mail.gmail.com.