Programmers
-
Level.1 연습문제 > 2016년Programmers/Python 2021. 5. 3. 12:49
123456789101112131415def solution(a, b): answer = '' month = [31, 29, 31, 30, 31, 30, 31, 31 ,30 ,31 ,30 ,31]; week = ["FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU"]; dmonth = a - 1; dday = b - 1; for i in range (0,dmonth): dday += month[i]; answer = week[dday % 7]; return answerColored by Color Scriptercs
-
Level.1 탐욕법 > 체육복Programmers/Python 2021. 5. 3. 12:48
1234567891011121314151617181920212223242526272829303132333435363738394041def solution(n, lost, reserve): clothes = [] for i in range(n): clothes.append(1); for i in lost: clothes[i-1] -= 1; for i in reserve: clothes[i-1] += 1; if clothes[0] == 2 and clothes[1] == 0: clothes[0] -= 1; clothes[1] += 1; if clothes[1] == 2 and clothes[0] == 0: clothes[1] -= 1; clothes[0] += 1; if clothes[n-1] == 2 an..
-
Level.1 완전탐색 > 모의고사Programmers/Python 2021. 5. 3. 12:43
12345678910111213141516171819202122232425262728293031def solution(answers): answer = [] people1 = [1,2,3,4,5]; people2 = [2,1,2,3,2,4,2,5]; people3 = [3,3,1,1,2,2,4,4,5,5]; cor1 = 0; cor2 = 0; cor3 = 0; for i in range(0,len(answers)): if answers[i] == people1[i%5]: cor1 += 1; if answers[i] == people2[i%8]: cor2 += 1; if answers[i] == people3[i%10]: cor3 += 1; resultDic = {1:cor1, 2:cor2, 3:cor3}..
-
Level.1 해시 > 완주하지 못한 선수Programmers/Python 2021. 5. 3. 12:20
1 2 3 4 5 6 7 8 9 10 11 12 def solution(participant, completion): spart = sorted(participant); scom = sorted(completion); for i in range(len(completion)): if scom[i] != spart[i]: print(spart[i]); return spart[i]; return spart[len(spart)-1]; cs