-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputConverter.py
57 lines (40 loc) · 1.27 KB
/
inputConverter.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
def position(posi):
#Removing white spaces in the string
posi = posi.replace(" ","")
# Converting the string into list
list = posi.split(";")
# This list stores information in terms of rows.
rowList = []
# Function to split digit entries into rows. For example 24 into 8,8,8
def splitting(i):
j = int(i)
if j == 8:
rowList.append(str(j))
else:
rowList.append(str(8))
splitting(str(j - 8))
# Splitting into a list of rows
for i in list:
if i.isdigit():
splitting(i)
else:
rowList.append(i)
# This function takes a string and an empty string as input
# It returns the list with appropriate ' ' as required
def helper(str1,ch):
for j in str1:
if j.isdigit():
if int(j) == 0:
continue
elif int(j) == 1:
ch.append(' ')
else:
ch.append(' ')
helper(str(int(j) - 1),ch)
else:
ch.append(j)
return ch
List_Of_Lists = []
for k in range(8):
List_Of_Lists.append(helper(rowList[k],[]))
return List_Of_Lists