분류 전체보기
-
[💕 프로그래머스] 최솟값 만들기Algorithm/1일 1코테 2020. 12. 15. 13:12
Q. programmers.co.kr/learn/courses/30/lessons/12941 코딩테스트 연습 - 최솟값 만들기 길이가 같은 배열 A, B 두개가 있습니다. 각 배열은 자연수로 이루어져 있습니다. 배열 A, B에서 각각 한 개의 숫자를 뽑아 두 수를 곱합니다. 이러한 과정을 배열의 길이만큼 반복하며, 두 수를 곱 programmers.co.kr A. def solution(A,B): A.sort() B.sort(reverse=True) s = 0 for a, b in zip(A,B): s += a*b return s A의 최솟값과 B의 최댓값을 더해줘야 s에 최솟값이 누적된다. A는 오름차순 정렬, B는 내림차수 정렬. 그리고 인덱스 0부터 하나씩 뽑아 곱해줘서 누적시킨다.
-
[🦩 프로그래머스] 오픈채팅방 / 나누어 떨어지는 숫자배열 / 같은 숫자는 싫어 / 체육복Algorithm/케로베로스 2020. 12. 14. 09:34
프로그래머스 풀이 Q. 오픈채팅방 def solution(record): id_dict = {} # id와 닉네임 저장 dict # 아이디: 닉네임 형태로 저장한다. 최종적으로는 바뀐 닉네임이 저장되어 있음. for r in record: a = list(r.split()) if len(a) == 3: id_dict[a[1]] = a[2] # a[1]은 아이디 값 저장, enter/leave에 따라 문장 저장 result = [] for r in record: a = list(r.split()) if a[0] == 'Enter': result.append(id_dict[a[1]]+'님이 들어왔습니다.') elif a[0] == 'Leave': result.append(id_dict[a[1]]+'님이 나갔..
-
[🐉 백준 9단계] 수학 2Algorithm/케로베로스 2020. 12. 13. 22:55
백준 9단계 수학 2 1978 n=input() l=list(map(int, input().split())) answer = 0 for i in l: count = 0 for j in range(1, i+1): if i == 1: break if i%j == 0: count += 1 if count == 2: answer += 1 print(answer) 2581 import math while True: n = int(input()) if n == 0: break count = 0 for i in range(n+1, 2*n+1): if i == 1: continue elif i == 2: count += 1 continue else: for j in range(2, int(math.sqrt(i))+1)..
-
[🐉 백준 8단계] 수학 1Algorithm/케로베로스 2020. 12. 13. 20:11
백준 8단계 수학 1 1712 a, b, c = map(int, input().split()) if b >= c: print(-1) else: print(int(a/(c-b))+1) 2839 n = int(input()) count = 0 while True: if (n % 5) == 0: count = count + (n//5) print(count) break n = n-3 count += 1 if n < 0: print("-1") break 2292 n = int(input()) a = 2 b = 1 for i in range(0, n): if n == 1: print(1) break a = a + 6*i b = b + 6*(i+1) if a
-
[🐉 백준 7단계] 문자열Algorithm/케로베로스 2020. 12. 12. 11:34
백준 7단계 문자열 11654. print(ord(input())) 11720. n = int(input()) a = str(input()) s = 0 for i in a: i = int(i) s += i print(s) 10809. import string alpha = list(string.ascii_lowercase) answer = [] word = input() for a in alpha: if a in word: answer.append(str(word.index(a))) else: answer.append('-1') print(' '.join(answer)) 2675. t = int(input()) for _ in range(t): a, b = input().split() answer = '..
-
[Django] debug=False로 수정하니 static, media 파일 날라감프로그래밍/Django & Flask 2020. 12. 11. 20:52
프로젝트/urls.py에 다음 두 줄 추가! from django.views.static import serve from django.conf.urls import url urlpatterns = [ // url(r'^media/(?P.*)$', serve,{'document_root': settings.MEDIA_ROOT}), url(r'^static/(?P.*)$', serve,{'document_root': settings.STATIC_ROOT}), ]
-
[💕 프로그래머스] 숫자의 표현Algorithm/1일 1코테 2020. 12. 7. 12:27
프로그래머스 2단계 숫자의 표현 Q. 문제 programmers.co.kr/learn/courses/30/lessons/12924 코딩테스트 연습 - 숫자의 표현 Finn은 요즘 수학공부에 빠져 있습니다. 수학 공부를 하던 Finn은 자연수 n을 연속한 자연수들로 표현 하는 방법이 여러개라는 사실을 알게 되었습니다. 예를들어 15는 다음과 같이 4가지로 표현 할 programmers.co.kr A. 답 def solution(n): a = [i for i in range(1, n+1)] l = 0 r = 1 count = 0 while l < n: s = sum(a[l:r]) if s == n: count += 1 if s < n: r += 1 else: l += 1 return count 풀이 - 1부..