5 / 5
Sep 2016
def act1(row, col):
    for x in range(1,row+1):
        if x % 2 == 1:
            first = '*'
            second = '.'
        else:
            first = '.'
            second = '*'

        result = ''
        net = first

        for y in range(1,col+1):
            result += net
            if net == first:
                net = second
            else:
                net = first

        print(result)

cases = int(input())
for each in range(1,cases+1):
    case = input()
    act1(int(case[0]), int(case[2]))
    if each < cases:
        print()

The above code runs fine in pycharm and ideone but spoj gives runtime error. Help me find the mistakes.

  • created

    Sep '16
  • last reply

    Sep '16
  • 4

    replies

  • 808

    views

  • 2

    users

  • 1

    like

Think about the full range of valid testcase, epecially maximum cases. You will have to "enhance" your input processing to be able to support these. Hint: The split() function is very helpful in cases like this

I didn't get it, can you please explain in detail?

What do you think is the result of this expression if the input is something like

1
11 22