Simple_PS

  • Lv0 프로그래머스(Programmers)[Python][파이썬] A강조하기
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181874 """ # 풀이 과정 def solution(myString): x=list(myString) for k in range(len(x)): if x[k]=="A" or x[k]=="a": x[k]="A" else: x[k]=x[k].lower() return "".join(x)
  • Lv3 프로그래머스(Programmers)[Python][파이썬] 야근 지수
    """ 출처:프로그래머스 https://school.programmers.co.kr/learn/courses/30/lessons/12927 """ 풀이과정 import heapq def solution(n, works): # map(lambda x:x*x,works) new=[] for i in works: heapq.heappush(new,-i) while n>0: k=heapq.heappop(new) k+=1 heapq.heappush(new,k) n-=1 if new[0]>=0: #print(new) return 0 return sum(list(map(lambda x:x*x,new)))
  • Lv0 프로그래머스(Programmers)[Python][파이썬] ad제거하기
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/181870 """ # 풀이 과정 def solution(strArr): result = [] for x in range(len(strArr)): if not "ad" in strArr[x]: result.append(strArr[x]) return result
  • Lv0 프로그래머스(Programmers)[Python][파이썬] 369게임
    """ 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/courses/30/lessons/120891 """ #풀이 과정 def solution(order): answer = 0 a=list(str(order)) count=0 for x in a: if not int(x)==0 and int(x)%3==0: count+=1 answer=count return answer
  • 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
  • << 20 21 22 23 24 25 >>