Simple_PS

  • Lv0 프로그래머스(Programmers)[Python][파이썬] 7의 개수
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120912 """ # 풀이 과정 1 def solution(array): b=list(map(str,array)) c=[] count=0 for x in b: d=list(x) c=c+d for y in range(len(c)): if c[y]=="7": count+=1 answer = count return answer # 풀이 과정 2 def solution(array): # answer = 0 # for x in array: # xx = str(x) # for y in xx: # if y == "7": # answer+=1 # return answer return str(array).count("7")
  • Lv0 프로그래머스(Programmers)[Python][파이썬]5명씩
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181886 """ # 풀이 과정 def solution(names): result = [] for x in range(len(names)): if (x + 1) % 5 == 1: result.append(names[x]) answer = result return answer
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 2의 영역
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181894 """ # 풀이 과정 def solution(arr): result = [] sub = [] for x in arr: if x == 2 or 2 in result: if x == 2: if not len(sub) == 0: result = result + sub result.append(x) sub = [] else: result.append(x) else: sub.append(x) else: continue return result if len(result) > 0 else [-1]
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 1로 만들기
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181880 """ # 풀이과정 def solution(num_list): count = 0 for x in range(len(num_list)): while True: if num_list[x] % 2 == 0 and not num_list[x] == 1: num_list[x] = num_list[x] / 2 count += 1 elif num_list[x] % 2 == 1 and not num_list[x] == 1: num_list[x] = (num_list[x] - 1) / 2 count += 1 if num_list[x] == 1: break return count
  • << 22 23 24 25 26 27 >>