Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions SH_Noh/season3/CodingTest/Line/2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,32 @@
def filtering(k, dic, string):
if string in dic:
string = "#" * len(string)
if "." in string:
return string
# .이 대체할 수 있는 만큼 word에서 빼자
if "." in string: # ex) bad.ord
# .이 들어갈 수 있는 단어가 최대로 커버할 수 있는 길이
max_len = len(string) + string.count(".") * (k - 1) # 8
for word in dic:
for i in range(len(word)):
for j in range(len(string)):
if i == j:
pass
elif i == ".":
string[j] = word[i]
else:
continue
return string
# 커버할 수 없는 길이면 return
if len(word) > max_len:
return string
else:
for i in range(len(word)):
for j in range(max_len):
if word[i] == string[j]:
continue
if string[j] == ".":
string[j] = word[i]
else:
continue

def solution(k: int, dic: List[str], chat: str) -> str:
answer = ''
chat = chat.split(" ")
for i in range(len(chat)):
chat[i] = filtering(k, dic, chat[i])
return " ".join(chat)
return " ".join(chat)

# print(solution(2, ["slang", "badword"], "badword ab.cd bad.ord .word sl.. bad.word"))
print(solution(2, ["slang", "badword"], "bad.ord"))
# print(solution(3, ["abcde", "cdefg", "efgij"], ".. ab. cdefgh .gi. .z."))
print(solution(3, ["abcde", "cdefg", "efgij"], "ab."))
6 changes: 5 additions & 1 deletion SH_Noh/season3/CodingTest/Line/3.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ def solution(n: int, m: int, fires: List[List[int]], ices: List[List[int]]) -> L
# print(answer)
ices, answer = icing(ices, answer, n)
print(answer)
return answer
return answer

print(solution(3, 2, [[1, 1]], [[3, 3]]))
# [[2, 2, 0], [2, 1, -1], [0, -1, -1]]
print(solution(5, 3, [[5, 5], [1, 3], [5, 2]], [[1, 5], [3, 2]]))
37 changes: 37 additions & 0 deletions SH_Noh/season3/baekjoon/10/03-2/1107_리모컨.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# https://www.acmicpc.net/board/view/73355
from itertools import product
from sys import stdin
input = stdin.readline

# 현재 100번에서 시작
# 먼저 제일 가까운 숫자를 찾아야 함
def main():
channel_num = int(input())
broken = int(input())
length = len(str(channel_num))
if broken == 0:
print(min(length, abs(channel_num - 100)))
else:
# 일단 answer에 100번과의 차이를 저장
answer = abs(channel_num - 100) if channel_num != 100 else 0

broken_nums = set(input().split())
nums = set(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"])
normal_nums = nums - broken_nums

# 가능한 조합 중 원하는 채널보다 하나 작은 개수, 같은 개수, 하나 많은 개수의 길이인 경우 구하기
possible_nums = []
if length == 1:
for x in range(length, length + 2):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extend 신기하네요..! 파이썬 대단해..

possible_nums.extend(product(normal_nums, repeat = x))
else:
for x in range(length - 1, length + 2):
possible_nums.extend(product(normal_nums, repeat = x))

for y in possible_nums:
num = int("".join(y))
if abs(channel_num - num) + len(y) < answer:
answer = abs(channel_num - num) + len(y)
print(answer)

main()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쉽게 작성해주셔서 잘 읽을 수 있었습니다. :)

19 changes: 19 additions & 0 deletions SH_Noh/season3/baekjoon/10/03-2/9375_패션왕신해빈.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from sys import stdin
input = stdin.readline

T = int(input())
for _ in range(T):
clothes = int(input())
cloth_dict = {}
for _ in range(clothes):
cloth, type = input().split()
if type in cloth_dict:
cloth_dict[type] += 1
else:
cloth_dict[type] = 1
# 해당 종류를 입을지 안입을지 모든 경우의 수 곱하기
answer = 1
for type in cloth_dict:
answer *= cloth_dict[type] + 1
# 알몸이 되는 경우 빼기
print(answer - 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

풀이가 동일해요! 그래서 술술 읽혔습니다.
너무 늦은 리뷰 죄송합니다...😢