Saturday, April 9, 2022

📑 Punched Cards 2

Codejam Qualification Round 2022. Task 1 Variant 2

Python Only

def gen_table(r,c):
    for i in range(2*r+1):
        for j in range(2*c+1):
            if (i < 2 and j < 2):
                yield '.'
            else:
                el=((j+1)%2)*((i+1)%2)*'+'+\
                   (j%2)*((i+1)%2)*'-'+\
                   ((j+1)%2)*(i%2)*'|'+\
                   (j%2)*(i%2)*'.'
                yield el
        yield '\n'
T=int(input())
for t in range(T):
    N=input()
    [R,C]=[int(n) for n in N.split()]
    gen=gen_table(R,C)
    print('Case #{}:'.format(t+1))
    print(''.join(gen))


No comments:

Post a Comment