목록All Contents (134)
Code&Data Insights
2022.01.16 #1. Function / Brute Force Algorithm (완전 탐색 알고리즘) (ex) - Programmers : '모의고사', '소수찾기' ** 6단계 풀다가 너무 어려워서 나중에 부르트포스 할 때 다시 풀기로!! ** #2. 문자열 - Stage 7 [11720] [my code] n = int(input()) num = list(map(int,input())) sum = 0 for i in range(n): sum += num[i] print(sum) -> int 형으로 해도 정답이 맞지만, 출제유형에 맞게 문자열로 다시 풀었다. ** 파이썬은 이미 문자열에 인덱싱이 가능하다 ** [new code] n = int(input()) num = input() sum = ..
2022.01.15 # 1. Stage 5 - [1546] [my code] n = int(input()) score = list(map(int,input().split())) m = max(score) new_score = [] sum = 0 for i in range(n): new_n = (score[i]/m) * 100 new_score.append(new_n) sum += new_score[i] print(sum/n) --> 짜면서 나름 맘에 들었다. array를 안써서 풀어도 되는 문제였던듯 # 2. Stage 5 - [8958] [8958] OX quiz - 다시 풀기 [my code] n = int(input()) cnt = 0 sum = 0 for i in range(n): x = inpu..
2022.01.14 # 1. Stage 4 - while loop [my code] a,b = map(int,input().split()) while a > 0 and b The "while true" loop in python runs without any conditions until the break statement executes inside the loop. # 2. Stage 4 - 1110번 계속 고민했는데 당최모르겠다..ㅎ 정수랑 str쓰는거 까진 생각했는데. 결국 구글링하다 다른분 답 참고했다. https://wook-2124.tistory.com/222 다시 풀어야할듯..! 주말에 다시 풀문제 # 3. Stage 5 - 1 dimensional array [2562- for + inp..
2022.01.13 #1 Python - for문 for문 range(0,n+1) --> 0부터 n까지 자동으로 1씩 increment 설정하려면 (0,n+1,3) 마지막에 쓰면, 3씩 increment #2 A+B를 여러 번 출력하는 문제 [my code] t = int(input()) for i in range(1,t+1): i = input().split(' ') a = int(i[0]) b = int(i[1]) print(int(i[0])+int(i[1])) ---> 입력 5번 한번에 가능하지 않고, 한번씩 하고 답이 나옴 정답으로 인정되긴 했으나 찜찜.. ---> range(1,t+1) 쓰지않고, 그냥 range(t)도 가능 => 다른 사람들도 비슷한 방식으로 추출됨 * map function ..
2022.01.12 #1 Python - If문 #2 윤년 표시하기 조건 : ( y % 4 == 0 and y % 100 != 0 ) or y % 400 == 0 #3 사분면 고르기 java와 다른점 && == and || == or --> 그냥 영어로 써도 됨, () 필요 X #4 알람시계 45분 일찍 알람 설정하기 [my code] time = input().split(' ') h = int(time[0]) m = int(time[1]) if 45
2022.01.11 #1 문자열에서 "와 \를 출력할 때는 앞에 \붙이기. #2 두 수를 입력받고 사칙연산 값을 출력하기 1) 두수를 입력받기 i = input().spilt(' ') -> 스페이스를 기준으로 나눔, 두 수를 동시에 입력 2) 배열로 i 입력받은 두 수를 정수형(int)으로 출력 a = int(i[0]) b = int(i[1]) #3 사칙연산 문제 num = input().split(' ') a = int(num[0]) b = int(num[1]) print(a+b) print(a-b) print(a*b) print(int(a/b)) print(a%b) #4 곱셈 문제 (세 자리 수) × (세 자리 수)는 다음과 같은 과정을 통하여 이루어진다. (1)과 (2)위치에 들어갈 세 자리 자연수..