[TIL_Carrotww] 25 - 22/10/06

์œ ํ˜•์„ยท2022๋…„ 10์›” 6์ผ
0

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
30/138
post-thumbnail

๐Ÿ“Carrotww์˜ ์ฝ”๋”ฉ ๊ธฐ๋ก์žฅ

๐Ÿงฒ ์•Œ๊ณ ๋ฆฌ์ฆ˜

๐Ÿ”— ๋ฌธ์ œ ๋งํฌ : 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 bash encoding ์„ค์ •

๐Ÿ” git config --global --edit ๋ฅผ ์ž…๋ ฅ

์œ„์™€ ๊ฐ™์ด ์„ค์ • python encoding ๋ถ€๋ถ„์€ conda activate๊ฐ€ git bash์—์„œ๋งŒ ์‹คํ–‰์ด ์•ˆ๋ผ์„œ ๋„ฃ์–ด์ฃผ์–ด๋ดค๋Š”๋ฐ ์•ˆ๋œ๋‹ค ์‹ ๊ธฐํ•˜๊ฒŒ
PYTHONIOENCODING=utf8 conda activate "์ด๋ฆ„"
๊ณผ ๊ฐ™์€ ์‹์œผ๋กœ ํ•˜๋ฉด ์‹คํ–‰์ด ์ž˜ ๋˜๋Š”๋ฐ vscode์—์„œ ๋งค๋ฒˆ ์ž…๋ ฅํ•  ์ˆ˜ ์—†๊ธฐ๋•Œ๋ฌธ์— ์ผ๋‹จ์€ cmd๋กœ conda๋ฅผ ๋Œ๋ฆฌ๋ฉฐ ์‚ฌ์šฉ์ค‘์ด๋‹ค.
์™œ encoding ๋ถ€๋ถ„์„ ๋” ์ฐพ์•„๋ด์•ผ๊ฒ ๋‹ค ๋ช‡์‹œ๊ฐ„ ์ฐพ์•„๋ณด๋‹ค ๋•Œ๋ ค ์ณค๋Š”๋ฐ ๋‹ค์‹œ ๊ธฐ์šด์ด ๋‚˜๋ฉด ์ฐพ์•„๋ด์•ผ๋  ๊ฒƒ ๊ฐ™๋‹ค.

๐Ÿงฒ Conda error

๐Ÿ” conda ์„ค์น˜ ํ›„ cmd ์ฐฝ ์—ด๋ฆฌ์ง€ ์•Š๋Š” ์˜ค๋ฅ˜
ํ•ด๋‹น ์˜ค๋ฅ˜ ํŠน์ง•์ด powershell ์€ ์—ด๋ฆฌ๋Š”๋ฐ cmd๊ฐ€ ์—ด๋ฆฌ์ง€ ์•Š๋Š” ๊ฒƒ์ด๋‹ค ์ด๋Ÿด๋•Œ powershell ์—์„œ ์•„๋ž˜ ๋ช…๋ น์–ด๋งŒ ์ž…๋ ฅํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

reg.exe DELETE "HKCU\Software\Microsoft\Command Processor" /v AutoRun /f

0๊ฐœ์˜ ๋Œ“๊ธ€