문제📖
풀이🙏
while 반복문
+ if 조건문
+ 증감표현식
으로 구현한다.코드💻
import sys
visit_list = list(map(int,sys.stdin.readline().split()))
cnt = 1
while True:
if cnt%visit_list[0]==0 and cnt%visit_list[1]==0 and cnt%visit_list[2]==0:
print(cnt)
break
cnt += 1
결과😎
출처📝
https://codeup.kr/problem.php?id=6091
문제📖
풀이🙏
이중 for문
+ if 조건문
을 활용하여 구현하였다.코드💻
import sys
n = int(sys.stdin.readline())
bunho_list = list(map(int,sys.stdin.readline().split()))
num_list = [i for i in range(1,23+1)]
result = [0 for i in range(1,23+1)]
for i in num_list:
for j in bunho_list:
if i == j:
result[i-1] += 1
print(" ".join(map(str,result)))
결과😎
출처📝
https://codeup.kr/problem.php?id=6092
문제📖
풀이🙏
list
로 받는다.list
인 k를 reverse()
함수를 이용해 list
요소의 순서를 반전시킨다.코드💻
import sys
n = int(sys.stdin.readline())
k = list(map(int,sys.stdin.readline().split()))
k.reverse()
print(" ".join(map(str,k)))
결과😎
출처📝
https://codeup.kr/problem.php?id=6093
문제📖
풀이🙏
min()
함수를 이용하면 list
내의 최솟값을 반환한다.코드💻
import sys
n = int(sys.stdin.readline())
k = list(map(int,sys.stdin.readline().split()))
print(min(k))
결과😎
출처📝
https://codeup.kr/problem.php?id=6094
문제📖
풀이🙏
list
중복제거를 위해 list
를 tuple
로 변환시킨 후 OrderedDict
모듈의 fromkeys
함수로 중복제거를 한다.코드💻
import sys
from collections import OrderedDict
n = int(input())
baduk = [[0 for j in range(1,20)] for i in range(1,20)]
x_y = []
cnt = 0
for _ in range(n):
location = list(map(int,input().split()))
x_y.append(location)
x_y_tuple = [tuple(x) for x in x_y]
without_overlap = list(OrderedDict.fromkeys(x_y_tuple))
for i in without_overlap:
baduk[i[0]-1][i[1]-1] += 1
for _ in range(20):
print(" ".join(map(str,baduk[cnt])))
cnt += 1
결과😎
출처📝
https://codeup.kr/problem.php?id=6095
문제📖
풀이🙏
코드💻
import sys
baduk =[[0 for j in range(20)] for i in range(20)]
cnt = 0
for i in range(19):
badukal = list(map(int,sys.stdin.readline().split()))
for j in range(19):
baduk[i+1][j+1] = badukal[j]
n = int(input())
for _ in range(n):
cross = list(map(int,sys.stdin.readline().split()))
for i in range(1,20):
if baduk[cross[0]][i] == 0:
baduk[cross[0]][i] = 1
else:
baduk[cross[0]][i] = 0
if baduk[i][cross[1]] == 0:
baduk[i][cross[1]] = 1
else:
baduk[i][cross[1]] = 0
for i in range(1,20):
for j in range(1,20):
print(baduk[i][j],end=' ')
print('')
결과😎
출처📝
https://codeup.kr/problem.php?id=6096
문제📖
풀이🙏
코드💻
import sys
h, w = map(int,sys.stdin.readline().split())
n = int(sys.stdin.readline())
grid =[[0 for j in range(w)] for i in range(h)]
makdae = []
cnt = 0
len_num = 1
for _ in range(n):
makdae_info = list(map(int,sys.stdin.readline().split()))
makdae.append(makdae_info)
# 길이, (0 = 세로, 1 = 가로), x_point, y_point
for i in makdae:
grid[i[2]-1][i[3]-1] += 1
if i[1] == 0:
for _ in range(i[0]-1):
grid[i[2]-1][i[3]-1+len_num] += 1
len_num += 1
len_num = 1
else:
for _ in range(i[0]-1):
grid[i[2]-1+len_num][i[3]-1] += 1
len_num += 1
len_num = 1
for _ in range(h):
print(" ".join(map(str,grid[cnt])))
cnt += 1
결과😎
출처📝
https://codeup.kr/problem.php?id=6097
문제📖
풀이🙏
import sys
background = [[0 for cols in range(10)] for widths in range(10)]
for i in range(10):
num = sys.stdin.readline().split()
background[i] = list(map(int, num))
startPoint = (1, 1)
point = [0, 0]
point[0] = startPoint[0]
point[1] = startPoint[1]
status = 0
while status != 2:
if background[point[0]][point[1]] == 2:
status = 2
background[point[0]][point[1]] = 9
else:
background[point[0]][point[1]] = 9
if background[point[0]][point[1]+1] != 1:
point[1] = point[1]+1
else:
point[0] = point[0] + 1
if point[0] > 8:
point[0] = 8
break;
if point[1] > 8:
point = 8
break;
for i in range(10):
for j in range(10):
print(background[i][j], end=' ')
print()
결과😎
출처📝
https://codeup.kr/problem.php?id=6098