From 9aa652953c205e632ea097c227c2cd14da0e6e5f Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Tue, 30 Nov 2021 22:49:02 +0100 Subject: [PATCH] add lua solution for day 0 --- Day00/Part1.lua | 8 ++++++++ clean | 2 +- prepare | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Day00/Part1.lua diff --git a/Day00/Part1.lua b/Day00/Part1.lua new file mode 100644 index 0000000..29fc5cb --- /dev/null +++ b/Day00/Part1.lua @@ -0,0 +1,8 @@ +io.input(arg[3]) +local min, max = math.huge, -math.huge +for i = 1, io.read("*n") do + local num = io.read("*n") + max = math.max(num, max) + min = math.min(num, min) +end +print(min .. " " .. max) diff --git a/clean b/clean index e077475..225afb3 100755 --- a/clean +++ b/clean @@ -4,5 +4,5 @@ part="$2" day="$(printf '%02d' "$day")" -rm -f ./run +rm -f ./run ./luac.out rm -f "Day${1}/Part${2}.hi" "Day${1}/Part${2}.o" diff --git a/prepare b/prepare index 6f493f9..5ae7ae1 100755 --- a/prepare +++ b/prepare @@ -4,7 +4,11 @@ part="$2" day="$(printf '%02d' "$day")" -if test -f "Day${day}/Part${part}.hs"; then +if test -f "Day${day}/Part${part}.lua"; then + luac -o luac.out "Day${day}/Part${part}.lua" + printf '#!/bin/sh\nlua luac.out "$@"\n' > run + chmod u+x run +elif test -f "Day${day}/Part${part}.hs"; then #stack build stack ghc -- -O3 "Day${day}/Part${part}.hs" -o run fi