repo.or.cz
/
aoc_eblake.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
day 16 optimize
[aoc_eblake.git]
/
2015
/
advent1.sh
blob
f8c1888ae0b40d88b6876d558e81e08187a8ec22
1
# part 1
2
echo
$
((
$
(
tr
-d -c
\
( <
day1.input |
wc
-c
) -
\
3
$
(
tr
-d -c
\
) <
day1.input |
wc
-c
) ))
4
5
6
# part 2
7
i
=
0
floor
=
0
8
for
act
in
$
(
sed
's/(/ +1/g; s/)/ -1/g'
<
day1.input
);
do
9
i
=
$
((
i
+
1
))
floor
=
$
((
floor
$act
))
10
if
test
$floor
-lt
0
;
then
11
echo
$i
12
break
13
fi
14
done