못풀었음 - 나중에 다시 풀자
- 정답 및 해설 코드1 : https://hae-sooo97.tistory.com/44
- 정답 및 해설 코드2 : https://jennnn.tistory.com/60
[나의 경우]
[정답 경우]
숫자 버튼은 0~9
버튼은 + -
채널 0 ~ 무한대 (0에서 -하면 0)
현재 채널은 100, 이동할 채널은 n -> 최소 몇 번 눌러?
고장난 버튼이 m개 주어짐
일단 디폴트로 수행해둘것
프로세스 어케하냐
# 2차 작성
from itertools import permutations
n = str(5457)
#n = str(10)
not_button = [6,7,8]
button = [i for i in range(10)]
for i in not_button:
if i in button:
button.pop(button.index(i))
ans = []
nn_list = []
for j in range(1, len(button)):
for remote in permutations(button, j):
if remote[0] == 0: continue # 0으로 시작하는 경우는 패스
# 모든 경우의 수로 찾기 가능한 경우
tmp = "".join(map(str,list(remote)))
if tmp == n:
ans.append(len(tmp))
break
else:
nn_list.append(tmp)
# 모든 경우의 수에 포함 안되었을 때, + - 로 찾는 경우
for candi in nn_list:
tmp_plus = len(candi)
while int(candi) < int(n):
candi = str(int(candi) + 1) # "+" 버튼
tmp_plus = tmp_plus + 1 # + 누른 횟수 추가
if candi == n:
#print(tmp, " ", tmp_plus-1)
ans.append(tmp_plus)
break
#print(ans)
print(min(ans))