반응형 프로그래머스/1단계83 (Python/LV1)문자열을 정수로 바꾸기 문제출처:https://school.programmers.co.kr/learn/courses/30/lessons/12925 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: return int(n) 자바로도 풀어본다. import java.math.BigInteger; class Solution { public int solution(String s) { BigInteger bi = new BigInteger(s); return bi.intValue(); } } 2022. 9. 9. (Python/LV1)하샤드 수 문제출처:https://school.programmers.co.kr/learn/courses/30/lessons/12947 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(n): x = sum([int(i) for i in str(n)]) return n % x == 0 아래처럼 한 줄로 가능 return n % sum([int(i) for i in str(n)]) == 0 2022. 9. 9. (Python/LV1) 정수 내림차순으로 배치하기 문제출처:https://school.programmers.co.kr/learn/courses/30/lessons/12933 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: return int("".join(list(reversed(sorted(str(n)))))) 최대한 포문을 사용 안해서 풀어 보려고 노력중이다 2022. 9. 9. (Python/LV1) 문자열 내 p 와 y 의 개수 문제출처:https://school.programmers.co.kr/learn/courses/30/lessons/12916 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: def solution(s) return s.lower().count('p') == s.lower().count('y') def solution(n): dic = {i:0 for i in n.lower()} for i in n.lower(): dic[i] += 1 return "true" if dic.get('p') == dic.get('y') else "false" 컴프리핸션 연.. 2022. 9. 9. (Python/LV1)자연수 뒤집어 배열로 만들기 문제출처: https://school.programmers.co.kr/learn/courses/30/lessons/12932 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: return list(map(int,reversed(str(n)))) 2022. 9. 9. (Python/LV1)평균 구하기 문제출처:https://school.programmers.co.kr/learn/courses/30/lessons/12944 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이: return (sum([i for i in arr]) / len(arr)) 2022. 9. 9. 이전 1 ··· 9 10 11 12 13 14 다음 반응형