-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_v1.py
41 lines (35 loc) · 955 Bytes
/
test_v1.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
numRows = 5
s = "PAYPALISHIRING"
if len(s) == 1 or numRows == 1:
output = s
else:
l = [[] for _ in range(numRows)]
index = (numRows - 1) * 2
start = 0
output = ""
end = start + index
while len(s) > start:
if end > len(s):
end = len(s)
c = s[start:end]
start = end
end = start + index
ind = 0
for cha in c:
print(ind)
if ind > numRows - 1:
ind = ind - 1 if ind != numRows else ind -2
l[ind].append(cha)
ind -= 1
else:
l[ind].append(cha)
ind += 1
# for ind, cha in enumerate(c):
# if ind > numRows - 1:
# l[len(c) - ind].append(cha)
# else:
# l[ind].append(cha)
print(l)
for subset in l:
output += "".join(subset)
print(output)