Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 837c8a3

Browse files
committed
Lv1 파이썬 완료
1 parent fc52f32 commit 837c8a3

37 files changed

+387
-0
lines changed

‎Programmers/Lv1/Lv1_2016년.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
def solution(a, b):
2+
answer = ''
3+
v = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
4+
index = 0
5+
if a == 1 or a == 4 or a == 7:
6+
index = 5
7+
elif a == 2 or a == 8:
8+
index = 1
9+
elif a == 3 or a == 11:
10+
index = 2
11+
elif a == 5:
12+
index = 0
13+
elif a == 6:
14+
index = 3
15+
elif a == 9 or a == 12:
16+
index = 4
17+
elif a == 10:
18+
index = 6
19+
20+
index += b % 7;
21+
if index > 6:
22+
index -= 7
23+
24+
if index == 0:
25+
index = 6
26+
else:
27+
index -= 1
28+
return v[index]
29+
30+
print(solution(5,24))

‎Programmers/Lv1/Lv1_K번째수.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def solution(array, commands):
2+
answer = []
3+
for i in commands:
4+
start, end, order = i
5+
answer.append(sorted(array[start-1:end])[order-1])
6+
return answer
7+
8+
array = [1, 5, 2, 6, 3, 7, 4]
9+
commands = [[2, 5, 3], [4, 4, 1], [1, 7, 3]]
10+
print(solution(array,commands))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def solution(x, n):
2+
answer = []
3+
for i in range(1,n+1):
4+
answer.append(x*i)
5+
return answer
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def solution(s):
2+
answer = ''
3+
if(len(s)%2==0): # 길이가 짝수
4+
cut = int(len(s)/2 -1)
5+
answer = s[cut:cut+2]
6+
else: # 길이가 홀수
7+
cut = int((len(s)-1) / 2)
8+
answer = s[cut:cut + 1]
9+
10+
return answer
11+
12+
print(solution("abcde"))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def solution(arr):
2+
answer = []
3+
prev = -1
4+
5+
for a in arr:
6+
if prev != a:
7+
answer.append(a)
8+
prev = a;
9+
return answer
10+
11+
print(solution([4,4,4,3,3]))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def solution(arr, divisor):
2+
answer = []
3+
arr.sort()
4+
for a in arr:
5+
if a%divisor==0:
6+
answer.append(a)
7+
if len(answer)==0:
8+
answer.append(-1)
9+
return answer
10+
11+
print(solution([3,2,6],10))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def solution(a, b):
2+
if a>b:
3+
return sum(range(b,a+1))
4+
else:
5+
return sum(range(a, b + 1))
6+
7+
print(solution(3,5))

‎Programmers/Lv1/Lv1_모의고사.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def solution(answers):
2+
result = []
3+
q1 = [1,2,3,4,5]
4+
q2 = [2,1,2,3,2,4,2,5]
5+
q3 = [3,3,1,1,2,2,4,4,5,5]
6+
score = [0]*3
7+
8+
for idx, ans in enumerate(answers):
9+
if ans == q1[idx%5]:
10+
score[0] += 1
11+
if ans == q2[idx%8]:
12+
score[1]+= 1
13+
if ans == q3[idx%10]:
14+
score[2]+= 1
15+
16+
for idx,s in enumerate(score):
17+
if s == max(score):
18+
result.append(idx+1)
19+
return result
20+
21+
answers = [1, 2, 3, 4, 5]
22+
print(solution(answers))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def solution(s):
2+
return s.lower().count('p') == s.lower().count('y')
3+
print(solution("Pyy"))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def solution(s):
2+
return "".join(sorted(s,reverse=True))
3+
print(solution("Zbcdefg"))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /