OK… I just looked at changing the criteria for using numbers 1 thru 9 to fit in format ???x?=?????
I do not believe that there are any solutions to this question. There is no 3 digit number multiplied by a single digit number that will yield a 5 digit number
just finished my 2nd bash script that cut down the time to complete from over 4 1/2 minutes to 12 seconds..
#!/bin/bash
function check {
t=$s;y=0
for x in 1 2 3 4;do
p=$(echo $t | cut -c"$x")
r[x]=$p
if [[ ${r[x]} -ne 0
&& ${r[x]} -ne 9 ]]
then y=$(($y+1));fi
done
if [ $y -eq 4 ];then cont;fi
}
#===============================================================
function cont {
y=0
for x in 1 2 3 4;do
if [[ ${r[x]} -ne $a
&& ${r[x]} -ne $b
&& ${r[x]} -ne $c
&& ${r[x]} -ne $d ]]
then y=$(($y+1));fi
done
if [ $y = 4 ];then result;fi
}
#===============================================================
function result {
y=0
for j in 1 2 3 4; do
for k in 1 2 3 4; do
v=$(($j+$k))
if [ $v -gt 4 ];then v=$(($v-4));fi
if [ $k -ne $v ];then duplicate;fi
done;done;
if [ $y = 0 ];then echo "$a$b$c X $d = $s FILLS CRITERIA!!";fi
}
#===============================================================
function duplicate {
if [ ${r[k]} = ${r[v]} ];then y=$(($y+1));fi
}
#===============================================================
date
echo " OBJECT:- Use 1 2 3 4 5 6 7 8 once only in ??? x ?? = ???? so sum is correct."
echo "WORKING!! please be patient WORKING!!"
for a in 1 2 3 4 5 6 7 8; do
for b in 1 2 3 4 5 6 7 8; do
for c in 1 2 3 4 5 6 7 8; do
for d in 1 2 3 4 5 6 7 8; do
s=$(($a$b$c*$d))
l="${#s}"
if [[ $a -ne $b
&& $a -ne $c
&& $a -ne $d
&& $b -ne $c
&& $b -ne $d
&& $c -ne $d
&& $l -eq 4 ]]
then check;fi
done;done;done;done;date;echo "FINISHED!!"
no idea how to make it as fast as the code you lot have tho,
it's not as if my i7 920@3.8ghz is slow..
and now you want ??? x ? = ?????
well first script is easy to alter for any combo, so will start it off and see..
seeing how that is impossible i'm trying ???x??=????? with 0 to 9
here's the results
terry@mainpc:~> newt1
Sat Oct 23 21:26:41 BST 2010
OBJECT:- Use 0 1 2 3 4 5 6 7 8 9 once only in ??? x ?? = ????? so sum is correct.
WORKING!! please be patient WORKING!!
297 X 54 = 16038 FILLS CRITERIA!!
345 X 78 = 26910 FILLS CRITERIA!!
367 X 52 = 19084 FILLS CRITERIA!!
396 X 45 = 17820 FILLS CRITERIA!!
402 X 39 = 15678 FILLS CRITERIA!!
495 X 36 = 17820 FILLS CRITERIA!!
594 X 27 = 16038 FILLS CRITERIA!!
715 X 46 = 32890 FILLS CRITERIA!!
927 X 63 = 58401 FILLS CRITERIA!!
Sat Oct 23 21:30:58 BST 2010
FINISHED!!
terry@mainpc:~>