X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2019.git/blobdiff_plain/bcb44f33292aa19afb49b6aafb4e60631b7de6cd..24a0a2360eb2e4b4332ce45ba5888e72f970428a:/day6/get_orbits.sh?ds=sidebyside diff --git a/day6/get_orbits.sh b/day6/get_orbits.sh deleted file mode 100644 index a6d886f..0000000 --- a/day6/get_orbits.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash - -declare -A orbits -declare -A reverse_orbits - -exec 3&2 - - IFS="," - # check forwards - if [ ${#orbits[$start_point]} -gt 0 ]; then - for p in ${orbits[$start_point]}; do - if [ "$p" == "$last_start" ]; then - continue - fi - if [ $p == $end_point ]; then - echo $((offset+1)) - if [ $shortest_path -eq -1 ] || [ $offset -lt $shortest_path]; then - shortest_path=$((offset)) - fi - return 0 - else - o=$(get_path $p $end_point $start_point $((offset+1))) - if [ $? -eq 0 ]; then - if [ $shortest_path -eq -1 ] || [ $o -lt $shortest_path ]; then - shortest_path=$o - fi - fi - fi - done - fi - - # otherwise, time to check other paths - for p in ${reverse_orbits[$start_point]}; do - if [ "$p" == "$last_start" ]; then - continue - fi - if [ "$p" == "$end_point" ]; then - echo $((offset+1)) - if [ $shortest_path -eq -1 ] || [ $offset -lt $shortest_path]; then - shortest_path=$((offset)) - fi - return 0 - else - o=$(get_path $p $end_point $start_point $((offset+1))) - if [ $? -eq 0 ]; then - if [ $shortest_path -eq -1 ] || [ $o -lt $shortest_path ]; then - shortest_path=$o - fi - fi - fi - done - - echo $shortest_path -} - -#get_orbits COM 1 - -shortest_path=-1 -get_path YOU SAN "" 0 -