You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
노란색을 직사각형으로 채울 수 있는 가로, 세로를 찾기 위해 반복문을 돌면서 나머지가 0인 경우를 찾는다.
만약 (yx * 2) + (i * 2) + 4 가 브라운의 값과 같다면 target이므로 break한다.
💬 풀이
import Foundation
func solution(_ brown:Int, _ yellow:Int)->[Int]{varres:[Int]=[]
if yellow ==1{return[3,3]}
for i in 1...yellow /2+1{
if yellow % i ==0{letyx= yellow / i
letans=(yx *2)+(i *2)+4
if ans == brown {
res =[yx +2, i +2]
break
}}}return res
}
The text was updated successfully, but these errors were encountered:
💬 문제
https://school.programmers.co.kr/learn/courses/30/lessons/42842
💬 Idea
💬 풀이
The text was updated successfully, but these errors were encountered: