본문 바로가기

[SWEA] - Python

(10)
[SWEA] 1244 : [S/W 문제해결 응용] 2일차 - 최대 상금 python https://swexpertacademy.com/main/solvingProblem/solvingProblem.do SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 코드 def solution(numbers,cnt): global result # 숫자를 저장할 빈 문자열 생성 tmp = '' for number in numbers: tmp += number # 이 교환횟수에서 이미 만들어진 적 있는 숫자라면 리턴해서 실행시간 단축 if int(tmp) in result[cnt]: return # 처음 만들어진 숫자라면 정수형으로 바꿔서 리스트에 추가 else: result[cnt].append(int(tmp)..
[SWEA/D3] 5215 : 햄버거 다이어트 python https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AWT-lPB6dHUDFAVT&categoryId=AWT-lPB6dHUDFAVT&categoryType=CODE&problemTitle=&orderBy=RECOMMEND_COUNT&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=1 SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 아이디어 맛에 대한 점수와 칼로리를 튜플로 리스트에 저장한다. 가장 높은 점수를 저장할 전역변수 answer를 생성한다. 인덱스..
[SWEA] 1213 : [S/W 문제해결 기본] 3일차 - String python https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV14P0c6AAUCFAYi&categoryId=AV14P0c6AAUCFAYi&categoryType=CODE&problemTitle=%EB%AC%B8%EC%A0%9C%ED%95%B4%EA%B2%B0&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=2 SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 아이디어 string.find(target)함수를 활용한다..
[SWEA] 1206 : [S/W 문제해결 기본] 1일차 - View python https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV134DPqAA8CFAYh&categoryId=AV134DPqAA8CFAYh&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=&pageSize=10&pageIndex=1 SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com n을 입력받고 집의 높이들을 arr라는 리스트에 저장한다. arr[0], arr[1], arr[n-2], arr[n-1]은 0이기 때문에 arr[2]부..
[SWEA/D3] 16800 : 구구단 걷기 python https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AYaf9W8afyMDFAQ9 SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com i가 2부터 시작하고 num이 40일 때 나올 수 있는 i,j의 순서쌍은 (2, 20), (4, 10), (5, 8), (8, 5), (10, 4), (20, 2)이다. 이중에서 최단거리에 있는 것은 i+j가 최소인 순간인 (5,8) 또는 (8,5)일 때이다. 그런데 생각해보면 (5, 8)일 때 이후로는 구할 필요가 없다. 순서쌍의 앞뒤값의 순서가 달라지기만 할 뿐이기 때문이다. 따라서 i가 num..
[SWEA/D4] 2819 : 격자판의 숫자 이어 붙이기 python https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=4&contestProbId=AV7I5fgqEogDFAXB&categoryId=AV7I5fgqEogDFAXB&categoryType=CODE&problemTitle=&orderBy=SUBMIT_COUNT&selectCodeLang=PYTHON&select-1=4&pageSize=10&pageIndex=1&&&&&&&&&& SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 35분만에 풀었다. 뿌듯 from collections import deque T = int(input()) ..
[SWEA/D3] 13218 : 조별과제 python https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AXzjvCCq-PwDFASs&categoryId=AXzjvCCq-PwDFASs&categoryType=CODE&problemTitle=&orderBy=PASS_RATE&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=1 SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 난이도 책정이 잘못된 문제인 듯하다. n을 3으로 나눈 몫을 출력해주기만 하면 된다. T = int(input()) for test_cas..
[SWEA/D2] 1288 : 새로운 불면증 치료법 python https://swexpertacademy.com/main/code/problem/problemDetail.do T = int(input()) for test_case in range(1, T + 1): N = input() tmp = N s = set() while True: for c in tmp: if int(c) not in s: s.add(int(c)) if len(s)==10: print('#%d'%test_case,tmp) break tmp = str(int(tmp)+int(N)) 음...형변환을 많이 써서 자칫하면 실수하면 딱 좋겠다는 느낌이 든다. 리스트를 쓰면 더 간략하게 풀 수 있을 것 같으니 생각을 좀 해봐야겠다. 수정한 코드 T = int(input()) for test_case ..