본문 바로가기

Algorithm/Programmers

완전탐색 03 - 카펫, 프로그래머스, 알고리즘, Programmers, Stack, Queue, Hash, 코딩테스트, Algorithm, 풀이과정, Leetcode, 릿코드, 코딩테스트, Tech interview, Heap, 힙, 정렬, sort, search

 

# Process

# 1. Input brown, yellow numbers

# 2. Check the number of edges (brown)

#  2.1. If so -> Check the number of inner sector (yellow)

#   2.1.1. If so -> append to answer (width, height)

# 3. Return valid size

 

import math



def solution(brown, yellow):

    answer = []

    

    # 2.

    init_brown = math.ceil(brown / 2)

    end_brown = 3

    for width_brown in range(init_brown, end_brown-1, -1):

        height_brown = (brown - (width_brown*2)) // 2 + 2

        # 2.1.

        if (width_brown - 2) * (height_brown - 2) == yellow:

            answer.append(width_brown)

            answer.append(height_brown)

            break

    

    return answer



 

2021.03.11 - [Algorithm/Programmers] - 탐욕법 02 - 조이스틱, 프로그래머스, 알고리즘, Programmers, Stack, Queue, Hash, 코딩테스트, Algorithm, 풀이과정, Leetcode, 릿코드, 코딩테스트, Tech interview, Heap, 힙, 정렬, sort, greedy

 

탐욕법 02 - 조이스틱, 프로그래머스, 알고리즘, Programmers, Stack, Queue, Hash, 코딩테스트, Algorithm, 풀

// ASCII 65~ 90 (A~ Z) // Process #2  (greedy) // 1. Input name // 2. Make list or Map using Index and DiffCount of diff things // 3. Iterate while all list is remove..

itdar.tistory.com

2019.08.27 - [Programming] - 개발자 선배들에게서 배운 것들. Things I Learnt from a Senior Software Engineer. 코딩 잘하는 방법, how to code well, 소프트웨어,프로그래머,programmer

 

개발자 선배들에게서 배운 것들. Things I Learnt from a Senior Software Engineer. 코딩 잘하는 방법, how to cod

 

itdar.tistory.com

2019.01.12 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #59 spiralNumbers. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive

 

Aracade Intro #59 spiralNumbers. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해

Aracade Intro #59 spiralNumbers. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive Q.  Construct a square matrix with a size N × N co..

itdar.tistory.com