python3 Beatty sequence와 Python decimal 관련 메모메모 0. 들어가며 google foobar 문제를 풀다 마주한 Sequence와 Python 내 소숫점 처리에 관한 몇가지 메모다. 생각보다 수 감각이라는게 쉽지 않다. 1. Beatty Sequence floor (i * sqrt(2)) 가 주어지고, 1 2023. 9. 23. [기타] Dynamic Programming, 1부터 N까지의 정수를 이용해 합이 M인 배열 찾아보기 0. 들어가며. 코드가지고 꼼지락 거릴 일이 있다가, 저런 문제가 있었다. 처음에는 어라, Brute Force로 순회돌면 되지 않나? 했다가, N이 20넘어가면서부터 랩탑이 따끈해졌다. 그래서 남기는 코드 기록. 1. 직접 순회하기. from itertools import combinations def count_combinations(n): count = 0 numbers = list(range(1, 101)) for r in range(1, n + 1): for combination in combinations(numbers, r): if sum(combination) == 100: count += 1 return count n = 100 combinations = count_combinations.. 2023. 6. 23. LeetCode - Two Sum (Python) 문제개요 Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. 2 2020. 11. 23. 이전 1 다음