-
Notifications
You must be signed in to change notification settings - Fork 9
[노유빈]_17주차_과제제출 #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
YOOBINNOH
wants to merge
14
commits into
kth990303:main
Choose a base branch
from
YOOBINNOH:YOOBINNOH-patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[노유빈]_17주차_과제제출 #119
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
71cd490
(P)17659
YOOBINNOH 73749c8
(P)72412 , 2146
YOOBINNOH 4cd5881
2146,(P)72412
YOOBINNOH 42e0666
Merge branch 'main' of https://github.com/YOOBINNOH/BojCodingTestStudy
YOOBINNOH 3c91574
every file
YOOBINNOH b81a16f
Merge branch 'main' of https://github.com/YOOBINNOH/BojCodingTestStudy
YOOBINNOH 59c3268
2 files
YOOBINNOH 094799c
2 files
YOOBINNOH 1ee399b
Merge branch 'kth990303:main' into main
YOOBINNOH 74b9928
[노유빈]16주차 과제 제출
YOOBINNOH 736ca80
[노유빈] 16주차 final
YOOBINNOH 35a89e1
Merge branch 'kth990303:main' into main
YOOBINNOH 5c3664b
17주차 과제
YOOBINNOH 7ef2cef
[노유빈]_17주차_과제제출
YOOBINNOH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | ||
|
|
||
| # 각 섬 별 숫자를 다르게 표기하기 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| def solution(places): | ||
| answer = [] | ||
|
|
||
| # 각 고사장 별 사람 위치 리스트 | ||
|
|
||
| one = [] | ||
| two = [] | ||
| three = [] | ||
| four = [] | ||
| five = [] | ||
| # 실패. 사람들 위치, 파티션 위치를 좌표로 구했지만 그 이후 방법을 모르겠음. | ||
|
|
||
|
|
||
| # 각 고사장 별 파티션 위치 리스트 | ||
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # 좌표 별로 두가지의 기준으로 나누어서 거리를 계산하는 방식으로 했지만 실패했다. | ||
|
|
||
|
|
||
| import math | ||
|
|
||
| # 좌표 거리 계산 함수 | ||
|
|
||
| def distance(key_loc): | ||
|
|
||
| key_dis_1 = [] | ||
| for i in range(0,len(key_loc)-1): | ||
| for j in range(i+1,len(key_loc)): | ||
| key_dis_1.append((key_loc[i][0]-key_loc[j][0])**2+(key_loc[i][1]-key_loc[j][1])**2) | ||
|
|
||
| return key_dis_1 | ||
|
|
||
|
|
||
| def solution(key, lock): | ||
| answer = True | ||
|
|
||
| # key : 1 , lock : 0 이 만나야 함 | ||
|
|
||
| # key, lock 좌표 리스트 | ||
|
|
||
| key_loc_1 = [ ] | ||
| lock_loc_1 = [ ] | ||
|
|
||
| key_loc_2 = [ ] | ||
| lock_loc_2 = [ ] | ||
|
|
||
|
|
||
|
|
||
|
|
||
| # key_loc 들에 대입 | ||
|
|
||
| for i in range(0,len(key)): | ||
| for j in range(0,len(key[0])): | ||
| if key[i][j] == 1 and i>=j: | ||
| key_loc_1.append([i,j]) | ||
| if key[i][j] == 1 and i<j: | ||
| key_loc_2.append([i,j]) | ||
|
|
||
| # lock_loc 들에 대입 | ||
|
|
||
| for i in range(0,len(lock)): | ||
| for j in range(0,len(lock[0])): | ||
| if lock[i][j] == 0 and i>=j: | ||
| lock_loc_1.append([i,j]) | ||
| if lock[i][j] == 0 and i<j: | ||
| lock_loc_2.append([i,j]) | ||
|
|
||
|
|
||
| # key, lock 좌표들의 거리 리스트 | ||
|
|
||
| key_dis_1 = distance(key_loc_1) | ||
| lock_dis_1 = distance(lock_loc_1) | ||
|
|
||
| key_dis_2 = distance(key_loc_2) | ||
| lock_dis_2 = distance(lock_loc_2) | ||
|
|
||
|
|
||
|
|
||
| for i in lock_dis_1: | ||
| if i not in key_dis_1: | ||
| return False | ||
|
|
||
| for i in lock_dis_2: | ||
| if i not in key_dis_2: | ||
| return False | ||
|
|
||
|
|
||
| return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # 좌표 별로 두가지의 기준으로 나누어서 거리를 계산하는 방식으로 했지만 실패했다. | ||
|
|
||
|
|
||
| import math | ||
|
|
||
| # 좌표 거리 계산 함수 | ||
|
|
||
| def distance(key_loc): | ||
|
|
||
| key_dis_1 = [] | ||
| for i in range(0,len(key_loc)-1): | ||
| for j in range(i+1,len(key_loc)): | ||
| key_dis_1.append((key_loc[i][0]-key_loc[j][0])**2+(key_loc[i][1]-key_loc[j][1])**2) | ||
|
|
||
| return key_dis_1 | ||
|
|
||
|
|
||
| def solution(key, lock): | ||
| answer = True | ||
|
|
||
| # key : 1 , lock : 0 이 만나야 함 | ||
|
|
||
| # key, lock 좌표 리스트 | ||
|
|
||
| key_loc_1 = [ ] | ||
| lock_loc_1 = [ ] | ||
|
|
||
| key_loc_2 = [ ] | ||
| lock_loc_2 = [ ] | ||
|
|
||
|
|
||
|
|
||
|
|
||
| # key_loc 들에 대입 | ||
|
|
||
| for i in range(0,len(key)): | ||
| for j in range(0,len(key[0])): | ||
| if key[i][j] == 1 and i>=j: | ||
| key_loc_1.append([i,j]) | ||
| if key[i][j] == 1 and i<j: | ||
| key_loc_2.append([i,j]) | ||
|
|
||
| # lock_loc 들에 대입 | ||
|
|
||
| for i in range(0,len(lock)): | ||
| for j in range(0,len(lock[0])): | ||
| if lock[i][j] == 0 and i>=j: | ||
| lock_loc_1.append([i,j]) | ||
| if lock[i][j] == 0 and i<j: | ||
| lock_loc_2.append([i,j]) | ||
|
|
||
|
|
||
| # key, lock 좌표들의 거리 리스트 | ||
|
|
||
| key_dis_1 = distance(key_loc_1) | ||
| lock_dis_1 = distance(lock_loc_1) | ||
|
|
||
| key_dis_2 = distance(key_loc_2) | ||
| lock_dis_2 = distance(lock_loc_2) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 거리 리스트 체크 굿굿 👍 |
||
|
|
||
|
|
||
|
|
||
| for i in lock_dis_1: | ||
| if i not in key_dis_1: | ||
| return False | ||
|
|
||
| for i in lock_dis_2: | ||
| if i not in key_dis_2: | ||
| return False | ||
|
|
||
|
|
||
| return True | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
15주차부터 17주차까지 한 PR에 다 올라왔네요! 이런..