Simple_PS

  • Lv0 프로그래머스(Programmers)[Python][파이썬] 가위 바위 보
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120839 """ # 풀이 과정 def solution(rsp): a = list(rsp) result = [] for x in a: if x == "2": result.append("0") elif x == "0": result.append("5") elif x == "5": result.append("2") answer = "".join(result) return answer
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 가까운 1로 찾기
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181898 """ # 풀이 과정 def solution(arr, idx): for x in range(idx,len(arr)): if arr[x]==1: return x return -1
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 가까운 수
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120890 """ # 풀이 과정1 def solution(array, n): answer = 0 num = [] num_abs = [] for x in range(len(array)): a = abs(array[x] - n) if len(num) == 0: num.append(array[x]) num_abs.append(a) elif len(num) == 1: if num_abs[0] > a: num.pop() num.append(array[x]) num_abs.pop() num_abs.append(a) elif num_abs[0] == a: if array[x] < num[0]: num.pop() num.append(array[x]) num_abs.pop() num_abs.append(a) elif num_abs[0] <= a: continue answer = num[0] # 풀이 과정2 solution=lambda a,n:sorted(a,key=lambda x:(abs(x-n),x))[0]
  • Lv0 프로그래머스(Programmers)[Python][파이썬] x사이의 개수
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181867 """ # 풀이 과정 def solution(myString): k=myString.split("x") result=[] for x in k: z=len(x) result.append(z) return result
  • Lv0 프로그래머스(Programmers)[Python][파이썬] rny_string
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181863 """ # 풀이 과정 def solution(rny_string): x=rny_string.replace("m","rn") return x
  • Lv0 프로그래머스(Programmers)[Python][파이썬] qr코드
    """ 출처:프로그래머스 https://school.programmers.co.kr/learn/courses/30/lessons/181903 """ # 풀이 과정 def solution(q, r, code): return code[r::q]
  • Lv0 프로그래머스(Programmers)[Python][파이썬] ox퀴즈
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120907 """ 풀이 과정 def solution(quiz): return ["O" if x else "X" for x in map(eval, map(lambda x: x.replace("=", "=="), quiz))]
  • Lv0 프로그래머스(Programmers)[Python][파이썬] n의 배수 고르기
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120905 """ # 풀이 과정 def solution(n, numlist): answer = [] for x in numlist: if x % n == 0: answer.append(x) return answer # 풀이 과정2 def solution(n, numlist): answer = [] for x in numlist: if x%n==0: answer.append(x) else:continue return answer
  • Lv0 프로그래머스(Programmers)[Python][파이썬] n보다 커질때까지 더하기
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181884 """ # 풀이 과정 def solution(numbers, n): count=0 for x in numbers: count+=x if count>n: return count
  • Lv0 프로그래머스(Programmers)[Python][파이썬] n번째 원소부터
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181892 """ # 풀이 과정 def solution(num_list, n): x = num_list[n - 1:]
  • << 20 21 22 23 24 25 26 27 >>