23 for (( a=0; $a<${#values[@]}; a++ )); do
25 values_2=( "${values[@]:0:$a}" )
26 values_2+=( "${values[@]:$((a+1))}" )
28 for num2 in "${values_2[@]}"; do
29 if [ $((num1+$num2)) -eq $check ]; then
46 for (( a=0; $a<${#sum_data[@]}; a++ )); do
47 cur_sum=${sum_data[$a]}
48 local -a cur_nums=( ${sum_data[$a]} )
49 for (( b=$((a+1)); b<${#sum_data[@]}; b++ )); do
50 cur_nums+=( "${sum_data[$b]}" )
51 let cur_sum+=$((${sum_data[$b]}))
52 if [ $cur_sum -eq $check ]; then
55 elif [ $cur_sum -gt $check ]; then
64 get_lowest_highest() {
67 local highest=${hl[0]}
70 for (( a=0; a<${#hl[@]}; a++ )); do
71 if [ ${hl[$a]} -lt $lowest ]; then
73 elif [ ${hl[$a]} -gt $highest ]; then
78 echo "$lowest $highest"
82 for (( a=$preamble; a< $((${#data[@]}-1)); a++ )); do
84 declare -a check_array
85 check_array=( "${data[@]:${offset}:$window}" )
86 check_digit="${data[$a]}"
88 if ! check_for_sum check_array $check_digit; then
89 echo "$check_digit is invalid (position $((a)))"
95 echo "Doing sequential sums"
96 declare -a sum_nums=( $(sequential_sum data $check_digit) )
98 declare -a nums=( $(get_lowest_highest sum_nums) )
101 for num in "${nums[@]}"; do
105 echo "Sum of lowest (${nums[0]}) and highest (${nums[1]}) numbers: $sum"