전체 글
-
[프로그래머스] - 숫자 블록Algorithm/프로그래머스 2022. 7. 29. 06:10
문제 숫자 블록 https://school.programmers.co.kr/learn/courses/30/lessons/12923 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 이해 더보기 숫자 블록 문제 설명 그렙시에는 0으로 된 도로에 숫자 블록을 설치하기로 하였습니다. 숫자 블록의 규칙은 다음과 같습니다. 블록의 번호가 n 일 때, 가장 처음 블록은 n * 2번째 위치에 설치합니다. 그다음은 n * 3, 그다음은 n * 4, ...로 진행합니다.만약 기존에 블록이 깔려있는 자리라면 그 블록을빼고 새로운 블록으로 집어넣습니다. 예를 들어 1번 블..
-
[프로그래머스] - 땅따먹기Algorithm/프로그래머스 2022. 7. 29. 06:02
문제 땅따먹기 https://school.programmers.co.kr/learn/courses/30/lessons/12913# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 이해 더보기 문제 설명 땅따먹기 게임을 하려고 합니다. 땅따먹기 게임의 땅(land)은 총 N행 4열로 이루어져 있고, 모든 칸에는 점수가 쓰여 있습니다. 1행부터 땅을 밟으며 한 행씩 내려올 때, 각 행의 4칸 중 한 칸만 밟으면서 내려와야 합니다. 단, 땅따먹기 게임에는 한 행씩 내려올 때, 같은 열을 연속해서 밟을 수 없는 특수 규칙이 있습니다. 예를 들면, | 1 | ..
-
[Python] - Closure개발/Python 2022. 7. 28. 20:59
Closure 1. Nested functions A function that is defined inside another function is known as a nested function. Nested functions are able to access variables of the enclosing scope. In Python, these non-local variables can be accessed only within their scope and not outside their scope. But Closure can be access non-local variables #nested function example def nested_func(text): temp = text def te..
-
[Python] - First class functions개발/Python 2022. 7. 28. 17:55
1. First class Obejct Define 1. You can store them in Variable , Data Structure(list,dictionary .. ) 2. You can pass the function as a parameter to another function 3. You can return the function from a function. 2. First class functions Python support first class functions, it means function is instance of Object. First class functions includes First class Object properties. First class functio..
-
[Python] - Generator개발/Python 2022. 7. 28. 16:38
Generator Generator functions allow you to declare a function that behaves like an iterator, it can be used in a for loop. Generator call like iterator whenever you need 1. yield if use normal function 'return' get value , but Generator use 'yield' yield can be used to control the iteration behaviour of a loop instead of building an array containing all the values and returning them all at once,..
-
[Python] - Call by Object reference & Call by sharing개발/Python 2022. 7. 28. 15:08
1. Call by value call by value used to C programming call the function , parameter copied value and pass value arguement so, do not changed origin data within function 2. Call by reference (pointer) call by reference used to Java programming parameter copied reference = pointer (value address) so, function can access origin data by address 3. Call by object reference( Call by sharing ) Python's ..
-
[Python] - Counter개발/Python 2022. 7. 27. 20:24
Counter A Counter is a dict subclass for counting hashable objects. collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Syntax Counter([iterable-or-mapping]) from collections import Counter c = Counter('gallahad') > Counter({'a': 3, 'l': 2, 'g': 1, 'h': 1, 'd': 1}) c = Counter({'red': 4, 'blue': 2}) > Counter({'red': 4, 'blue': 2}) c = Counte..
-
[Python] - Permutation & Combination개발/Python 2022. 7. 27. 19:50
Permutation process of changing the linear order of an ordered set support itertools Permutations differ from combinations , which are selections of some members of a set regardless of order set {1, 2, 3} -> (1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1) Syntax permutations(iterable, r=None) from itertools import permutations list( permutations('ABC', 2) ) > [('A', 'B'), ('A', ..