Created
October 14, 2015 11:28
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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