Dojo Diamantes

By gt.salles on Jun 07, 2013

PUG-PI it's the Python User Group from the Brazilian State Piauí.
Together, we did a Dojo to solve this problem:
The problem consists in given an input (a char), the program print all the letters from the alphabet until we find the given letter and then all the way back, doing this like a diamond. Something like this:

Given D as input:

#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))
        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))
        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 in to comment.
ovelayer   -  Jun 08, 2013

pug-pi solution to the problem

im guessing it's games?
please translate in english and alittle more description would be nice :)

gt.salles  -  Jun 08, 2013

Sorry man, i'll do it.

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.