Simple_PS

  • Lv0 프로그래머스(Programmers)[Python][파이썬] 문자열안에 문자열
    """ 출처: 프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/120908 """ # 풀이 과정 def solution(str1, str2): if str2 in str1: return 1 else:return 2
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 문자열 바꿔서 찾기
    """ 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/181864 """ # 풀이 과정 def solution(myString, pat): x = list(myString) for k in range(len(x)): if x[k] == "A": x[k] = "B" else: x[k] = "A" if pat in "".join(x): return 1 else: return 0 print(x) answer = 0 return answer
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 문자열 밀기
    """ 출처: 프로그래머스 https://school.programmers.co.kr/learn/courses/30/lessons/120921 """ # 풀이 과정 def solution(A, B): a = list(A) b = [] count = 0 answer = 0 if A == B: return answer for y in range(1, len(a)): for x in range(len(a)): b.append(a[x - y]) c = "".join(b) print(c) count += 1 if c == B: answer = count break else: b.clear() if not c == B: answer = -1 return answer
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 문자열 묶기
    """ 출처: 프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/181855 """ # 풀이 과정 def solution(strArr): num = [] result = [] for x in range(len(strArr)): num.append(len(strArr[x])) for k in range(31): s = num.count(k) result.append(s) return max(result)
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 문자열 뒤집기
    """ 출처: 프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/181905 """ # 풀이 과정 def solution(my_string, s, e): answer=list(my_string) answer[s:e+1]=answer[s:e+1][::-1] return "".join(answer)
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 문자열 뒤집기
    """ 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/120822 """ # 풀이 과정 def solution(my_string): result=list(my_string) result.reverse() result="".join(result) return result
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 문자열 계산하기
    """ 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/120902 """ # 풀이 과정1 def solution(my_string): answer = 0 a = eval(my_string) answer = a return answer # 풀이 과정2 def solution(my_string): x=eval(my_string) answer = x return answer
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 문자 반복 출력하기
    """ 출처:프로그래머스, https://school.programmers.co.kr/learn/courses/30/lessons/120825 """ # 풀이 과정 def solution(my_string, n): x = list(my_string) result = [] for a in x: result.append(a * n) result = "".join(result) return result
  • 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
  • << 16 17 18 19 20 21 22 23 24 25 26 >>