K

@kimjuha19

지그재그 숫자 합

Python
5 months ago
grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] total = 0 for i in range(len(grid)): if i % 2 == 0: total += sum(grid[i]) else:

중복 문자 제거 후 정렬

Python
5 months ago
s = "banana" result = "".join(sorted(set(s))) print(result)

엘리베이터 이동 거리

Python
5 months ago
floors = [5, 2, 8] current = 1 total_distance = 0 for floor in floors: total_distance += abs(floor - current) current = floor total_distance += abs(current - 1)

진법 변환 (10진수 → 2진수)

Python
5 months ago
num = 13 output = "" while num != 0: temp = num // 2 output = str(num % 2) + output num = temp print(output)

주차 요금 정산

Python
5 months ago
times = [[10, 14], [15, 16], [18, 22]] answer = 0 for start, end in times: parking_time = end - start if parking_time <= 3: answer += 5000 else: answer += 5000 + (parking_time - 3) * 2000

단어 변환 및 거꾸로 출력

Python
5 months ago
word = "Python is Easy" stack = [] result = "" for ch in word: stack.append(ch) for i in range(len(stack)): result += stack.pop(-1)

연속된 K일의 매출 합 최대화

Python
5 months ago
num = [10, 20, 30, 10, 50, 20, 10] k = 3 current_sum = sum(num[:k]) max_sum = current_sum for i in range(k, len(num)): current_sum = current_sum - num[i - k] + num[i] max_sum = max(max_sum, current_sum)

캐릭터의 이동 거리

Python
5 months ago
commands = "URR" x = 0 y = 0 for c in commands: if c == 'U': y += 1 elif c == 'D': y -= 1

체질량 지수(BMI) 판정

Python
5 months ago
info = [[170, 80], [160, 50], [180, 90]] result = [] for i in range(len(info)): h = info[i][0] / 100 w = info[i][1] bmi = w / (h ** 2) if bmi >= 25: result.append(i)

재고 관리

Python
5 months ago
inventory = {"apple": 10, "banana": 5} sales = ["apple", "apple", "banana"] for i in sales: if i in inventory: inventory[i] -= 1 print(inventory)

중복 없는 닉네임

Python
5 months ago
names = ["lee", "kim", "lee", "park", "lee"] count = {} result = [] for name in names: if name not in count: count[name] = 0 result.append(name) else:

팰린드롬 숫자 찾기

Python
5 months ago
start = 100 end = 150 count = 0 for s in range(start, end): if str(s) == str(s)[::-1]: count += 1 print(count)

기록 단축왕

Python
5 months ago
best_record = 55.5 records = [54.2, 56.1, 55.0, 58.3] count = 0 for i in range(len(records)): if best_record < records[i]: count += 1 print(count)

ATM 출금 수수료

Python
5 months ago
amount = 10000 grade = "VIP" answer = 0 charge = amount * 0.02 totalcharge = charge + 500 if grade == "VIP": print(totalcharge // 2)

미세먼지 경보

Python
5 months ago
dust = [70, 160, 180, 50, 90, 100, 40] for i in range(len(dust) - 1): if dust[i] < 150 and dust[i + 1] < 150: print("True") break else: print("False")

과락 제외 평균 구하기

Python
5 months ago
scores = [80, 90, 70] answer = 0 for score in scores: if score < 40: print("False") break answer += score else: answer //= len(scores)

유통기한 확인 서비스

Python
5 months ago
manufactured = 20230501 expire_days = 60 today = 20230715 m_year = manufactured // 10000 m_month = (manufactured // 100) % 100 m_day = manufactured % 100 t_year = today // 10000 t_month = (today // 100) % 100

행렬의 90도 회전

Python
5 months ago
arr = [ [1,2,3], [4,5,6], [7,8,9] ] n = len(arr) m = len(arr[0]) result = [[0] * n for i in range(m)]

특정한 합을 가지는 부분 연속 수열

Python
5 months ago
arr = [1,2,3,2,5] M = 5 n = len(arr) start = 0 sum = 0 count = 0 for end in range(n):

문자열 압축

Python
5 months ago
lst = "aabbaccc" ans = "" c = 1 for n in range(1, len(lst)): if lst[n] == lst[n - 1]: c += 1 else: if c > 1: