[프로그래머스 | 파이썬 / 자바스크립트] 유한소수 판별하기(코딩테스트 입문/ level 0)
·
Problem Solving/프로그래머스
문제 https://school.programmers.co.kr/learn/courses/30/lessons/120878 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 🐍파이썬 def solution(a, b): a_arr = [] b_arr = [] # 1. 기약분수로 나타내기-분자, 분모의 소인수 확인, 동일한 소인수는 제거 i = 2 while a >= i: if a % i == 0: a //= i a_arr.append(i) else: i += 1 i = 2 while b >= i: if b % i == 0: b //= i if i in a_arr..
[프로그래머스 | 파이썬 / 자바스크립트] 대문자와 소문자(코딩테스트 입문/ level 0)
·
Problem Solving/프로그래머스
문제 https://school.programmers.co.kr/learn/courses/30/lessons/120893?language 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 🐍파이썬 def solution(my_string): return ''.join([i.lower() if i.isupper() else i.upper() for i in my_string]) 다른 풀이 방법 def solution(my_string): return my_string.swapcase() ❓ swapcase() 대문자와 소문자의 문자열을 변환하는 데 사용된다 반..
[프로그래머스 | 파이썬 / 자바스크립트] 피로도(완전탐색/ level 2)
·
Problem Solving/프로그래머스
문제 https://school.programmers.co.kr/learn/courses/30/lessons/87946 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 🐍파이썬 from itertools import permutations def solution(k, dungeons): result = [] #던전을 방문하는 순서의 경우의 수를 나열 for dg in permutations(dungeons, len(dungeons)): nk = k#매번 k로 피로도 리셋 answer = 0#방문한 던전 수 매번 리셋 for d in dg:#각 경우의 수마다..
[프로그래머스 | 파이썬 / 자바스크립트] 다항식 더하기(코딩테스트 입문/ level 0)
·
Problem Solving/프로그래머스
문제 https://school.programmers.co.kr/learn/courses/30/lessons/120863?language=python3 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 🐍파이썬 def solution(polynomial): arr = polynomial.replace(" ", "").split("+") x, num = 0, 0 for i in arr: if "x" in i: if len(i) >= 2: x += int(i[:-1]) else: x += 1 else: num += int(i) if num > 0 and x > ..
[프로그래머스 | 파이썬 / 자바스크립트] 배열 회전시키기(코딩테스트 입문/ level 0)
·
Problem Solving/프로그래머스
문제 https://school.programmers.co.kr/learn/courses/30/lessons/120844 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 🐍파이썬 def solution(numbers, direction): if direction == "right": numbers.insert(0, numbers.pop()) else: numbers.append(numbers.pop(0)) return numbers 1️⃣ direction이 right인 경우, 0번째 인덱스에 numbers.pop() 데이터를 삽입 2️⃣ direction..
[프로그래머스 | 파이썬 / 자바스크립트] 소인수분해(코딩테스트 입문/ level 0)
·
Problem Solving/프로그래머스
문제 https://school.programmers.co.kr/learn/courses/30/lessons/120852 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 🐍파이썬 def solution(n): answer = [] result = [] i = 2 while i
[프로그래머스 | 파이썬 / 자바스크립트] 문자 반복 출력하기(코딩테스트 입문/ level 0)
·
Problem Solving/프로그래머스
문제 https://school.programmers.co.kr/learn/courses/30/lessons/120825 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 🐍파이썬 def solution(my_string, n): my_string1 = "" for i in my_string: my_string1 += i * n return my_string1 다른 풀이 방법 def solution(my_string, n): return ''.join(i*n for i in my_string) 🐥자바스크립트 function solution(my_string,..
[프로그래머스 | 파이썬 / 자바스크립트] 삼각형의 완성조건 (1)(코딩테스트 입문/ level 0)
·
Problem Solving/프로그래머스
문제 https://school.programmers.co.kr/learn/courses/30/lessons/120889?language=python3 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 🐍파이썬 def solution(sides): return 1 if max(sides) acc+cur) - Math.max(...sides) ? 1..
[프로그래머스 | 파이썬 / 자바스크립트] 할인 행사(연습문제/ level 2)
·
Problem Solving/프로그래머스
문제 https://school.programmers.co.kr/learn/courses/30/lessons/131127 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 🐍파이썬 def solution(want, number, discount): answer = 0 #원하는 품목이 모두 있는지 확인 for i, j in zip(want, number): if j > discount.count(i): return 0 for k in range(len(discount)-9): check = 0 for i, j in zip(want, number): # k ~ ..