-
Notifications
You must be signed in to change notification settings - Fork 1
Insea 99/week02 #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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이 할당됨 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 저도 이 방법 사용해서 복습해봐야겠어요!