1 / 3
Feb 2016

I am new in SPOJ,
output of my code for character patterns (act 5) is same as expected output. but it is not accepting it.

n=int(raw_input())
a=list()
for i in range(n):
    a.append(raw_input().split())
l=("*",".")
m=("\\","/")
for i in range(n):
    for j in range(int(a[i][0])*(int(a[i][2])+1)+1):
        b=""
        for k in range(int(a[i][1])*(int(a[i][2])+1)+1):
            if (j%(int(a[i][2])+1))==0 or (k%(int(a[i][2])+1))==0:
                b+=l[0]
            elif ((j/(int(a[i][2])+1))+(k/(int(a[i][2])+1)))%2==0:
                if (j+k)%2==0:
                    b+=m[0]
                else:
                    b+=l[1]
            else:
                if (j+k)%2==0:
                    b+=m[1]
                else:
                    b+=l[1]
        print b
    if i!=n-1:
        print ""

PLease help me,
thanks in advance

  • created

    Feb '16
  • last reply

    Feb '16
  • 2

    replies

  • 861

    views

  • 2

    users

Look at your results for cell sizes greater than 2. eg this case

1
1 1 5

Your code produces a kind of hatchure, where the problom statement says "each of the grid elements will have a diagonal". I think it means exactly one diagonal per element. But I did not solve this problem, so I cannot be sure.