diff --git a/2020/01/balance.c b/2020/01/balance.c index c91bef5..2fb75d3 100644 --- a/2020/01/balance.c +++ b/2020/01/balance.c @@ -44,13 +44,13 @@ void sortLine(Barrel * line) { int loadBarrel (Barrel * reservoir, Barrel b) { float capacity = b.juice + b.alcohol; - if (reservoir->juice - capacity * 0.86 >= -EPSILON - && reservoir->alcohol - capacity * 0.14 >= -EPSILON) { - reservoir->juice -= capacity * 0.86; - reservoir->alcohol -= capacity * 0.14; - return b.no; - } + if (reservoir->juice - capacity * 0.86 < -EPSILON + || reservoir->alcohol - capacity * 0.14 < -EPSILON) return 0; + + reservoir->juice -= capacity * 0.86; + reservoir->alcohol -= capacity * 0.14; + return b.no; } int balance() {