Skip to content

Commit 498b05b

Browse files
bspsoojinoh
authored andcommitted
fix .
1 parent e4c20f9 commit 498b05b

99 files changed

Lines changed: 1878 additions & 1878 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
File renamed without changes.
File renamed without changes.
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# 2. 직사각형 별찍기
2-
3-
n, m = map(int, input().strip().split(' '))
4-
5-
for i in range(m):
6-
for j in range(n):
7-
print('*', end = '')
8-
print()
9-
print()
10-
11-
answer = ('*' * n + '\n') * m
12-
print(answer)
13-
1+
# 2. 직사각형 별찍기
2+
3+
n, m = map(int, input().strip().split(' '))
4+
5+
for i in range(m):
6+
for j in range(n):
7+
print('*', end = '')
8+
print()
9+
print()
10+
11+
answer = ('*' * n + '\n') * m
12+
print(answer)
13+
File renamed without changes.
Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
# 19. 시저 암호
2-
3-
def solution(s, n):
4-
answer = ''
5-
6-
for char in s:
7-
if char.isalpha():
8-
if 65 <= ord(char) <= 90:
9-
if ord(char) + n > 90:
10-
answer += chr(ord(char) - 26 + n)
11-
else:
12-
answer += chr(ord(char) + n)
13-
else:
14-
if ord(char) + n > 122:
15-
answer += chr(ord(char) - 26 + n)
16-
else:
17-
answer += chr(ord(char) + n)
18-
else:
19-
answer += ' '
20-
return answer
21-
22-
s_1 = 'AB'
23-
s_2 = 'z'
24-
s_3 = 'a B z'
25-
26-
n_1 = 1
27-
n_2 = 1
28-
n_3 = 4
29-
30-
print(solution(s_1, n_1))
31-
print(solution(s_2, n_2))
32-
print(solution(s_3, n_3))
33-
34-
def solution_best(s, n):
35-
answer = ''
36-
str = list(s)
37-
for i in range(len(str)):
38-
if str[i].isupper():
39-
str[i] = chr((ord(str[i]) - ord('A') + n) % 26 + ord('A'))
40-
elif str[i].islower():
41-
str[i] = chr((ord(str[i]) - ord('a') + n) % 26 + ord('a'))
42-
43-
answer = ''.join(str)
44-
return answer
45-
46-
print(solution_best(s_1, n_1))
47-
print(solution_best(s_2, n_2))
48-
print(solution_best(s_3, n_3))
49-
# 틀린 풀이
50-
def solution_error(s, n):
51-
answer = ''
52-
53-
# string을 ascii로 바꾼 리스트
54-
str_ascii_lst = [ord(i) for i in s]
55-
# print(str_ascii_lst)
56-
57-
for idx, cost in enumerate(str_ascii_lst):
58-
if cost == 32:
59-
str_ascii_lst[idx] -= 4
60-
str_ascii_lst[idx] += n
61-
62-
# print(str_ascii_lst)
63-
for i in str_ascii_lst:
64-
idx = str_ascii_lst.index(i)
65-
if 90 < i and i < 97:
66-
rest = i - 90
67-
str_ascii_lst[idx] = 64 + rest
68-
elif 122 < i:
69-
rest = i - 122
70-
str_ascii_lst[idx] = 96 + rest
71-
72-
answer = ''.join(chr(i) for i in str_ascii_lst)
1+
# 19. 시저 암호
2+
3+
def solution(s, n):
4+
answer = ''
5+
6+
for char in s:
7+
if char.isalpha():
8+
if 65 <= ord(char) <= 90:
9+
if ord(char) + n > 90:
10+
answer += chr(ord(char) - 26 + n)
11+
else:
12+
answer += chr(ord(char) + n)
13+
else:
14+
if ord(char) + n > 122:
15+
answer += chr(ord(char) - 26 + n)
16+
else:
17+
answer += chr(ord(char) + n)
18+
else:
19+
answer += ' '
20+
return answer
21+
22+
s_1 = 'AB'
23+
s_2 = 'z'
24+
s_3 = 'a B z'
25+
26+
n_1 = 1
27+
n_2 = 1
28+
n_3 = 4
29+
30+
print(solution(s_1, n_1))
31+
print(solution(s_2, n_2))
32+
print(solution(s_3, n_3))
33+
34+
def solution_best(s, n):
35+
answer = ''
36+
str = list(s)
37+
for i in range(len(str)):
38+
if str[i].isupper():
39+
str[i] = chr((ord(str[i]) - ord('A') + n) % 26 + ord('A'))
40+
elif str[i].islower():
41+
str[i] = chr((ord(str[i]) - ord('a') + n) % 26 + ord('a'))
42+
43+
answer = ''.join(str)
44+
return answer
45+
46+
print(solution_best(s_1, n_1))
47+
print(solution_best(s_2, n_2))
48+
print(solution_best(s_3, n_3))
49+
# 틀린 풀이
50+
def solution_error(s, n):
51+
answer = ''
52+
53+
# string을 ascii로 바꾼 리스트
54+
str_ascii_lst = [ord(i) for i in s]
55+
# print(str_ascii_lst)
56+
57+
for idx, cost in enumerate(str_ascii_lst):
58+
if cost == 32:
59+
str_ascii_lst[idx] -= 4
60+
str_ascii_lst[idx] += n
61+
62+
# print(str_ascii_lst)
63+
for i in str_ascii_lst:
64+
idx = str_ascii_lst.index(i)
65+
if 90 < i and i < 97:
66+
rest = i - 90
67+
str_ascii_lst[idx] = 64 + rest
68+
elif 122 < i:
69+
rest = i - 122
70+
str_ascii_lst[idx] = 96 + rest
71+
72+
answer = ''.join(chr(i) for i in str_ascii_lst)
7373
return answer
Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
# 41. 삼진법 뒤집기
2-
3-
# 어디가 틀린거지??? 내 풀이 ㅠㅠ
4-
def solution(n):
5-
answer = 0
6-
7-
Ternary_str = ''
8-
while n > 0:
9-
Ternary_str += str(n % 3)
10-
n //= 3
11-
12-
cnt = 1
13-
for each_chr in reversed(Ternary_str):
14-
answer += cnt * int(each_chr)
15-
cnt *= 3
16-
17-
return answer
18-
19-
n_1 = 45
20-
n_2 = 125
21-
22-
print(solution(n_1))
23-
print(solution(n_2))
24-
25-
def solution_error(n):
26-
answer = 0
27-
28-
# 3진법 문자열 -> '1200'
29-
Ternary_str = ''
30-
31-
quota, rest = n // 3, n % 3
32-
Ternary_str += str(rest)
33-
34-
if n != 1:
35-
# 45 -> '1200' -> '0021'
36-
while quota > 3:
37-
rest = quota % 3
38-
quota //= 3
39-
Ternary_str += str(rest)
40-
Ternary_str += str(quota)
41-
42-
# 10진법 리스트 ... '0021' -> [0, 0, 2, 1]
43-
Decimal_lst = [int(i) for i in Ternary_str]
44-
45-
for i in range(len(Decimal_lst)):
46-
answer += Decimal_lst[i] * (3 ** (len(Decimal_lst) - i - 1))
47-
return answer
48-
49-
# print(solution_error(n_1))
1+
# 41. 삼진법 뒤집기
2+
3+
# 어디가 틀린거지??? 내 풀이 ㅠㅠ
4+
def solution(n):
5+
answer = 0
6+
7+
Ternary_str = ''
8+
while n > 0:
9+
Ternary_str += str(n % 3)
10+
n //= 3
11+
12+
cnt = 1
13+
for each_chr in reversed(Ternary_str):
14+
answer += cnt * int(each_chr)
15+
cnt *= 3
16+
17+
return answer
18+
19+
n_1 = 45
20+
n_2 = 125
21+
22+
print(solution(n_1))
23+
print(solution(n_2))
24+
25+
def solution_error(n):
26+
answer = 0
27+
28+
# 3진법 문자열 -> '1200'
29+
Ternary_str = ''
30+
31+
quota, rest = n // 3, n % 3
32+
Ternary_str += str(rest)
33+
34+
if n != 1:
35+
# 45 -> '1200' -> '0021'
36+
while quota > 3:
37+
rest = quota % 3
38+
quota //= 3
39+
Ternary_str += str(rest)
40+
Ternary_str += str(quota)
41+
42+
# 10진법 리스트 ... '0021' -> [0, 0, 2, 1]
43+
Decimal_lst = [int(i) for i in Ternary_str]
44+
45+
for i in range(len(Decimal_lst)):
46+
answer += Decimal_lst[i] * (3 ** (len(Decimal_lst) - i - 1))
47+
return answer
48+
49+
# print(solution_error(n_1))
5050
# print(solution_error(n_2))

0 commit comments

Comments
 (0)