오늘 한 일
튜터님 깜짝 퀴즈
car_brands = ["Tesla", "BMW", "Audi", "Ferrari", "Hyundai", "Kia"]
cars = []
for car in car_brands:
if car == "Hyundai" or car == "Kia":
cars.append(car.upper())
print(cars)
프로그래머스 코딩테스트 입문 문제 풀이
def solution(num, k):
answer = 1
for i in str(num):
if i == str(k):
return answer
else:
answer += 1
if answer == len(str(num))+1:
return -1
def solution(num, k):
return -1 if str(k) not in str(num) else str(num).find(str(k)) + 1
--------------------------------------------------------
def solution(n, numlist):
answer = []
for num in numlist:
if num % n == 0:
answer.append(num)
return answer
def solution(n, numlist):
return list(filter(lambda v: v%n==0, numlist))
--------------------------------------------------------
def solution(n):
answer = 0
for i in str(n):
answer += int(i)
return answer
def solution(n):
return sum(int(i) for i in str(n))
--------------------------------------------------------
def solution(quiz):
answer = []
for i in quiz:
qu = i.split()
op = qu[1]
if op == '+':
iz = int(qu[0]) + int(qu[2])
if iz == int(qu[4]):
answer.append("O")
else:
answer.append("X")
else:
iz = int(qu[0]) - int(qu[2])
if iz == int(qu[4]):
answer.append("O")
else:
answer.append("X")
return answer
def solution(quiz):
answer = []
for q in quiz:
l, r = q.split('=')
answer.append("O" if eval(l) == int(r) else "X")
return answer
참고
https://bluese05.tistory.com/64