๐ ๋ฌธ์ ๋งํฌ : programmers ์ง๊ฒ๋ค๋ฆฌ ๊ฑด๋๊ธฐ
๐ ์ด๊ธฐ ์ฝ๋
from collections import deque def solution(bridge_length, weight, truck_weights): total_length = deque([0] * bridge_length) queue = deque(truck_weights) time = 0 while queue: if sum(total_length) + queue[0] <= weight: total_length.popleft() total_length.append(queue.popleft()) time += 1 else: total_length.popleft() if sum(total_length) + queue[0] <= weight: total_length.append(queue.popleft()) else: total_length.append(0) time += 1 return time + len(total_length)
๐ ๊ณ ์น ์ฝ๋
from collections import deque def solution(bridge_length, weight, truck_weights): total_length = deque([0] * bridge_length) queue = deque(truck_weights) time = 0 total_sum = 0 while queue: if total_sum + queue[0] <= weight: left = total_length.popleft() right = queue.popleft() total_length.append(right) total_sum += right - left time += 1 else: temp = total_length.popleft() total_sum -= temp if total_sum + queue[0] <= weight: left = queue.popleft() total_length.append(left) total_sum += left else: total_length.append(0) time += 1 return time + len(total_length)
๐ git config --global --edit ๋ฅผ ์ ๋ ฅ
์์ ๊ฐ์ด ์ค์ python encoding ๋ถ๋ถ์ conda activate๊ฐ git bash์์๋ง ์คํ์ด ์๋ผ์ ๋ฃ์ด์ฃผ์ด๋ดค๋๋ฐ ์๋๋ค ์ ๊ธฐํ๊ฒ
PYTHONIOENCODING=utf8 conda activate "์ด๋ฆ"
๊ณผ ๊ฐ์ ์์ผ๋ก ํ๋ฉด ์คํ์ด ์ ๋๋๋ฐ vscode์์ ๋งค๋ฒ ์ ๋ ฅํ ์ ์๊ธฐ๋๋ฌธ์ ์ผ๋จ์ cmd๋ก conda๋ฅผ ๋๋ฆฌ๋ฉฐ ์ฌ์ฉ์ค์ด๋ค.
์ encoding ๋ถ๋ถ์ ๋ ์ฐพ์๋ด์ผ๊ฒ ๋ค ๋ช์๊ฐ ์ฐพ์๋ณด๋ค ๋๋ ค ์ณค๋๋ฐ ๋ค์ ๊ธฐ์ด์ด ๋๋ฉด ์ฐพ์๋ด์ผ๋ ๊ฒ ๊ฐ๋ค.
๐ conda ์ค์น ํ cmd ์ฐฝ ์ด๋ฆฌ์ง ์๋ ์ค๋ฅ
ํด๋น ์ค๋ฅ ํน์ง์ด powershell ์ ์ด๋ฆฌ๋๋ฐ cmd๊ฐ ์ด๋ฆฌ์ง ์๋ ๊ฒ์ด๋ค ์ด๋ด๋ powershell ์์ ์๋ ๋ช ๋ น์ด๋ง ์ ๋ ฅํด์ฃผ๋ฉด ๋๋ค.reg.exe DELETE "HKCU\Software\Microsoft\Command Processor" /v AutoRun /f