Skip to content

Instantly share code, notes, and snippets.

@gtsalles
Created October 14, 2015 11:28
Show Gist options
  • Save gtsalles/3905334dfea31dca1005 to your computer and use it in GitHub Desktop.
Save gtsalles/3905334dfea31dca1005 to your computer and use it in GitHub Desktop.
Solução do problema dos diamantes feita no primeiro encontro do Grupo de Usuários de Python do Piauí. http://dojopuzzles.com/problemas/exibe/diamantes/
#alfabeto = range(97,(97+26))
letra = raw_input("Insira o caractere: ")
i = ord(letra) - 65
aux = 0
for j in range(i, -1, -1):
if aux == 0:
print "%s%c"%(' '*j, chr(65))
else:
print "%s%c%s%c"%(' '*j, chr(65+aux),' '*((aux-1)*2+1),chr(65+aux))
aux += 1
aux -= 1
for j in range(1, i+1):
if chr(65+i-j) == 'A':
print "%s%c"%(' '*j, chr(65))
else:
print "%s%c%s%c"%(' '*j, chr(65+i-j),' '*((aux-1)*2-1),chr(65+i-j))
aux -= 1
#for i in range(65,(65+26)):
# alfabeto = alfabeto + chr(i)
#print alfabeto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment