aboutsummaryrefslogtreecommitdiff
path: root/2017/01
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2021-12-03 14:14:40 +0100
committerThomas Voss <thomasvoss@live.com> 2021-12-03 14:14:40 +0100
commit13f17fb1180375e64e02d1a3b9bc5faacc14c588 (patch)
tree51b66a7d0dcd19372b0369a4c93cfe7b278a2f96 /2017/01
parentcacd416845e12bde1840508532474cb45e50a334 (diff)
Add 2017 Day 1 solutions
Diffstat (limited to '2017/01')
-rw-r--r--2017/01/input1
-rwxr-xr-x2017/01/puzzle-1.sh11
-rwxr-xr-x2017/01/puzzle-2.sh6
3 files changed, 18 insertions, 0 deletions
diff --git a/2017/01/input b/2017/01/input
new file mode 100644
index 0000000..4ee62ea
--- /dev/null
+++ b/2017/01/input
@@ -0,0 +1 @@
+818275977931166178424892653779931342156567268946849597948944469863818248114327524824136924486891794739281668741616818614613222585132742386168687517939432911753846817997473555693821316918473474459788714917665794336753628836231159578734813485687247273288926216976992516314415836985611354682821892793983922755395577592859959966574329787693934242233159947846757279523939217844194346599494858459582798326799512571365294673978955928416955127211624234143497546729348687844317864243859238665326784414349618985832259224761857371389133635711819476969854584123589566163491796442167815899539788237118339218699137497532932492226948892362554937381497389469981346971998271644362944839883953967698665427314592438958181697639594631142991156327257413186621923369632466918836951277519421695264986942261781256412377711245825379412978876134267384793694756732246799739464721215446477972737883445615664755923441441781128933369585655925615257548499628878242122434979197969569971961379367756499884537433839217835728263798431874654317137955175565253555735968376115749641527957935691487965161211853476747758982854811367422656321836839326818976668191525884763294465366151349347633968321457954152621175837754723675485348339261288195865348545793575843874731785852718281311481217515834822185477982342271937155479432673815629144664144538221768992733498856934255518875381672342521819499939835919827166318715849161715775427981485233467222586764392783699273452228728667175488552924399518855743923659815483988899924199449721321589476864161778841352853573584489497263216627369841455165476954483715112127465311353411346132671561568444626828453687183385215975319858714144975174516356117245993696521941589168394574287785233685284294357548156487538175462176268162852746996633977948755296869616778577327951858348313582783675149343562362974553976147259225311183729415381527435926224781181987111454447371894645359797229493458443522549386769845742557644349554641538488252581267341635761715674381775778868374988451463624332123361576518411234438681171864923916896987836734129295354684962897616358722633724198278552339794629939574841672355699222747886785616814449297817352118452284785694551841431869545321438468118
diff --git a/2017/01/puzzle-1.sh b/2017/01/puzzle-1.sh
new file mode 100755
index 0000000..2659fae
--- /dev/null
+++ b/2017/01/puzzle-1.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+
+sed '
+:l
+s/\(.\)\1/<\1>\1/g
+tl
+s/^\(.\)\(.*\)\1$/<\1>\2/
+s/>[0-9]*</+/g
+s/^[0-9]*<//
+s/>[0-9]*$//
+' input | bc
diff --git a/2017/01/puzzle-2.sh b/2017/01/puzzle-2.sh
new file mode 100755
index 0000000..f16db44
--- /dev/null
+++ b/2017/01/puzzle-2.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+
+trap 'rm -f xa[ab]' EXIT
+mid=$((`tr -d '\n' <input | wc -c` / 2))
+sed 's/./&\n/g; s/\n$//' input | split -l $mid
+paste xa[ab] | awk '$1 == $2 { s += $1 + $2 } END { print s }'