Add Day 1
This commit is contained in:
commit
1fcd7bc89d
2 changed files with 33 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*input
|
||||
*test
|
31
day1
Executable file
31
day1
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/fish
|
||||
|
||||
cat $argv[1] \
|
||||
# there's definitely a more elegant way to do this,
|
||||
# but maybe not with sed, and probably not readably
|
||||
| sed -E 's/oneight/18/g;
|
||||
s/twone/21/g;
|
||||
s/threeight/38/g;
|
||||
s/fiveight/58/g;
|
||||
s/sevenine/79/g;
|
||||
s/eightwo/82/g;
|
||||
s/eighthree/83/g;
|
||||
s/nineight/98/g;
|
||||
s/zerone/01/g;
|
||||
s/one/1/g;
|
||||
s/two/2/g;
|
||||
s/three/3/g;
|
||||
s/four/4/g;
|
||||
s/five/5/g;
|
||||
s/six/6/g;
|
||||
s/seven/7/g;
|
||||
s/eight/8/g;
|
||||
s/nine/9/g;
|
||||
s/zero/0/g;
|
||||
s/[a-zA-Z]//g;
|
||||
s/([0-9]{1})[0-9]*([0-9]{1})/\1\2/g
|
||||
s/^([0-9]{1})$/\1\1/g' \
|
||||
| tr '\n' '+' \
|
||||
| sed 's/+$/\n/g;
|
||||
s/^+//g' \
|
||||
| bc
|
Loading…
Reference in a new issue