Aquí tienes sin ni un solo if.
Código Python:
Ver originalmaximo = int(raw_input("Tamanho maximo: "))
bars = []
for i in range(1, 5):
bars.append(int(raw_input("Tamanho de barra%d: " % i)))
print ""
print "El maximo alcance de la barra es:", maximo
def print_matrix(matrix):
for row in matrix:
print ''.join(row)
def border_matrix(matrix):
rows = len(matrix)
cols = len(matrix[0])
for i in range(rows):
matrix[i][0] = matrix[i][-1] = '+'
for j in range(cols):
matrix[0][j] = matrix[-1][j] = '+'
def put_bar(matrix, i, j):
for k in range(4):
matrix[i][j+k] = '-'
def draw_bars(matrix, bars):
rows = len(matrix)
for i, bar in enumerate(bars):
for c in range(bar):
put_bar(matrix, rows - 2 - c, 2 + (i * 5))
matrix =[list(' ' * 23) for i in range(maximo + 2)]
border_matrix(matrix)
draw_bars(matrix, bars)
print_matrix(matrix)