-
Notifications
You must be signed in to change notification settings - Fork 1
[동원] kakao 인턴 코드리뷰 요청 #34
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
base: Dongwon
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| def solution(s): | ||
| result = s.lower() | ||
| num_dict = { | ||
| "zero": 0, | ||
| "one": 1, | ||
| "two": 2, | ||
| "three": 3, | ||
| "four": 4, | ||
| "five": 5, | ||
| "six": 6, | ||
| "seven": 7, | ||
| "eight": 8, | ||
| "nine": 9 | ||
| } | ||
| for key, value in num_dict.items(): | ||
| result = result.replace(key, str(value)) | ||
| return int(result) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| def solution(places): | ||
| result = [] | ||
| dx = [-2,-1,-1,-1,0,0,0,0,1,1,1,2] | ||
| dy = [0,-1,0,1,-2,-1,0,1,2,-1,0,1,0] | ||
| for place in places: | ||
| candiates = [] | ||
| wall_checklist = [] | ||
| for x in range(5): | ||
| for y in range(5): | ||
| cur_position = place[x][y] | ||
| if cur_position == "P": # 응시자 선출 | ||
| candiates.append((x,y)) | ||
| # 응시자들끼리 거리 비교 | ||
| break_point = False | ||
| for i in range(len(candiates)): | ||
| for j in range(i+1, len(candiates)): | ||
| manhaton_x = candiates[i][0] - candiates[j][0] | ||
| manhaton_y = candiates[i][1] - candiates[j][1] | ||
| manhaton = abs(manhaton_x) + abs(manhaton_y) | ||
| # 맨하탄 거리가 2이하일때 | ||
| if manhaton < 3: | ||
| if manhaton_x == 0: # x 값이 같을 때 | ||
| if place[candiates[i][0]][(candiates[i][1] + candiates[j][1]) // 2] != "X": | ||
| result.append(0) | ||
| break_point = True | ||
| break | ||
| elif manhaton_y == 0: # y 값이 같을 때 | ||
| if place[(candiates[i][0] + candiates[j][0]) // 2][candiates[i][1]] != "X": | ||
| result.append(0) | ||
| break_point = True | ||
| break | ||
| else: | ||
| # x,y 값이 다를 때 | ||
| if place[candiates[i][0]][candiates[j][1]] != "X" or place[candiates[j][0]][candiates[i][1]] != "X": | ||
| result.append(0) | ||
| break_point = True | ||
| break | ||
| if break_point: # 하나라도 맞으면 나머지는 볼 필요 없음. | ||
| break | ||
| else: # 거리두기 잘 지키고 있을 때 | ||
| result.append(1) | ||
| return result |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| def solution (n,k,cmd): | ||
| selected = k | ||
| stack = [] | ||
| board = [i+1 for i in range(n)] | ||
| arr = [1 for _ in range(n)] | ||
| for item in cmd: | ||
| # print(item) | ||
| # print(arr, selected, stack) | ||
| if len(item) == 3: | ||
|
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. 반례 찾아왔습니다 "U 14" 이런식으로도 들어올 수 있다고 하네요
Owner
Author
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. 아아 맞네요!! >= 바꾸니깐 정확성 다 맞습니다 진현님 짱 😍
Owner
Author
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. 효율성 5개까지 맞네요 ㅎㅎ |
||
| direction, score = item.split(" ") | ||
| temp = 0 | ||
| if direction == "U": | ||
| while temp < int(score) and selected >= 0: | ||
| selected -= 1 | ||
| temp += arr[selected] | ||
| else: | ||
| while temp < int(score) and selected <= n-1: | ||
| selected += 1 | ||
| temp += arr[selected] | ||
| else: | ||
| if item == "Z": | ||
| if stack: | ||
| garbage = stack.pop() | ||
| arr[garbage] = 1 | ||
| else: | ||
| arr[selected] = 0 | ||
| stack.append(selected) | ||
| if selected < n-1: | ||
| selected += 1 | ||
| while arr[selected] == 0: | ||
| selected += 1 | ||
| if arr[selected] != 0: | ||
|
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. while문 어차피 탈출해서 따로 조건 안줘도 되지 않을까요?
Owner
Author
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. 아하 if문은 필요없긴하네유,, |
||
| break | ||
| else: | ||
| selected -= 1 | ||
| while arr[selected] == 0: | ||
| selected -= 1 | ||
| if arr[selected] != 0: | ||
| break | ||
| # 기본은 +1 증가인데 다음 노드가 없으면 다음으로 맨 마지막 노드이면 그전 노드로 | ||
| return "".join(list(map(lambda x: "O" if x==1 else "X", arr))) | ||
|
|
||
|
|
||
| # 3차시도 | ||
| # 유사 링크드 리스트 시도 | ||
|
|
||
| def solution (n,k,cmd): | ||
| selected = k | ||
| stack = [] | ||
| board = {} | ||
| for i in range(n): | ||
| board[i] = i | ||
|
|
||
| arr = [1 for _ in range(n)] | ||
|
|
||
| for item in cmd: | ||
| if len(item) == 3: | ||
| direction, score = item.split(" ") | ||
| if direction == "U": | ||
| temp = selected - int(score) | ||
| if temp < 0: | ||
| temp = 0 | ||
| selected = board[temp] | ||
| else: | ||
| temp = selected + int(score) | ||
| if temp > n-1: | ||
| temp = n-1 | ||
| selected = board[temp] | ||
| else: | ||
| if item == "Z": | ||
| if stack: | ||
| garbage = stack.pop() | ||
| arr[garbage] = 1 | ||
| board[garbage] = garbage | ||
| else: | ||
| arr[selected] = 0 | ||
| stack.append(selected) | ||
| if selected < n-1: | ||
| board[selected] = board[selected+1] | ||
| selected = board[selected] | ||
| # board[i] = | ||
| else: | ||
| board[selected] = board[selected-1] | ||
| selected = board[selected] | ||
| # for i in range(n): | ||
| # if board[i] == board[selected]: | ||
| # board[selected] = i | ||
| # print(i) | ||
| # selected = i | ||
| print(item) | ||
| print(board, selected, stack) | ||
| return "".join(list(map(lambda x: "O" if x==1 else "X", arr))) | ||
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.
board 사용하는 구간이 없는거 같습니다
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.
앗 그렇네요ㅜㅜ 근데 저는 왜 안되는지가 궁금..
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.
저는 테스트 3개만 통과해서 왜그런지 모르겠네요....
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.
ㅋㅋㅋㅋ 저도 정확도 테스트는 대여섯개는 맞아요 ㅜㅜ 어렵군.. 오늘 이놈이다!