Ok fixed code:
<script>
/********************************************************
******************Created by Celphi**********************
******************March 19 2016**************************
********************************************************/
var group1, group2, total;
group1 = 0;
group2 = 0;
var group3, group4, index, indx, num, number, count;
var eightdigit;
count = 0;
var eightdigitArray = [];
var s = [];
var t = [];
var u = [];
var w = [];
group3 = 0;
group4 = 0;
s = [111];
// find all numbers which give a sum of 111
// generates #s for group 3 and group 4
for (group3=0;group3<100;group3++){
for (group4=0;group4<100;group4++){
if (group3+group4 == s[0]){
t.push(String(group3)+ String(group4));
}
}
}
// adds 0s to single digit numbers
function addZero(num){
if (num<10)
num = String('0'.concat(num));
else
num = num;
return num;
}
function cycle(number){
// 13-98 range for group 3 & 4
// Find all #s which subtract to give 13-98
for (group1=0;group1<100;group1++){
for (group2=0;group2<100;group2++){
total = group1-group2;
//if (total >= 13 && total <= 99){
if (total == number){
group1 = addZero(group1);
group2 = addZero(group2);
w.push(String(group1)+ String(group2));
}
}
}
}
for (indx=12;indx<99;indx++){
cycle(indx);
for (index=0;index<w.length;index++){
eightdigit = w[index].concat(t[indx-12]);
eightdigitArray.push(eightdigit);
//document.write(eightdigitArray[index] + '<br>');
//document.write(w[index] + t[indx-12] + ' ' + count + '<br>');
count++;
}
w = [];
}
//free memory
delete group1[0];
delete group2[0];
delete group3[0];
delete group4[0];
t = w = null;
// regex
var regex, count, i;
var filtered = eightdigitArray.filter(filterme);
function filterme(val){
for (i=0;i<val.length;i++){
letter = val.charAt(i)
regex = new RegExp(letter, "g");
count = (val.match(regex) || []).length;
if (count >= 2){
return false;
}
}
return true;
}
var letter;
var val = String(4546789);
var counter = 0;
display();
function display(){
for (celphi=0;celphi<filtered.length;celphi++){
counter++;
document.write('a=' + filtered[celphi][0] + ' b=' + filtered[celphi][1] + ' c=' + filtered[celphi][2] +
' d=' + filtered[celphi][3] + ' e=' + filtered[celphi][4] + ' f=' + filtered[celphi][5] +
' g=' + filtered[celphi][6] + ' h=' + filtered[celphi][7] + ' ||counter= ' + counter + '<br>' );
}
}
</script>
There's a total of 74 ways.
a=4 b=0 c=2 d=7 e=1 f=3 g=9 h=8 ||counter= 1
a=6 b=0 c=4 d=7 e=1 f=3 g=9 h=8 ||counter= 2
a=6 b=7 c=5 d=4 e=1 f=3 g=9 h=8 ||counter= 3
a=7 b=5 c=6 d=2 e=1 f=3 g=9 h=8 ||counter= 4
a=5 b=0 c=3 d=6 e=1 f=4 g=9 h=7 ||counter= 5
a=5 b=2 c=3 d=8 e=1 f=4 g=9 h=7 ||counter= 6
a=2 b=3 c=0 d=8 e=1 f=5 g=9 h=6 ||counter= 7
a=4 b=3 c=2 d=8 e=1 f=5 g=9 h=6 ||counter= 8
a=4 b=7 c=3 d=2 e=1 f=5 g=9 h=6 ||counter= 9
a=2 b=3 c=0 d=7 e=1 f=6 g=9 h=5 ||counter= 10
a=2 b=4 c=0 d=8 e=1 f=6 g=9 h=5 ||counter= 11
a=4 b=3 c=2 d=7 e=1 f=6 g=9 h=5 ||counter= 12
a=4 b=8 c=3 d=2 e=1 f=6 g=9 h=5 ||counter= 13
a=2 b=3 c=0 d=6 e=1 f=7 g=9 h=4 ||counter= 14
a=2 b=5 c=0 d=8 e=1 f=7 g=9 h=4 ||counter= 15
a=8 b=0 c=6 d=3 e=1 f=7 g=9 h=4 ||counter= 16
a=8 b=2 c=6 d=5 e=1 f=7 g=9 h=4 ||counter= 17
a=2 b=4 c=0 d=6 e=1 f=8 g=9 h=3 ||counter= 18
a=2 b=5 c=0 d=7 e=1 f=8 g=9 h=3 ||counter= 19
a=4 b=5 c=2 d=7 e=1 f=8 g=9 h=3 ||counter= 20
a=6 b=0 c=4 d=2 e=1 f=8 g=9 h=3 ||counter= 21
a=6 b=5 c=4 d=7 e=1 f=8 g=9 h=3 ||counter= 22
a=7 b=0 c=5 d=2 e=1 f=8 g=9 h=3 ||counter= 23
a=7 b=2 c=5 d=4 e=1 f=8 g=9 h=3 ||counter= 24
a=7 b=4 c=5 d=6 e=1 f=8 g=9 h=3 ||counter= 25
a=5 b=7 c=3 d=6 e=2 f=1 g=9 h=0 ||counter= 26
a=5 b=8 c=3 d=7 e=2 f=1 g=9 h=0 ||counter= 27
a=6 b=8 c=4 d=7 e=2 f=1 g=9 h=0 ||counter= 28
a=7 b=4 c=5 d=3 e=2 f=1 g=9 h=0 ||counter= 29
a=8 b=4 c=6 d=3 e=2 f=1 g=9 h=0 ||counter= 30
a=8 b=5 c=6 d=4 e=2 f=1 g=9 h=0 ||counter= 31
a=3 b=9 c=1 d=5 e=2 f=4 g=8 h=7 ||counter= 32
a=3 b=4 c=0 d=9 e=2 f=5 g=8 h=6 ||counter= 33
a=3 b=9 c=1 d=4 e=2 f=5 g=8 h=6 ||counter= 34
a=4 b=3 c=1 d=7 e=2 f=6 g=8 h=5 ||counter= 35
a=3 b=6 c=0 d=9 e=2 f=7 g=8 h=4 ||counter= 36
a=9 b=0 c=6 d=3 e=2 f=7 g=8 h=4 ||counter= 37
a=5 b=7 c=2 d=6 e=3 f=1 g=8 h=0 ||counter= 38
a=7 b=6 c=4 d=5 e=3 f=1 g=8 h=0 ||counter= 39
a=9 b=5 c=6 d=4 e=3 f=1 g=8 h=0 ||counter= 40
a=4 b=8 c=1 d=6 e=3 f=2 g=7 h=9 ||counter= 41
a=5 b=0 c=1 d=8 e=3 f=2 g=7 h=9 ||counter= 42
a=8 b=6 c=5 d=4 e=3 f=2 g=7 h=9 ||counter= 43
a=4 b=8 c=1 d=2 e=3 f=6 g=7 h=5 ||counter= 44
a=4 b=5 c=0 d=6 e=3 f=9 g=7 h=2 ||counter= 45
a=8 b=0 c=4 d=1 e=3 f=9 g=7 h=2 ||counter= 46
a=8 b=5 c=4 d=6 e=3 f=9 g=7 h=2 ||counter= 47
a=6 b=9 c=2 d=8 e=4 f=1 g=7 h=0 ||counter= 48
a=9 b=3 c=5 d=2 e=4 f=1 g=7 h=0 ||counter= 49
a=5 b=2 c=0 d=9 e=4 f=3 g=6 h=8 ||counter= 50
a=5 b=7 c=0 d=9 e=4 f=8 g=6 h=3 ||counter= 51
a=5 b=7 c=0 d=8 e=4 f=9 g=6 h=2 ||counter= 52
a=8 b=0 c=3 d=1 e=4 f=9 g=6 h=2 ||counter= 53
a=7 b=4 c=2 d=3 e=5 f=1 g=6 h=0 ||counter= 54
a=7 b=9 c=2 d=8 e=5 f=1 g=6 h=0 ||counter= 55
a=9 b=3 c=4 d=2 e=5 f=1 g=6 h=0 ||counter= 56
a=9 b=8 c=4 d=7 e=5 f=1 g=6 h=0 ||counter= 57
a=8 b=4 c=2 d=3 e=6 f=1 g=5 h=0 ||counter= 58
a=9 b=8 c=3 d=7 e=6 f=1 g=5 h=0 ||counter= 59
a=7 b=5 c=1 d=3 e=6 f=2 g=4 h=9 ||counter= 60
a=7 b=2 c=0 d=9 e=6 f=3 g=4 h=8 ||counter= 61
a=7 b=5 c=1 d=2 e=6 f=3 g=4 h=8 ||counter= 62
a=9 b=0 c=2 d=7 e=6 f=3 g=4 h=8 ||counter= 63
a=9 b=5 c=2 d=7 e=6 f=8 g=4 h=3 ||counter= 64
a=9 b=6 c=2 d=5 e=7 f=1 g=4 h=0 ||counter= 65
a=8 b=6 c=1 d=4 e=7 f=2 g=3 h=9 ||counter= 66
a=8 b=4 c=0 d=9 e=7 f=5 g=3 h=6 ||counter= 67
a=8 b=9 c=1 d=4 e=7 f=5 g=3 h=6 ||counter= 68
a=9 b=0 c=1 d=4 e=7 f=6 g=3 h=5 ||counter= 69
a=9 b=4 c=1 d=8 e=7 f=6 g=3 h=5 ||counter= 70
a=8 b=4 c=0 d=5 e=7 f=9 g=3 h=2 ||counter= 71
a=8 b=5 c=0 d=6 e=7 f=9 g=3 h=2 ||counter= 72
a=9 b=3 c=0 d=7 e=8 f=6 g=2 h=5 ||counter= 73
a=9 b=3 c=0 d=6 e=8 f=7 g=2 h=4 ||counter= 74
Math complete.