forked from y-tetsu/math_puzzle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
q33.py
65 lines (46 loc) · 1011 Bytes
/
q33.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
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Q33
"""
import csv
import re
def dup(key, pattern):
"""
重複チェック
"""
count = 0
for i in pattern:
if re.match(key, i):
count += 1
if count > 1:
return True
return False
def countlen(array):
"""
最小文字数のカウント
"""
cnt = 0
for i in array:
index = 0
check = i[index]
while dup(check, array):
index += 1
check += i[index]
print(check, " : ", i)
cnt += len(check)
return cnt
def main():
"""
CSV読み込み
"""
csvfile = open('./q33.csv', 'r', encoding='utf-8')
reader = csv.reader(csvfile)
_ = next(reader) # ヘッダーを捨てる
kaminoku, simonoku = [], []
for row in reader:
kaminoku += [row[3]]
simonoku += [row[4]]
print(countlen(kaminoku) + countlen(simonoku))
if __name__ == "__main__":
main()