From 65e2321cbcec387dc881fddc5721cf6fe27f5e55 Mon Sep 17 00:00:00 2001 From: j-james Date: Mon, 30 Nov 2020 22:11:08 -0800 Subject: Day One: Produce clean output --- 2020/one.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/2020/one.nim b/2020/one.nim index f136ed3..adc7e86 100644 --- a/2020/one.nim +++ b/2020/one.nim @@ -1,11 +1,14 @@ import os, strutils let input = paramStr(1) +var done: bool = false for one in lines(input): for two in lines(input): - if parseInt(one) + parseInt(two) == 2020: + if parseInt(one) + parseInt(two) == 2020 and not done: echo parseInt(one) * parseInt(two) + done = true for three in lines(input): - if parseInt(one) + parseInt(two) + parseInt(three) == 2020: + if parseInt(one) + parseInt(two) + parseInt(three) == 2020 and done: echo parseInt(one) * parseInt(two) * parseInt(three) + quit() -- cgit v1.2.3-70-g09d2