Skip to content

Instantly share code, notes, and snippets.

@gtsalles
Last active December 21, 2015 16:39
Show Gist options
  • Save gtsalles/6335247 to your computer and use it in GitHub Desktop.
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/
# -*- 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