-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cboustro_1.py
53 lines (48 loc) · 1.45 KB
/
Cboustro_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 9 19:08:37 2013
@author: remy
"""
def changer(sens):
if sens == "gd":
return "dg"
if sens == "dg":
return "gd"
def tronq(texte,L):
i = 0
tronq = ""
while i < L :
tronq = tronq + texte[i]
i += 1
return tronq
def compl(texte,L):
l = len(texte)
for i in range(L -l):
texte = texte + " "
return texte
def boustro1(texte,p,q):
# tronquer ou compléter
if len(texte) < p*q:
texte = compl(texte,p*q)
else :
texte = tronq(texte,p*q)
#print(len(texte))
rep = ["" for j in range(q)]
i = 0
j = 0
sens = "gd"
for c in texte:
#print(i,j, rep[j],c)
if sens == "gd" :
rep[j] = rep[j] + c
if sens == "dg" :
rep[j] = c + rep[j]
i += 1
if i % p == 0 :
sens = changer(sens)
j += 1
return rep
texte = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
lili = boustro1(texte,30,10)
for i in range(10):
print(lili[i])