Simple_PS

  • Lv0 프로그래머스(Programmers)[Python][파이썬] 문자 개수 세기
    """ 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/181902 """ # 풀이 과정 def solution(my_string): english = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] result = [] english = "".join(english).upper() print(my_string.count("a")) for x in list(english): result.append(my_string.count(x)) english = "".join(english).lower() for y in list(english): result.append(my_string.count(y)) return result
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 무작위로 k개의 수 뽑기
    """ 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/181858 """ # 풀이 과정 def solution(arr, k): result = [] for x in arr: if x not in result and len(result) < k: result.append(x) else: continue if len(result) < k: g = k - len(result) for l in range(g): result.append(-1) return result
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 몫 구하기
    """ 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/120805 """ # 풀이 과정 def solution(num1, num2): return int(num1 / num2)
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 모음 제거
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120849 """ # 풀이 과정 def solution(my_string): minus="aeiou" new=[] for a in list(my_string): if a in minus: continue else: new.append(a) answer="".join(new) return answer
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 모스 부호
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120838 """ # 풀이 과정 def solution(letter): morse = { '.-': 'a', '-...': 'b', '-.-.': 'c', '-..': 'd', '.': 'e', '..-.': 'f', '--.': 'g', '....': 'h', '..': 'i', '.---': 'j', '-.-': 'k', '.-..': 'l', '--': 'm', '-.': 'n', '---': 'o', '.--.': 'p', '--.-': 'q', '.-.': 'r', '...': 's', '-': 't', '..-': 'u', '...-': 'v', '.--': 'w', '-..-': 'x', '-.--': 'y', '--..': 'z' } x = letter.split() for a in range(len(x)): for b in morse: if x[a] == b: x[a] = morse[b] answer = "".join(x) return answer
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 머쓱이보다 큰 사람
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120585 """ # 풀이 과정 def solution(array, height): array.append(height) array.sort() array.reverse() return array.index(height)
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 마지막 두 원소
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181927 """ # 풀이 과정 def solution(num_list): if num_list[-1]>num_list[-2]: num_list.append(num_list[-1]-num_list[-2]) else: num_list.append(num_list[-1]*2) return num_list
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 리스트 자르기
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181897 """ # 풀이 과정 def solution(n, slicer, num_list): a = slicer[0] b = slicer[1] c = slicer[2] if n == 1: return num_list[0:b + 1] elif n == 2: return num_list[a:] elif n == 3: return num_list[a:b + 1] elif n == 4: return num_list[a:b + 1:c]
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 로그인 성공
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120883 """ #풀이 과정1 def solution(id_pw, db): for a, b in db: if a == id_pw[0] and b == id_pw[1]: return "login" elif a == id_pw[0] and not b == id_pw[1]: return "wrong pw" else: continue return "fail" #풀이 과정2 def solution(id_pw, db): if db_pw := dict(db).get(id_pw[0]): return "login" if db_pw == id_pw[1] else "wrong pw" return "fail"
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 등차수열의 특별한 항만 더하기
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181931 """ # 풀이 과정 def solution(a, d, included): num = [] result = 0 in_num = 0 for x in range(len(included)): if x == 0: num.append(a) in_num = a else: in_num += d num.append(in_num) if included[x] == True: result += num[x] return result
  • << 17 18 19 20 21 22 23 24 25 26 27 >>