Algorithm/Programmers
[Programmers] 코딩 기초 트레이닝 #2
j4ko
2023. 11. 25. 01:31
728x90
반응형
목차
공배수
https://school.programmers.co.kr/learn/courses/30/lessons/181936
def solution(number, n, m):
if number % n == 0 and number % m == 0:
return 1
else:
return 0
정수 찾기
https://school.programmers.co.kr/learn/courses/30/lessons/181840
def solution(num_list, n):
return 1 if n in num_list else 0
카운트 찾기
https://school.programmers.co.kr/learn/courses/30/lessons/181899
def solution(start, end_num):
return [x for x in range(start, end_num - 1, -1)]
소문자로 바꾸기
https://school.programmers.co.kr/learn/courses/30/lessons/181876
def solution(myString):
return myString.lower()
홀짝에 따라 다른 값 반환하기
https://school.programmers.co.kr/learn/courses/30/lessons/181935
def solution(n):
if n % 2 != 0:
return sum([x for x in range(n+1) if x % 2 != 0])
else:
return sum([x ** 2 for x in range(n+1) if x % 2 == 0])
flag에 따라 다른값 반환하기
https://school.programmers.co.kr/learn/courses/30/lessons/181933
def solution(a, b, flag):
if flag:
return a +b
return a - b
이어 붙인 수
https://school.programmers.co.kr/learn/courses/30/lessons/181928
def solution(num_list):
odd_str = ""
even_str = ""
for x in num_list:
if x % 2 == 0:
even_str += str(x)
else:
odd_str += str(x)
return int(odd_str) + int(even_str)
뒤에서 5등 위로
https://school.programmers.co.kr/learn/courses/30/lessons/181852
def solution(num_list):
num_list.sort()
return num_list[5:]
마지막 두 원소
https://school.programmers.co.kr/learn/courses/30/lessons/181927
def solution(num_list):
number1 = num_list[-1]
number2 = num_list[-2]
if number1 > number2:
num_list.append(number1 - number2)
else:
num_list.append(number1 * 2)
return num_list
n의 배수
https://school.programmers.co.kr/learn/courses/30/lessons/181937
def solution(num, n):
return 1 if num % n ==0 else 0
728x90
반응형