Empece por está vía:
Código Python:
Ver original
for i in range(t): a = raw_input().split() l = int(a[0]) c = int(a[1]) s = int(a[2]) M = (s+1)* l +1 N = (s+1)*c + 1 Matrix = [[' ' for x in range(N)] for x in range(M)] for z in range(N): Matrix[0][z] = '*' for i in range( 1, M ): Matrix[i][0] = '*' for j in range( 1, N ): ( m_i, m_j ) = ( (i-1)/(s+1) , (j+1)/(s+1) ) ( k , l ) = ( i - 1 + (s+1)*m_i , j - 1 + (s+1)*m_j ) palito = '\\' if m_i % 2 and m_j % 2 == 0: palito = '/' elif m_i%2 == 0 and m_j%2: palito = '/' if j == N-1: Matrix[i][j] = '*' # Ya sabemos pa onde va palito if palito == '\\': if j == N-1: Matrix[i][j] = '*' else: if k == l: Matrix[i][j] = palito else: Matrix[i][j] = '.' else: if k == l: Matrix[i][j] = palito else: Matrix[i][j] = '.' for a in Matrix: # for b in a: # c = map(int, b) print a
Pero luego preferi hacerlo de esta forma:
Código Python:
Ver original
t = input() for i in range(t): a = raw_input().split() l = int(a[0]) c = int(a[1]) s = int(a[2]) #M = (s+1) N = (s+1)*c + 1 result = '' tapa = (s+1)*c*'*'+'*' for y in range(l): print tapa for i in range(1,s+1): start = 1 result += '*' for j in range(1,N-1): ( m_i, m_j ) = ( (i+1)/(s+1) , (j+1)/(s+1) ) ( k , l ) = ( i - 1 + (s+1)*m_i , j - 1 + (s+1)*m_j ) if y % 2 == 0: if k ==l: if start == 1: palito = '\\' start = 0 else: palito = '/' start = 1 result += palito else: result += '.' else: if k ==l: if start == 1: palito = '/' start = 0 else: palito = '\\' start = 1 result += palito else: result += '.' result += '*' print result result = '' print tapa
En el último lo que me falta es el orden cuando es '/' que el orden al contrario de la primera fila.
Gracias los que puedan ayudarme.
Saludos