목록코드트리 (12)
배우고 느낀 것들
🍒 문제 링크 https://www.codetree.ai/missions/4/problems/season-of-num/description 🍒 문제 분석 if 문의 순서가 중요 🍒 내 코드 n = int(input()) if n >= 9 and n = 6 and n = 3 and n = 12 or n
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/robot-moving-from-side-to-side/submissions 🍒 문제 분석 🍒 내 코드 코드 🍓 내 해결 과정 🌽 다른 사람 코드 N, M = map(int, input().split()) # time에 따른 a,b의 위치 기록할 수 있는 배열 생성 pos_a, pos_b = [0] * 100000, [0] * 100000 time_a, time_b = 1, 1 #t만큼의 변화동안 pos_a, pos_b for _ in range(N): t, d = tuple(input().split()) for _ in range(int(t)): pos_a[time_a] = pos_a[time_a - 1] + ..
🍒 문제 링크 🍒 문제 분석 🍒 내 코드 a, b, c = map(int, input().split()) time = 0 while True: if a
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/code-name/explanation 🍒 문제 분석 5개 입력값 각각 받아 객체 생성 -> 최소값 출력 🍒 내 코드 class spy: #임의로 값=0 설정해서 초기값 제공 def __init__(self,code=0,score=0): self.code = code self.score = score # spy 리스트에 5개 객체 만들기 spys = [] for _ in range(5): spys.append(spy()) #입력값 5개 따로 들어오므로 for문으로 각각 입력 for i in range(5): spys[i].code, spys[i].score = input().split() print(spys[0]..
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/two-equal-series/discussions/1550 🍒 문제 분석 배열 두 개 설정, 비교하기 🍒 내 코드 N = int(input()) A = map(int, (input().split())) B = map(int, (input().split())) A2 = sorted(A) B2 = sorted(B) if A2 == B2: print("Yes") else: print("No") 🍓 내 해결 과정 sorted 해둔 후, A2 == B2 답지 : zip 함수 이용 🌽 다른 사람 코드 # 변수 선언 및 입력 n = int(input()) a = list(map(int, input().split())) b ..
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/inc-dec-sorting/submissions 🍒 문제 분석 🍒 내 코드 n = int(input()) arr = list(map(int, input().split())) arr_up = arr.sort print(arr_up) n = int(input()) arr = list(map(int, input().split())) arr_up = sorted(arr) arr_down = sorted(arr, reverse = True) for i in range(n): print(arr_up[i], end=' ') print() for i in range(n): print(arr_down[i], end=' ')코드..
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/maximum-value-with-recursive-function/explanation 🍒 문제 분석 🍒 답안 코드 # 변수 선언 및 입력: n = int(input()) arr = list(map(int, input().split())) # a번째 까지 인덱스의 숫자 중에 가장 큰 값을 반환합니다. def max_value(a): if a == 0: return arr[0] return max(max_value(a - 1), arr[a]) print(max_value(n - 1)) max 함수 이용해서 제일 오른쪽(?) 값이랑 비교하면서 줄여나감 🍓 내 해결 과정 🌽 다른 사람 코드 def max(x, y):..
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/369-games-using-functions/description 🍒 문제 분석 🍒 코드 a, b = map(int,input().split()) cnt = 0 def letter(n): if n // 10 == 3 or n // 10 == 6 or n // 10 == 9 or n % 10 == 3 or n % 10 == 6 or n % 10 == 9: return True def digit(n): if (n % 3 == 0) or letter(n): return True for i in range (a, b+1, 1): if digit(i): cnt += 1 print(cnt) # letter: 3,6,9 들..
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/minimum-value-of-an-integer/description 🍒 문제 분석 🍒 코드 a, b, c = map(int,input().split()) def minimum(a,b,c): if a
🍒 문제 링크 https://www.codetree.ai/missions/5/problems/sum-from-1-to-a-certain-number/description 🍒 문제 분석 🍒 코드 n = int(input()) def sig(n): for i in range(1, n+1): i += 1 return n // 10 print(sig(n))코드 입력 🍓 내 해결 과정 일단 함수 안에 n 에 관련된 값이 아무 것도 없음... 결국 그냥 n//10 i += 1 하게 되면 값이 엉킴 🌽 다른 사람 코드 n = int(input()) def sig(n): sum_value = 0 for i in range(1, n+1): sum_value += i return sum_value // 10 print(s..