Programmers Lv.1 "숫자 문자열과 영단어"
사실 요 문제는 약간의 꼼수를 썼는데, 문제를 풀 당시 귀찮았는지 다른 알고리즘이 생각이 안났었다. 그래서 그냥 숫자와 영단어를 딕셔너리로 매칭해서 적어놓고 주어진 문자열 s에서 문자열로 된부분을 딕셔너리에서 뽑아서 치환시켰다. def solution(s): table = {"zero":"0","one":"1","two":"2","three":"3","four":"4","five":"5","six":"6","seven":"7","eight":"8","nine":"9"} for key in table: s = s.replace(key, table[key]) return int(s)