5 filename="${1:-small-example-p2_36.txt}"
11 while read -u 3 line; do
15 if [ "$a" == "start" ] || [ "$b" == "end" ]; then
16 if [ "${links[$a]+abc}" ]; then
24 if [ "$a" == "end" ] || [ "$b" == "start" ]; then
25 if [ "${links[$b]+abc}" ]; then
33 # we actually want it to go both ways, so we'll
35 if [ "${links[$a]+abc}" ]; then
41 if [ "$a" != "start" ]; then
42 if [ "${links[$b]+abc}" ]; then
55 local -a previous_points=("$@")
56 local -a new_previous_path=()
59 local have_dupe_lowercase=0
61 local -A __previous_points
63 for temp_point in "${previous_points[@]}"; do
64 if [ "${__previous_points[$temp_point]+abc}" ]; then
65 ((__previous_points[$temp_point]+=1))
66 if [ "${temp_point}" == "${temp_point,,}" ]; then
67 # at least 2 of this point
71 __previous_points[$temp_point]=1
75 path="${previous_points[@]}"
77 if [ "${point}" == "${point,,}" ]; then
78 if [ "${__previous_points[$point]+abc}" ]; then
79 if [ $have_dupe_lowercase -eq 1 ]; then
80 # can only go through one lowercase point twice
86 if [ "${point}" == "end" ]; then
88 if [ ! "${paths[$path]+abc}" ]; then
92 new_previous_path=("${previous_points[@]}")
93 new_previous_path+=($point)
94 for new_point in ${links[$point]}; do
95 do_path $new_point "${new_previous_path[@]}"
100 # start at start and then work through all possible paths
101 for thing in ${links["start"]}; do
105 for path in "${!paths[@]}"; do
106 echo "Got path: $path"
109 echo "Total paths: ${#paths[@]}"