Skip to content
89 changes: 89 additions & 0 deletions 15주차/(P)72412/(P)72412_python_노유빈.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

# 정확성은 통과했지만 효율성을 통과하지 못했다.



# 리스트 a,b 비교 함수 (Score 제외, 조건이 일치하는 않는 것이 하나라도 있으면 False 반환 )

def compare(a,b):
for i in range(0,len(b)):
if b[i] not in a:
return False

return True


# Score 비교 함수

def score_compare(a,b):
a_score = ""
b_score = ""

for i in range(0,len(a)):
if a[i].isdigit()==True:
a_score+=a[i]

for i in range(0,len(b)):
if b[i].isdigit()==True:
b_score+=b[i]

return int(a_score)>=int(b_score)




def solution(info, query):
answer = 0

ans = []

# 2차원 리스트 초기화

a = [[]*2 for i in range(len(query))]


# query의 각 항목들을 추출해서 리스트 a에 넣기

for i in range(len(query)):
if "cpp" in query[i]:
a[i].append("cpp")

if "java" in query[i]:
a[i].append("java")

if "python" in query[i]:
a[i].append("python")

if "backend" in query[i]:
a[i].append("backend")

if "frontend" in query[i]:
a[i].append("frontend")

if "junior" in query[i]:
a[i].append("junior")

if "senior" in query[i]:
a[i].append("senior")

if "chicken" in query[i]:
a[i].append("chicken")

if "pizza" in query[i]:
a[i].append("pizza")



# compare 함수를 이용해서 조건에 맞는 answer 개수 세기

for i in range(0,len(a)):
for j in range(0,len(info)):
if compare(info[j],a[i])==True and score_compare(info[j],query[i])==True:
answer+=1
ans.append(answer)
answer=0




return ans
13 changes: 13 additions & 0 deletions 15주차/2146/2146_python_노유빈.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 잘 모르겠다..



# 첫 줄에는 지도의 크기 N(100이하의 자연수)가 주어진다.
# 그 다음 N줄에는 N개의 숫자가 빈칸을 사이에 두고 주어지며, 0은 바다, 1은 육지를 나타낸다.
# 항상 두 개 이상의 섬이 있는 데이터만 입력으로 주어진다.


N = int(input())
map = input()

# 각 섬 별 숫자를 다르게 표기하기
62 changes: 62 additions & 0 deletions 16주차/(P)17677/(P)17677_python_노유빈.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
def solution(str1, str2):

answer = 0

# 알파벳 리스트
m = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
Copy link
Collaborator

Choose a reason for hiding this comment

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

import string
string.ascii_lowercase

를 사용하면 알파벳 소문자를 모두 불러올 수 있습니다.


# 각 문자열 소문자로 변환 후 리스트에 담기
a = list(str1.lower())
b = list(str2.lower())
Comment on lines +9 to +10
Copy link
Collaborator

Choose a reason for hiding this comment

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

따로 a, b 원소를 변경하지 않으므로, 리스트에 담을 이유가 없어 보입니다. 그냥 str 형태로 해도 돼요!


# 조건 만족하는 값들만 담을 리스트 생성
final_a = [ ]
final_b = [ ]

# a 에서 조건 만족 하는 값들만 final에 담기

for i in range(0,len(a)-1):
if a[i] in m and a[i+1] in m:
Copy link
Collaborator

Choose a reason for hiding this comment

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

a[i:i+2].isalpha()라는 함수로 해당 str가 알파벳으로만 이루어졌는지 확인할 수 있습니다. 그럼 m 배열도 필요없어요!

final_a.append(a[i]+a[i+1])

# b 에서 조건 만족 하는 값들만 final에 담기

for i in range(0,len(b)-1):
if b[i] in m and b[i+1] in m:
final_b.append(b[i]+b[i+1])

inter = [ ] # 교집합
outer = final_a+final_b # 합집합
Comment on lines +28 to +29
Copy link
Collaborator

Choose a reason for hiding this comment

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

집합을 사용하고자 한다면 set을 사용하는 게 바람직합니다. 직접 하나하나 합/교집합을 구하지 않고, set 자체로 &(and) |(or) 연산을 통해 구할 수 있어요

outer = list(set(outer))

final_inter = [ ]
final_outer = [ ]



# 일반 교집합 구하기

for i in range(0,len(final_a)):
if final_a[i] in final_b:
inter.append(final_a[i])

# 일반 교집합 중복 제거

