[Hun]

무언가 좀 더 깔삼한 방법이 있을 것 같지만...


일단 우선 적으로 만든 것(Scala)


def thePouring(capapcities:Array[Int], bottles:Array[Int], fromId:Array[Int], toId:Array[Int]) : Array[Int] = {

for(nl <- 0 until fromId.length ) {
val fromNum = fromId(nl) //시작 넘버
val toNum = toId(nl) //to 넘버

val addJuice = bottles(toNum) + bottles(fromNum)

if(capapcities(toNum) - addJuice <0) {
bottles(toNum) = capapcities(toNum)
bottles(fromNum) = addJuice - capapcities(toNum)
} else {
bottles(fromNum) = 0
bottles(toNum) = addJuice
}
}

bottles
}


'Quiz > Answer' 카테고리의 다른 글

[A2/kyu] 즐거운 파티 (또 다른 방법)  (0) 2017.12.18
[A2/kyu] 즐거운 파티 (scala)  (0) 2017.12.18
[A2/hun] 2 Answer(Invite Party)  (0) 2017.12.15
[A1] 이런 답도 있다  (0) 2017.12.12
[A1/kyu] 키위쥬스 (Scala)  (0) 2017.12.11

+ Recent posts