Last active
December 21, 2015 16:39
-
-
Save gtsalles/6335247 to your computer and use it in GitHub Desktop.
Solution of PUG-PI for the 'Quebra Linha' [1] problem. [1] http://dojopuzzles.com/problemas/exibe/quebra-de-linha/
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
# -*- coding: utf-8 -*- | |
texto = 'Um pequeno jabuti xereta viu dez cegonhas felizes.' | |
limite = 20 | |
cont_espacos = 0 | |
while len(texto) >20: | |
print "Tamanho String: ", len(texto) | |
if texto[19] != ' ': | |
for i in range(19,-1,-1): | |
if texto[i] == ' ': | |
print texto[0:i] | |
print "Tamanho String: ", i | |
texto = texto[i+1:] | |
break | |
else: | |
print texto[0:19] | |
texto = texto[20:] | |
print "Tamanho String: ", len(texto) | |
print texto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment