Skip to content

Commit bb6531f

Browse files
committed
some 2015
1 parent e8c0960 commit bb6531f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

2015/day02/p1.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
. ../../misc/vardump
4+
5+
FILE="$1"
6+
7+
while IFS=x read l w h; do
8+
a=$((l*w))
9+
b=$((l*h))
10+
c=$((w*h))
11+
s=$((a>b?b:a))
12+
s=$((s>c?c:s))
13+
echo $((2*a+2*b+2*c+s))
14+
done < $FILE \
15+
| paste -sd+ | bc

2015/day02/p2.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
. ../../misc/vardump
4+
5+
FILE="$1"
6+
FILE=input.txt
7+
8+
while IFS=x read l w h; do
9+
s=$((l<w?w:l))
10+
s=$((s<h?h:s))
11+
main=$(((l+w+h-s)*2))
12+
bow=$((l*w*h))
13+
echo $((main + bow))
14+
done < $FILE \
15+
| paste -sd+ | bc

0 commit comments

Comments
 (0)