Skip to content

Commit 5803d15

Browse files
Add files via upload
1 parent f6aa022 commit 5803d15

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

Day9/ChangeStringToInteger.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 31. 문자열을 정수로 바꾸기
2+
3+
def solution(s):
4+
answer = ''
5+
6+
answer += s
7+
answer = int(answer)
8+
return answer
9+
10+
str_1 = '1234'
11+
str_2 = '-1234'
12+
13+
print(solution(str_1))
14+
print(solution(str_2))

Day9/FindMrKimInSeoul.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# 17. 서울에서 김서방 찾기
2+
3+
def solution(seoul):
4+
answer = ''
5+
6+
for i in range(len(seoul)):
7+
if seoul[i] == 'Kim':
8+
answer += '김서방은 ' + str(i) + '에 있다'
9+
10+
return answer
11+
12+
seoul_1 = ['Jane', 'Kim']
13+
print(solution(seoul_1))
14+
15+
def solution_best(seoul):
16+
answer = '김서방은 {}에 있다'.format(seoul.index('Kim'))
17+
18+
return answer
19+
20+
print(solution_best(seoul_1))

Day9/SooBakSooBakSooBak.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# 18. 수박수박수박수박수박수?
2+
3+
def solution(n):
4+
answer = ''
5+
6+
if n == 1:
7+
answer = '수'
8+
elif n == 2:
9+
answer = '수박'
10+
else:
11+
answer += '수박'
12+
if n % 2 == 0:
13+
answer += (n // 2 - 1) * '수박'
14+
else:
15+
answer += (n // 2 - 1) * '수박' + '수'
16+
17+
return answer
18+
19+
n_1 = 3
20+
n_2 = 4
21+
22+
print(solution(n_1))
23+
print(solution(n_2))
24+
25+
def solution_best(n):
26+
answer = '수박' * n
27+
28+
return answer[:n]
29+
30+
print(solution_best(n_1))
31+
print(solution_best(n_2))

0 commit comments

Comments
 (0)