-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix.py
More file actions
45 lines (34 loc) · 994 Bytes
/
Matrix.py
File metadata and controls
45 lines (34 loc) · 994 Bytes
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
from __future__ import print_function
import sys
import re
N, M = map(int, raw_input().split())
data = []
for d in range(N):
data.append(raw_input())
s = []
for j in range(M):
for i in range(N):
s += data[i][j]
s = ''.join(s)
#last = [m.end() for m in re.finditer(r'\w+',s)][-1]
last = [m.end() for m in re.finditer(r'\w+',s)]
def print_matrix(last):
last = last[-1]
s1 = s[:last]
s2 = s[last:]
s3 = re.split("([!,@,#,$,%,&, '', ' ']+)", s1)
s4 = filter(lambda (i,x) : i%2==0, enumerate(s3))
#s4 = filter(lambda i : i%2==0, range(len(s3)))
s5 = map(lambda (x,y) : y, s4)
sys.stdout.write(' '.join(s5) + s2)
g = [lambda: print_matrix(last), lambda: print(s)][len(last) == 0]
g()
# s1 = s[:last]
# s2 = s[last:]
#
# s3 = re.split("([!,@,#,$,%,&, '', ' ']+)", s1)
# s4 = filter(lambda (i,x) : i%2==0, enumerate(s3))
# #s4 = filter(lambda i : i%2==0, range(len(s3)))
# s5 = map(lambda (x,y) : y, s4)
#
# sys.stdout.write(' '.join(s5) + s2)