![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/526ddf2afc9d509f3427a7f73121fd4f.png)
count(){
a=0
b=0
c=0
d=0
for((i=0;i<=${#aw[*]};i++))
do
case ${aw[${i}]} in
a)
a=`expr $a + 1`
;;
b)
b=`expr $b + 1`
;;
c)
c=`expr $c + 1`
;;
d)
d=`expr $d + 1`
;;
esac
done
num=($a $b $c $d)
return $num
}
fun_2(){
case ${aw[1]} in
a)
if [ ${aw[4]} == c ]
then
return 1
fi
;;
b)
if [ ${aw[4]} == d ]
then
return 1
fi
;;
c)
if [ ${aw[4]} == a ]
then
return 1
fi
;;
d)
if [ ${aw[4]} == b ]
then
return 1
fi
;;
esac
return 0
}
fun_3(){
case ${aw[2]} in
a)
if [[ ${aw[2]} != ${aw[1]} && ${aw[2]} != ${aw[3]} && ${aw[2]} != ${aw[5]} && ${aw[1]} == ${aw[3]} && ${aw[3]} == ${aw[5]} ]]
then
return 1
fi
;;
b)
if [[ ${aw[5]} != ${aw[1]} && ${aw[5]} != ${aw[2]} && ${aw[5]} != ${aw[3]} && ${aw[1]} == ${aw[2]} && ${aw[2]} == ${aw[3]} ]]
then
return 1
fi
;;
c)
if [[ ${aw[1]} != ${aw[2]} && ${aw[1]} != ${aw[3]} && ${aw[1]} != ${aw[5]} && ${aw[1]} == ${aw[2]} && ${aw[2]} == ${aw[3]} ]]
then
return 1
fi
;;
d)
if [[ ${aw[3]} != ${aw[1]} && ${aw[3]} != ${aw[2]} && ${aw[3]} != ${aw[5]} && ${aw[1]} == ${aw[2]} && ${aw[2]} == ${aw[5]} ]]
then
return 1
fi
;;
esac
return 0
}
fun_4(){
case ${aw[3]} in
a)
if [ ${aw[0]} == ${aw[4]} ]
then
return 1
fi
;;
b)
if [ ${aw[1]} == ${aw[6]} ]
then
return 1
fi
;;
c)
if [ ${aw[0]} == ${aw[8]} ]
then
return 1
fi
;;
d)
if [ ${aw[5]} == ${aw[9]} ]
then
return 1
fi
;;
esac
return 0
}
fun_5(){
case ${aw[4]} in
a)
if [ ${aw[4]} == ${aw[7]} ]
then
return 1
fi
;;
b)
if [ ${aw[4]} == ${aw[3]} ]
then
return 1
fi
;;
c)
if [ ${aw[4]} == ${aw[8]} ]
then
return 1
fi
;;
d)
if [ ${aw[4]} == ${aw[6]} ]
then
return 1
fi
;;
esac
return 0
}
fun_6(){
case ${aw[5]} in
a)
if [[ ${aw[7]} == ${aw[1]} && ${aw[7]} == ${aw[3]} ]]
then
return 1
fi
;;
b)
if [[ ${aw[7]} == ${aw[0]} && ${aw[7]} == ${aw[5]} ]]
then
return 1
fi
;;
c)
if [[ ${aw[7]} == ${aw[2]} && ${aw[7]} == ${aw[9]} ]]
then
return 1
fi
;;
d)
if [[ ${aw[7]} == ${aw[4]} && ${aw[7]} == ${aw[8]} ]]
then
return 1
fi
;;
esac
return 0
}
fun_7(){
count $aw
num=$?
min=${num[0]}
index=0
cou=0
for((i=1;i<4;i++))
do
if [[ $min -gt ${num[$i]} ]]
then
min=${num[$i]}
fi
done
for((i=1;i<4;i++))
do
if [[ $min -eq ${num[$i]} ]]
then
cou=`expr $cou + 1`
fi
done
if [[ $cou -ne 1 ]]
then
return 0
fi
case ${aw[6]} in
a)
if [[ ${num[2]} -lt ${num[0]} && ${num[2]} -lt ${num[1]} && ${num[2]} -lt ${num[3]} ]]
then
return 1
fi
;;
b)
if [[ ${num[1]} -lt ${num[0]} && ${num[1]} -lt ${num[2]} && ${num[1]} -lt ${num[3]} ]]
then
return 1
fi
;;
c)
if [[ ${num[0]} -lt ${num[1]} && ${num[0]} -lt ${num[2]} && ${num[0]} -lt ${num[3]} ]]
then
return 1
fi
;;
d)
if [[ ${num[3]} -lt ${num[0]} && ${num[3]} -lt ${num[1]} && ${num[3]} -lt ${num[2]} ]]
then
return 1
fi
;;
esac
return 0
}
fun_8(){
case ${aw[0]} in
a)
l=''
m=a
r=b
;;
b)
l=a
m=b
r=c
;;
c)
l=b
m=c
r=d
;;
d)
l=c
m=d
r=''
;;
esac
case ${aw[7]} in
a)
if [[ ${aw[6]} != $l && ${aw[6]} != $m && ${aw[6]} != $r ]]
then
return 1
fi
;;
b)
if [[ ${aw[4]} != $l && ${aw[4]} != $m && ${aw[4]} != $r ]]
then
return 1
fi
;;
c)
if [[ ${aw[1]} != $l && ${aw[1]} != $m && ${aw[1]} != $r ]]
then
return 1
fi
;;
d)
if [[ ${aw[9]} != $l && ${aw[9]} != $m && ${aw[9]} != $r ]]
then
return 1
fi
;;
esac
return 0
}
fun_9(){
if [[ ${aw[0]} == ${aw[5]} ]]
then
aw_1_6=1
else
aw_1_6=0
fi
case ${aw[8]} in
a)
if [ ${aw[5]} == ${aw[4]} ]
then
aw_x_5=1
else
aw_x_5=0
fi
;;
b)
if [ ${aw[4]} == ${aw[9]} ]
then
aw_x_5=1
else
aw_x_5=0
fi
;;
c)
if [ ${aw[1]} == ${aw[4]} ]
then
aw_x_5=1
else
aw_x_5=0
fi
;;
d)
if [ ${aw[8]} == ${aw[4]} ]
then
aw_x_5=1
else
aw_x_5=0
fi
;;
esac
rs=`expr $aw_x_5 + $aw_1_6`
if [[ rs -eq 1 ]]
then
return 1
fi
return 0
}
fun_10(){
count $aw
num=$?
min=${num[0]}
max=${num[0]}
for((i=1;i<4;i++))
do
if [[ $max -lt ${num[$i]} ]]
then
max=${num[$i]}
fi
if [[ $min -gt ${num[$i]} ]]
then
min=${num[$i]}
fi
done
temp=`expr $max - $min`
case ${aw[9]} in
a)
if [[ $temp -eq 3 ]]
then
return 1
fi
;;
b)
if [[ $temp -eq 2 ]]
then
return 1
fi
;;
c)
if [[ $temp -eq 4 ]]
then
return 1
fi
;;
d)
if [[ $temp -eq 1 ]]
then
return 1
fi
;;
esac
return 0
}
isTrue(){
rs=1
for((question=2;question<=10;question++))
do
if [ ${rs} -eq 0 ]
then
return 0
fi
case $question in
2)
fun_2 ${aw}
rs=$?
;;
3)
fun_3 ${aw}
rs=$?
;;
4)
fun_4 ${aw}
rs=$?
;;
5)
fun_5 ${aw}
rs=$?
;;
6)
fun_6 ${aw}
rs=$?
;;
7)
fun_7 ${aw}
rs=$?
;;
8)
fun_8 ${aw}
rs=$?
;;
9)
fun_9 ${aw}
rs=$?
;;
10)
fun_10 ${aw}
rs=$?
;;
esac
done
return 1
}
fun(){
for aw_1 in a b c d
do
for aw_2 in a b c d
do
for aw_3 in a b c d
do
for aw_4 in a b c d
do
for aw_5 in a b c d
do
for aw_6 in a b c d
do
for aw_7 in a b c d
do
for aw_8 in a b c d
do
for aw_9 in a b c d
do
for aw_10 in a b c d
do
aw=(${aw_1} ${aw_2} ${aw_3} ${aw_4} ${aw_5} ${aw_6} ${aw_7} ${aw_8} ${aw_9} ${aw_10})
isTrue $aw
rs=$?
if [ $rs -eq 1 ]
then
echo ${aw[*]}
fi
done
aw_10=a
done
aw_9=a
done
aw_8=a
done
aw_7=a
done
aw_6=a
done
aw_5=a
done
aw_4=a
done
aw_3=a
done
aw_2=a
done
}
fun