Ok, for those who have doubt why case #3 is not printed it is, just because 
3rd input does not contain a digit '4'.

I've modified the code to meet `T` constrain:
import sys
import re
import random


def missing_number(k, N):
    if not (1 < int(N) < 10**100):
        sys.exit()
    if '4' not in N:
        print()
        return
    pos = [i.start(0) for i in re.finditer('4', N)]
    inter_list = [i for i in N]
    for i in pos:
        inter_list[i] = str(random.randint(1, 3))
    val = int(''.join(inter_list))
    diff = int(N) - val
    print(f'Case #{k+1}:', diff, val)


t = int(input())
if not (1 <= t <= 100):
    sys.exit()

l = [input() for i in range(t)]
for t, N in enumerate(l):
    missing_number(t, N)

And here are some outputs:

1
4
Case #1: 3 1


4
1235
12345
1426434
13546

Case #2: 10 12335
Case #3: 200102 1226332
Case #4: 30 13516

141

Sombody please help.

On Thursday, April 2, 2020 at 9:30:01 AM UTC+5:30, joe733 wrote:
>
> *Here's my code:*
> import re
> import random
>
> def missing_number(k, N):
>     if not (1 < int(N) < 10**100) or '4' not in N:
>         print()
>         return
>     pos = [i.start(0) for i in re.finditer('4', N)]
>     inter_list = [i for i in N]
>     for i in pos:
>         inter_list[i] = str(random.randint(1, 3))
>     val = int(''.join(inter_list))
>     diff = int(N) - val
>     print(f'Case #{k+1}:', diff, val)
>
> t = int(input())
> l = [input() for i in range(t)]
>     
> for t, N in enumerate(l):
>     missing_number(t, N)
> *Output* (On my system)
> 3
> 414
> 12345678
> 123131231231312313
> Case #1: 203 211
> Case #2: 30000 12315678
>
>
> "If there are multiple solutions, you may output any one of them"
>>
>
> The answers are correct right....?
>
> Then why do I get a RE? How should I solve it?
>

-- 
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/e9ab02ab-2b0b-41c4-8b3e-31f766d2ece2%40googlegroups.com.

Reply via email to