-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary.py
More file actions
55 lines (46 loc) · 1.32 KB
/
dictionary.py
File metadata and controls
55 lines (46 loc) · 1.32 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 9 08:16:07 2017
@author: suewoonryu
solution for : https://algospot.com/judge/problem/read/DICTIONARY
"""
import string
error = 'INVALID HYPOTHESIS'
class Dictionary(object):
def __init__(self):
self.alphabet=string.ascii_lowercase
self.newOrder={}
def find_newOrder(self, words):
for i in range(len(words)-1):
for j in range(len(words[i])) :
print('i: ',i,'j: ',j)
if words[i][j] != words[i+1][j]:
self.newOrder[words[i][j]]=[words[i+1][j]]
break
def is_aphabetical_order(self,char_list):
return sorted(char_list) == char_list
def return_newOrder(self):
'''
DFS이용
'''
for i in self.newOrder.keys():
if is_aphabetical_order(self.newOrder[i][0],self.newOrder[i][1]):
pass
else :
self.alphabet.remove()
d = Dictionary()
x=['gg',
'kia',
'lotte',
'lg',
'hanhw']
d.find_newOrder(x)
#if __name__ == "__main__":
# testcases = int(input())
# for i in range(testcases):
# d = Dictionary()
# n = int(input())
# words = []
# for j in range(n):
# words.append(str(input()))