K

@kimjuha19

수열의 구간 합

Python
5 months ago
N = 10 K = 2 Temps = [3, -2, -4, -9, 0, 3, 7, 13, 8, -3] current_sum = sum(Temps[:K]) max = current_sum for i in range(K, N): current_sum = current_sum - Temps[i - K] + Temps[i] if current_sum > max:

방 배정

Python
5 months ago
K = 2 students = [("여", 1), ("여", 1), ("남", 1), ("남", 2), ("여", 2)] fe_counter = 0 male_counter = 0 male = 0 female = 0 for gender in students: if gender == "남":

대표값

Python
5 months ago
from collections import Counter num = [10, 40, 30, 60, 30, 20, 60, 30, 40, 50] num_count = len(num) average = 0 arr = Counter(num).most_common(1)[0][0] for i in num: average += i

일곱 난쟁이

Python
5 months ago
heights = [20, 7, 23, 19, 10, 15, 25, 8, 13] total = sum(heights) for i in range(9): for j in range(i + 1, 9): if total - heights[i] - heights[j] == 100: result = [] for k in range(9): if k != i

버스 도착 알림

Python
5 months ago
buses = {101: 5, 202: 3, 123: 7, 35: 4, 770: 10} fastest_bus = min(buses, key=buses.get) print(fastest_bus)

환율 계산기

Python
5 months ago
usd = 12.5 rate = 1350 won = int(usd * rate) print(won)

비밀번호

Python
5 months ago
Password = "Pass123!" length_count = 0 special_count = 0 num_count = 0 if len(Password) >= 8: length_count = 1 for p in Password:

장바구니 무료배송

Python
5 months ago
Prices = [10000, 25000] total = 0 for price in Prices: total += price if total < 50000: total += 3000 print(total)

헬스장 출석률

Python
5 months ago
Days = [1, 3, 5, 10, 20] attendance = len(Days) oneday = 100 / 30 answer = attendance * oneday print(answer)

편의점 2+1 행사

Python
5 months ago
price = 1500 count = 5 free = count // 3 pay_count = count - free answer = price * pay_count print(answer)

요금 정산기

Python
5 months ago
Time = 55 total = 0 if Time - 30 < 0: total += 2000 else: total += 2000 Time -= 30 while Time >= 0: total += 500

카페 스탬프 쿠폰

Python
5 months ago
Current = 8 New = 5 total = 0 count = 0 total = Current + New while total >= 10: total -= 10 count += 1

상자 고르기

Python
5 months ago
Prod=[10, 20, 10] Box=[15, 25, 15] count = 0 for i in range(0,len(Box)): if Box[i] >= Prod[i]: count += 1 if count >= 3: print("True")

자료구조 구현

Python
5 months ago
class Stack: def __init__(self): self.items = [] def is_empty(self): return len(self.items) == 0 def push(self, item): self.items.append(item)

커피 머신 시뮬레이션

Python
5 months ago
class CoffeeMachine: def __init__(self, water, coffee_beans, cups): self.water = water self.coffee_beans = coffee_beans self.cups = cups def make_coffee(self, coffee_type): if coffee_type == "espresso":

학생 성적 통계

Python
5 months ago
class Student: students = [] def __init__(self, name, scores): self.name = name self.scores = scores Student.students.append(self) def get_average(self): return sum(self.scores) / len(self.scores) if sel

쇼핑카트 시스템

Python
5 months ago
class ShoppingCart: def __init__(self): self.items = [] def add_item(self, name, price): self.items.append({"name": name, "price": price}) def remove_item(self, name): self.items = [item for item in self.items i

좌표 간 거리 계산

Python
5 months ago
import math class Point: def __init__(self, x, y): self.x = x self.y = y def distance(self, other_point): return math.sqrt( (self.x - other_point.x) ** 2 +

직원 급여 관리

Python
5 months ago
class Employee: employee_count = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.employee_count += 1 def apply_raise(self, percent): self.salary += self.salary * (perce

계산기 상속

Python
5 months ago
class Calculator: def add(self, a, b): return a + b def subtract(self, a, b): return a - b class ScientificCalculator(Calculator): def square(self, n): return n ** 2