-
""" 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/92335 """ # 풀이과정 def solution(n, k): result = 0 a = "" while True: if k == 10: break t = n % k a += str(t) n = int(n / k) if n < k: a += str(n) break a = a[::-1] if k == 10: a = str(n) # print(a) b = a.split("0") if k == 10: for c in b: count = 0 if c.isdigit() == True and int(c) != 1: for d in range(1, int(int(c) ** 0.5) + 1): if int(c) % d == 0: count += 1 if count > 1: break if count == 1: result += 1 else: print(b) for c in b: count = 0 if c.isdigit() == True and int(c) != 1: for d in range(1, int(int(c) ** 0.5) + 1): if int(c) % d == 0: count += 1 if count > 1: break if count == 1: result += 1 print(result) return result
-
""" 출처:백준, https://www.acmicpc.net/problem/2579 """ # 풀이 과정 n = int(input()) stage = [0] for i in range(n): k = int(input()) stage.append(k) dp = [0] * (n + 1) dp_check = [False] * (n + 1) dp[1] = stage[1] if n == 1: print(stage[1]) elif n == 2: print(max(stage[1], stage[1] + stage[2])) else: if stage[1] == 0: dp[2] == stage[2] else: dp[2] = stage[1] + stage[2] dp_check[2] = True count = 3 while count < n + 1: if dp_check[count - 1] == False: one = stage[count] + dp[count - 1] else: one = stage[count] + dp[count - 3] + stage[count - 1] two = stage[count] + dp[count - 2] if one > two: dp_check[count] = True dp[count] = one else: dp_check[count] = False dp[count] = two count += 1 print(dp[-1])
-
""" 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/12899 """ # 풀이 과정 # 1.재귀로 연속으로 숫자를 바꾸기 # 2.조합으로 생각 후 연속 된 숫자를 나눠서 위치로 숫자 찾기 # 1.재귀로 연속으로 숫자를 바꾸기 # 2.조합으로 생각 후 연속 된 숫자를 나눠서 위치로 숫자 찾기 def solution(n): k = ["1", "2", "4"] result = "" num = n count = 1 # 자릿수 파악 while num > 0: num -= 3 ** (count) if num > 0: count += 1 for a in range(1, count): n -= 3 ** a while count > 1: i, j = divmod(n, 3 ** (count - 1)) if j == 0: result += k[i - 1] else: result += k[i] n = n % (3 ** (count - 1)) count -= 1 if count == 1: i, j = divmod(n - 1, 3) result += k[j] return result
-
""" 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/77885 """ # 풀이 과정 def solution(numbers): result = [] for a in numbers: k = list(str(bin(a))[2:]) t = k[::-1] flag = False for b in range(len(t)): if t[b] == "0": c = b flag = True break if flag == True: d = "1" + "0" * (b - 1) e = int(d, 2) result.append(a + e) else: d = "1" + "0" * (len(k) - 1) e = int(d, 2) result.append(a + e) return result
-
""" 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/120821 """ # 풀이 과정 def solution(num_list): num_list.reverse() return num_list
-
""" 출처: 프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/120809 """ # 풀이 과정 def solution(numbers): for a in range(len(numbers)): numbers[a] = numbers[a] * 2 return numbers
-
""" 출처: 프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/181871 """ # 풀이 과정 def solution(myString, pat): result = [] for x in range(len(myString)): k = myString.find(pat, x) result.append(k) return len(set(result) - {-1})
-
""" 출처: 프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/181907 """ # 풀이 과정 def solution(my_string, n): return my_string[0:n]
-
""" 출처: 프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/120911 """ # 풀이 과정 def solution(my_string): a=my_string.lower() b=list(a) answer = "".join(b) return answer
-
""" 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/120850 """ # 풀이 과정 def solution(my_string): a = "abcdefghijklmnopqrstuvwxyz" b = a.upper() result = [] x = list(my_string) for c in range(len(x)): if x[c] in a or x[c] in b: continue else: result.append(x[c]) result.sort() answer = map(int, result) return list(answer)