inter = list(set(inter))

# 자카드 교집합 구하기

for i in range(0,len(inter)):
for j in range(min(final_a.count(inter[i]),final_b.count(inter[i]))):
final_inter.append(inter[i])



for i in range(0,len(outer)):
for j in range(max(final_a.count(outer[i]),final_b.count(outer[i]))):
final_outer.append(outer[i])
Comment on lines +49 to +57
Copy link
Collaborator

Choose a reason for hiding this comment

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

리스트에 추가하고 길이를 구할 수도 있지만 카운트하는 방법을 써도 될 것 같아요!


if len(final_outer)==0:
return 65536

return int((len(final_inter)/len(final_outer))*65536)
62 changes: 62 additions & 0 deletions 16주차/(P)17677/(P)17677_python_노유빈.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
def solution(str1, str2):

answer = 0

# 알파벳 리스트
m = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

# 각 문자열 소문자로 변환 후 리스트에 담기
a = list(str1.lower())
b = list(str2.lower())

# 조건 만족하는 값들만 담을 리스트 생성
final_a = [ ]
final_b = [ ]

# a 에서 조건 만족 하는 값들만 final에 담기

for i in range(0,len(a)-1):
if a[i] in m and a[i+1] in m:
final_a.append(a[i]+a[i+1])

# b 에서 조건 만족 하는 값들만 final에 담기

for i in range(0,len(b)-1):
if b[i] in m and b[i+1] in m:
final_b.append(b[i]+b[i+1])

inter = [ ] # 교집합
outer = final_a+final_b # 합집합
outer = list(set(outer))

final_inter = [ ]
final_outer = [ ]



# 일반 교집합 구하기

for i in range(0,len(final_a)):
if final_a[i] in final_b:
inter.append(final_a[i])

# 일반 교집합 중복 제거

inter = list(set(inter))

# 자카드 교집합 구하기

for i in range(0,len(inter)):
for j in range(min(final_a.count(inter[i]),final_b.count(inter[i]))):
final_inter.append(inter[i])



for i in range(0,len(outer)):
for j in range(max(final_a.count(outer[i]),final_b.count(outer[i]))):
final_outer.append(outer[i])

if len(final_outer)==0:
return 65536

return int((len(final_inter)/len(final_outer))*65536)
83 changes: 83 additions & 0 deletions 16주차/(P)17677/(P)81302_python_노유빈.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
def solution(places):
answer = []

# 각 고사장 별 사람 위치 리스트

one = []
two = []
three = []
four = []
five = []
# 실패. 사람들 위치, 파티션 위치를 좌표로 구했지만 그 이후 방법을 모르겠음.
Copy link
Collaborator

Choose a reason for hiding this comment

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

저는 이 문제를 보고 제일 먼저 BFS / DFS가 떠올랐어요. 격자판에서 상하좌우로 움직이며 빈 칸/벽을 찾아 채워나가는 데에는 BFS / DFS가 사용됩니다. 한 번 찾아서 적용해 보세요!



# 각 고사장 별 파티션 위치 리스트
one_p = []
two_p = []
three_p = []
four_p = []
five_p = []


# places[0] 의 사람, 파티션 좌표 구하기

a = places[0]

for i in range(0,5):
b = list(a[i])
for j in range(0,5):
if b[j]=='P':
one.append([i,j])
if b[j]=='X':
one_p.append([i,j])

# places[1] 의 사람, 파티션 좌표 구하기

c = places[0]

for i in range(0,5):
d = list(c[i])
for j in range(0,5):
if d[j]=='P':
two.append([i,j])
if d[j]=='X':
two_p.append([i,j])

# places[2] 의 사람, 파티션 좌표 구하기

e = places[0]

for i in range(0,5):
f = list(e[i])
for j in range(0,5):
if f[j]=='P':
three.append([i,j])
if f[j]=='X':
three_p.append([i,j])


# places[3] 의 사람, 파티션 좌표 구하기

g = places[0]

for i in range(0,5):
h = list(g[i])
for j in range(0,5):
if h[j]=='P':
four.append([i,j])
if h[j]=='X':
four_p.append([i,j])

# places[4] 의 사람, 파티션 좌표 구하기

q = places[0]

for i in range(0,5):
w = list(q[i])
for j in range(0,5):
if w[j]=='P':
five.append([i,j])
if w[j]=='X':
five_p.append([i,j])

return four_p
Loading