일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- Python #pakage
- 네트워크 #NW
- jgrp000032 #ocp #
- shell #shell script
- PODS #POD #pods #pod #파드 #재기동 #롤링재기동 #rolling
- Kafka #카프카
- Grid #CSS
- dify
- Swap Memory
- DB #mariaDB #SQL
- jmap #jstack
- lvm #lv #vg #pv
- NameSpace #NS
- istio #k8s #kubernetes
- 티스토리챌린지
- test #비교
- function #사용자 정의 함수
- 오블완
- Linux #wc
- publishnotreadyaddress
- lenova #레노버 #노트북
- OCP
- Excel #엑셀
- 백준 #10430
- EFK
- CI #CD #CI/CD
- dump #jattach
- EKS
- bootstrap #css #CSS
- Node #POD #Container
Archives
- Today
- Total
BEOM_IT
[programmers]python 42842 카펫 본문
728x90
반응형
# 카펫
# 전체 카펫의 크기 구하기
# 갈색은 겉 노랑은 안
#yellow = x * y
#brown = 2*(x+y) + 4
#(brown - 4)//2 = x + y
# def solution(brown, yellow):
# answer = []
# total=brown+yellow
# for i in range(1,total):
# # print(i)
# if total % i == 0 :
# answer.append(i)
# answer.reverse()
# # print(answer)
# # print(len(answer)//2)
# for i in range(len(answer)//2+1):
# a=answer.pop()
# print(a)
# if a*a==total:
# return [a,a]
# else:
# return [answer.pop(),a]
def solution(brown, yellow):
x = 0
sum = (brown - 4) // 2
for r in range(sum):
if r * (sum-r) == yellow:
x = max(r, sum-r)
break
answer = [x + 2 , sum-x + 2]
return answer
print(solution(10,2)) #[4,3]
print(solution(8,1)) # [3,3]
print(solution(24,24)) #[8,6]
728x90
반응형
'Algorithm > Python' 카테고리의 다른 글
[programmers] python 120851 숨어있는 숫자의덧셈(1) (0) | 2024.04.09 |
---|---|
[programmers]python 131701 연속 부분 수열 합의 개수 (1) | 2024.03.06 |
[programmers]python 12973 짝지어 제거하기 (1) | 2024.02.25 |
[programmers]python 12945 피보나치 수 (0) | 2024.02.16 |
[programmers]python 12924 숫자의 표현 (0) | 2024.02.16 |