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 25 optimize and improve heuristics
[aoc_eblake.git]
/
2018
/
day1b.sh
blob
424bd74ccad7c2193444350b81ef9e438bebd56e
1
declare -a
array
2
offset
=
100000
3
sum
=
0
4
array
[
offset
]=
1
5
iter
=
0
6
while
:;
do
7
echo
$
((
iter
++))
8
while
read
number
;
do
9
# echo
10
# echo $number
11
:
$
((
sum
+=
number
))
12
# echo $(( sum ))
13
if
test
"
${array[offset + sum]:+set}
"
=
set
;
then
14
echo
done
:
$sum
15
exit
16
else
17
# echo first time
18
array
[
offset
+
sum
]=
1
19
fi
20
done
<
${1:-input1}
21
done