import re
def solution(s):
answer = []
lst = []
a = {}
for i in s.split("},"):
lst.append(re.sub("[{}]","", i))
lst.sort(key=lambda x: len(x))
["2","2,1","2,1,3","2,1,3,4"]
list(map(int, x))
메서드를 써봤지만 ,
때문에 처리 불가.,
를 제거해도 10의 자리 숫자가 1의 자리 숫자로 인식됨.def solution(s):
answer = []
s = s[:-2].replace('{','').replace(',',' ').split('}')
s = [i.split() for i in s]
s.sort(key=lambda x:len(x))
for tup in s:
diff = set(tup) - set(answer)
answer.append(list(diff)[0])
answer = [int(i) for i in answer]
return answer
import re
from collections import Counter
def solution(s):
s = Counter(re.findall('\d+', s))
return list(map(int, [k for k, v in sorted(s.items(), key=lambda x: x[1], reverse=True)]))
def solution(s):
answer = []
s1 = s.lstrip('{').rstrip('}').split('},{')
new_s = []
for i in s1:
new_s.append(i.split(','))
new_s.sort(key = len)
for i in new_s:
for j in range(len(i)):
if int(i[j]) not in answer:
answer.append(int(i[j]))
return answer
[참고 사이트]