diff --git "a/INSEA-99/week02/10798_\354\204\270\353\241\234\354\235\275\352\270\260.py" "b/INSEA-99/week02/10798_\354\204\270\353\241\234\354\235\275\352\270\260.py" new file mode 100644 index 0000000..585d44f --- /dev/null +++ "b/INSEA-99/week02/10798_\354\204\270\353\241\234\354\235\275\352\270\260.py" @@ -0,0 +1,30 @@ +import sys +from itertools import zip_longest +input = sys.stdin.readline + +lines = [input().rstrip() for _ in range(5)] +vertical_chars = [''.join(filter(None, chars)) for chars in zip_longest(*lines)] +print(''.join(vertical_chars)) + + +# - filter(function, iterable) +# iterable의 각 요소를 차례로 function에 넣고 반환값이 True면 사용, False면 제거 +# function 대산 None을 넣는 경우 None을 제거해줌 + +# - zip +# 여러 iterable(리스트, 문자열 등) 을 병렬로 묶어서 튜플을 만들어줌 +# 가장 짧은 iterable 길이에 맞춰 묶음이 생성됨 +# 예시) +# a = [1, 2, 3] +# b = ['x', 'y'] +# zip(a, b) -> [(1, 'x'), (2, 'y')] +# +# - zip_longest +# zip과 기능이 동일하지만 가장 긴 iterable 길이에 맞추고 그것보다 짧은 iterable은 None으로 채움(None 대신 다른 값으로 설정 가능. 인자에 fillvalue=?) + +# - * (언패킹) +# 리스트, 튜플, 문자열 등 iterable을 개별 요소로 풀어서 함수 인자나 다른 자료구조에 전달 +# ex) +# lst1 = [1, 2] +# lst2 = [3, 4] +# combined = [*lst1, *lst2] # [1, 2, 3, 4] diff --git "a/INSEA-99/week02/10807_\352\260\234\354\210\230_\354\204\270\352\270\260.py" "b/INSEA-99/week02/10807_\352\260\234\354\210\230_\354\204\270\352\270\260.py" new file mode 100644 index 0000000..e90bbdf --- /dev/null +++ "b/INSEA-99/week02/10807_\352\260\234\354\210\230_\354\204\270\352\270\260.py" @@ -0,0 +1,16 @@ +import sys +input = sys.stdin.readline + +ans = 0 + +# 입력 +input() # 다른 언어는 리스트 입력 받을 때 몇개인지 정보가 필요한 경우가 있는데, 파이썬은 필요없어서 그냥 받기만 하고 사용 안함 +nums = map(int, input().split()) +v = int(input()) + +# 풀이 +for n in nums: + if(n==v): ans+=1 + +# 출력 +print(ans) \ No newline at end of file diff --git a/INSEA-99/week02/10952_A+B-5.py b/INSEA-99/week02/10952_A+B-5.py new file mode 100644 index 0000000..7d02847 --- /dev/null +++ b/INSEA-99/week02/10952_A+B-5.py @@ -0,0 +1,16 @@ +import sys +input = sys.stdin.readline + +while(True): + a, b = map(int, input().split()) + if(a==0 and b==0): + break + print(a+b) + +# [입력 받는 로직 설명] +# a, b = map(int, input().split()) +# 예시) 만약 "1 1" 입력이 들어왔다면 +# 1. input()을 통해 "1 1"을 가져옴 +# 2. input().split()를 통해 공백을 기준으로 쪼갠 리스트를 얻음["1", "1"] (쪼개는 기준 split에 인자 줘서 바꿀 수 있음) +# 3. map을 통해 list의 원소마다 int를 적용시켜줌 -> [1, 1] +# 4. a, b = [1, 1]를 하면 파이썬에서 제공하는 시퀀스 언패킹 기능으로 a=1, b=1이 할당됨 \ No newline at end of file