remove debug code, some optimization (50% speed gain)
This commit is contained in:
@@ -6,8 +6,8 @@ CMD=${0##*/}
|
|||||||
set -o noglob
|
set -o noglob
|
||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
|
|
||||||
declare -A strings
|
#declare -A strings
|
||||||
declare -a T R B L RT RR RB RL nums
|
declare -a strings T R B L RT RR RB RL nums
|
||||||
|
|
||||||
declare -i count=-1
|
declare -i count=-1
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
@@ -16,9 +16,7 @@ while read -r line; do
|
|||||||
((count++))
|
((count++))
|
||||||
num=${line##* }
|
num=${line##* }
|
||||||
num=${num%%:}
|
num=${num%%:}
|
||||||
nums[$count]="$num"
|
nums+=("$num")
|
||||||
printf "%s\n" "$num"
|
|
||||||
printf "size nums=%s\n" "${#nums[@]}"
|
|
||||||
;;
|
;;
|
||||||
\#|.)
|
\#|.)
|
||||||
strings[$count]="${strings[$count]} $line"
|
strings[$count]="${strings[$count]} $line"
|
||||||
@@ -26,12 +24,10 @@ while read -r line; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
((count--))
|
((count--))
|
||||||
#printf "string 2311=[%s]\n" "${strings[2311]}"
|
|
||||||
|
|
||||||
for key in "${!nums[@]}"; do
|
for key in "${!nums[@]}"; do
|
||||||
# shellcheck disable=SC2206
|
# shellcheck disable=SC2206
|
||||||
str=(${strings[$key]})
|
str=(${strings[$key]})
|
||||||
printf "str=%d\n" "${#str[@]}"
|
|
||||||
top="${str[0]}"
|
top="${str[0]}"
|
||||||
bottom="${str[9]}"
|
bottom="${str[9]}"
|
||||||
T+=("$top")
|
T+=("$top")
|
||||||
@@ -56,48 +52,20 @@ for key in "${!nums[@]}"; do
|
|||||||
RB+=("$flipbottom")
|
RB+=("$flipbottom")
|
||||||
RL+=("$flipleft")
|
RL+=("$flipleft")
|
||||||
|
|
||||||
printf "%d: top=%s right=%s bottom=%s left=%s\n" "$key" "$top" "$right" "$bottom" "$left"
|
|
||||||
printf "%d: fliptop=%s flipright=%s flipbottom=%s flipleft=%s\n" "$key" "$fliptop" "$flipright" "$flipbottom" "$flipleft"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
ALL=("${T[@]}" "${R[@]}" "${B[@]}" "${L[@]}" "${RT[@]}" "${RR[@]}" "${RB[@]}" "${RL[@]}")
|
ALL=("${T[@]}" "${R[@]}" "${B[@]}" "${L[@]}" "${RT[@]}" "${RR[@]}" "${RB[@]}" "${RL[@]}")
|
||||||
#ALL=("${T[@]}" "${R[@]}" "${B[@]}" "${L[@]}" "${RT[@]}" "${RL[@]}")
|
declare -i res=1 count
|
||||||
printf "%d %s\n" "${#ALL[@]}" "${ALL[0]}"
|
|
||||||
declare -i res=1
|
|
||||||
for ((i=0; i<${#nums[@]}; ++i)); do
|
for ((i=0; i<${#nums[@]}; ++i)); do
|
||||||
count=0
|
count=0
|
||||||
#printf "%d: " "$i"
|
|
||||||
#printf "%s " ${T[$i]} ${R[$i]} ${B[$i]} ${L[$i]} ${RT[$i]} ${RR[$i]} ${RB[$i]} ${RL[$i]}
|
|
||||||
#echo
|
|
||||||
|
|
||||||
for ((j=0; j<${#nums[@]}; ++j)); do
|
for t in ${T[$i]} ${R[$i]} ${B[$i]} ${L[$i]}; do
|
||||||
if ((j != i)); then
|
for s in "${ALL[@]}"; do
|
||||||
#printf "i=%d j=%d\n" "$i" "$j"
|
[[ $t == "$s" ]] && ((count++))
|
||||||
ALL=("${T[$j]}" "${R[$j]}" "${B[$j]}" "${L[$j]}" "${RT[$j]}" \
|
done
|
||||||
"${RR[$j]}" "${RB[$j]}" "${RL[$j]}")
|
|
||||||
for s in "${ALL[@]}"; do
|
|
||||||
#[[ $a == "$s" ]] && ((count++))
|
|
||||||
for t in ${T[$i]} ${R[$i]} ${B[$i]} ${L[$i]} #\
|
|
||||||
#${RT[$i]} ${RR[$i]} ${RB[$i]} ${RL[$i]}; do
|
|
||||||
do printf "match %d %s with %d %s: " "$i" "$s" "$j" "$t"
|
|
||||||
if [[ $t == "$s" ]]; then
|
|
||||||
printf "yes\n"
|
|
||||||
((count++))
|
|
||||||
else
|
|
||||||
:
|
|
||||||
printf "no\n"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
printf "COUNT(%d)=%d key=%s\n" "$i" "$count" "${nums[$i]}"
|
|
||||||
if ((count == 2)); then
|
((count ==6)) && ((res*=${nums[$i]}))
|
||||||
printf " --> %s\n" "${nums[$i]}"
|
|
||||||
((res*=${nums[$i]}))
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
printf "%s : res=%d\n" "$CMD" "$res"
|
printf "%s : res=%d\n" "$CMD" "$res"
|
||||||
|
Reference in New Issue
Block a user