K

@kimjuha19

숫자 뒤집기 합치기

Python
7 months ago
a,b = input().split() a = int(a[::-1]) b = int(b[::-1]) result = a + b print(int(str(result)[::-1]))

달력

C
7 months ago
#include <stdio.h> int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char *week[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; int main() { int y,m,d; scanf("%d %d %d", &y, &m, &d);

딕셔너리 값 기준 정렬

Python
7 months ago
crypto = {'BTC': 40000, 'ETH': 2500, 'SOL': 80} sorted_items = sorted(crypto.items(), key=lambda x: x[1], reverse=True) print(sorted_items)

두 리스트의 교집합 구하기

Python
7 months ago
lst1 = [1,2,3,4] lst2 = [3,4,5,6] intersection = list(set(lst1) & set(lst2)) intersection = list(set(lst1).intersection(lst2)) print( intersection)

리스트 평탄화 (2 차원 → 1 차원)

Python
7 months ago
def lists(lst): result = [] for item in lst: if type(item) == list: result += lists(item) else: result += [item] return result

단어 길이 사전 만들기

Python
7 months ago
sentence = "Bitcoin is secure and decentralized" words = sentence.split() word_length_dict = {word: len(word) for word in words} print(word_length_dict)

단어 등장 횟수 세기

Python
7 months ago
text = "to be or not to be" words = text.split() word_counts = {} for word in words: if word in word_counts: word_counts[word] += 1 else: word_counts[word] = 1

문자 뒤집고 같은지 확인

Python
7 months ago
word = input().strip() if word == word[::-1]: print("YES") else: print("NO")

리스트 중복 제거

Python
7 months ago
list = [1, 2, 2, 3, 4, 4, 5] result = [] for i in list: if i not in result: result.append(i) print(result)

COS PRO 2(시작 날짜와 끝 날짜의 사이 날짜구하기)

Python
7 months ago
def func_a(month, day): month_list = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] total = 0; for i in range(month - 1): total += month_list[i] total += day return total - 1 def solution(startmonth, startday, endmonth, endday): starttota

COS PRO 2(쇼핑몰 등급별 할인 금액구하기)

Python
7 months ago
def solution(price, grade): discount = { 'S': 0.05, 'G': 0.10, 'V': 0.15 } discountedprice = int(price * (1 - discount[grade])) return discountedprice

COS PRO 2(단체 티셔츠를 주문하기)

Python
7 months ago
def solution(shirtsize): sizes = ["XS", "S", "M", "L", "XL", "XXL"] answer = [] for i in sizes: answer.append(shirtsize.count(i)) return answer shirt_order=["XS", "S", "L", "L", "XL", "S"] a = solution(shirt_order);

대표값 구하기

Python
7 months ago
n = int(input()) scores = list(map(int, input().split())) avg = round(sum(scores) / n) min_diff = float('inf') answer = 0 for s in scores: diff = abs(s - avg) if diff < min_diff or (diff == min_diff and s > answer):

두 리스트에서 공통 원소 찾기

Python
7 months ago
A = list(map(int, input().split())) B = list(map(int, input().split())) common = sorted(set(A) & set(B)) print(common)

숫자 뒤집어서 비교하기

Python
7 months ago
a, b = input().split() arev = int(a[::-1]) brev = int(b[::-1]) print(max(arev, brev))

소수의 개수 구하기

Python
7 months ago
def is_prime(x): if x < 2: return False for i in range(2, int(x**0.5) + 1): if x % i == 0: return False return True N = int(input()) nums = list(map(int, input().split()))

피보나치 수열 N번째 항

Python
7 months ago
n = int(input()) a,b = 0, 1 for i in range(n-1): a,b = b, a + b print(b)

숫자 자리수 합

Python
7 months ago
s = input() count = 0 for ch in s: if ch.isdigit(): count += int(ch) print(count)

구구단 출력

Python
7 months ago
N = int(input()) for i in range(1, 10): print(f"{N} x {i} = {N * i}")

숫자 뒤집기

Python
7 months ago
num = int(input()) reversed= str(num)[::-1] reversed = int(reversed) print(reversed)