From e052dbd910788fb4267a28f09ee1f2e283ca4cc2 Mon Sep 17 00:00:00 2001 From: Abreu Date: Sat, 11 Sep 2021 19:47:58 -0300 Subject: [PATCH] Experimenting with assignments --- 2020/01/balance.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/2020/01/balance.c b/2020/01/balance.c index 2fb75d3..3d15bea 100644 --- a/2020/01/balance.c +++ b/2020/01/balance.c @@ -18,25 +18,21 @@ bool readInput(Barrel * line, Barrel * reservoir) { if (i % 2 == 0) { line[i / 2].no = i / 2 + 1; line[i / 2].juice = f; + continue; } - else { - if (f > 1) - return false; - line[i / 2].alcohol = f * line[i / 2].juice; - line[i / 2].juice -= line[i / 2].alcohol; - reservoir->juice += line[i / 2].juice; - reservoir->alcohol += line[i / 2].alcohol; - } + if (f > 1) + return false; + reservoir->alcohol += line[i / 2].alcohol = f * line[i / 2].juice; + reservoir->juice += line[i / 2].juice -= line[i / 2].alcohol; } return true; } void sortLine(Barrel * line) { - Barrel aux; + Barrel aux = line[0]; if (line[0].juice + line[0].alcohol > line[1].juice + line[1].alcohol) return; - aux = line[0]; line[0] = line[1]; line[1] = aux; }