2 declare -A places distances
4 while read a to b eq l
; do
5 if [[ ! ${places[$a]+set} ]]; then
10 if [[ ! ${places[$b]+set} ]]; then
18 echo "parsed ${#list[*]} places: ${list[*]}"
21 shortest
=9999999999999
25 [[ ! ${DEBUG+set} ]] && return
28 # visit seed places...
30 debug
"${indent}visit $@"
35 compute
$seed $place $
*
39 # compute seed start places... # places includes start
41 debug
"${indent}compute $@"
43 if [[ $# == 3 ]]; then
44 debug
"${indent}computed $1"
46 [[ $1 -lt $shortest ]] && shortest
=$1
47 [[ $1 -gt $longest ]] && longest
=$1
48 attempt
=$
((attempt
+1))
52 local sublist
=() seed
=$1 start
=$2 place
55 [[ $place != $start ]] && sublist
+=($place)
57 for place
in ${sublist[*]}; do
58 try
$seed $start $place ${sublist[*]}
62 # try seed start dest places... # places includes dest, but not start
64 debug
"${indent}try $@"
66 local seed
=$1 start
=$2
68 compute $
(($seed+${distances[$start.$1]})) $
*
72 echo "computed $attempt permutations, shortest $shortest, longest $longest"