Topic: "why wont my javascript work?" (page 1 of 2)

1 2 >
Author Post
xcrissxcrossx
[none yet]
i made a brute force script in javascript but it doesn't seem to work. can anyone find the problem(s)?

<script language="JavaScript">
var a = 0;
var b = 0;
var c = 0;
var d = 0;
var all = 0;
var aa = 0;
var bb = 0;
var cc = 0;
var dd = 0;

while (all != 6342) {
  if (c<9 && a=8 && d=5 && b=4) {
    c++;
    a = 0;
    b = 0;
    d = 0;
    done = 1;
  }
  if (a<8 && d=5 && b=4 && done=0) {
    a++;
    b = 0;
    d = 0;
    done = 1;
  }
  if (d<5 && b=4 && done=0) {
    d++;
    b = 0;
    done = 1;
  {
  if (b<4 && done=0) {
    b++;
    done = 1;
  }
  done = 0;
  aa = a * a * a * a + 80;
  bb = b * b * b * b * b * 5;
  cc = c * c * c - 110;
  dd = d * d * d * d * d + 1234;
  all = aa + bb + cc + dd;
}
document.write(a + b + c + d);
</script>
Edited by xcrissxcrossx on 13.05.2006 19:08:55
private message
theAnswer
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
1. You forgot the brackets in if-statements:
if ((c<9) && (a=8) && (d=5) && (b=4)) { etc
2. At the end some } were missing/at the wrong place.
3. Can you explain what kind of BF-Script you want to make? Then help would be easier .. :P
The output of the corrected script shows:
10111213141516171818181818181818...^^

Intended?:thumbsup:
Edited by theAnswer on 13.05.2006 19:10:27
private message
xcrissxcrossx
[none yet]
im trying to make a script that brute forces the algebra problem around the bottom of the script. i must find a, b, c, and d

btw i intend 4 numbers right next to each other
Edited by xcrissxcrossx on 13.05.2006 19:16:30
private message
xcrissxcrossx
[none yet]
i changed the script and got this.

<script language="JavaScript">
var a = 0;
var b = 0;
var c = 0;
var d = 0;
var all = 0;
var aa = 0;
var bb = 0;
var cc = 0;
var dd = 0;

while (all != 6342) {
  if ((c<9 && a=8 && d=5 && b=4)) {
    c++;
    a = 0;
    b = 0;
    d = 0;
    done = 1; }
  if ((a<8 && d=5 && b=4 && done=0)) {
    a++;
    b = 0;
    d = 0;
    done = 1; }
  if ((d<5 && b=4 && done=0)) {
    d++;
    b = 0;
    done = 1; }
  if ((b<4 && done=0)) {
    b++;
    done = 1; }
  done = 0;
  aa = a * a * a * a + 80;
  bb = b * b * b * b * b * 5;
  cc = c * c * c - 110;
  dd = d * d * d * d * d + 1234;
  all = aa + bb + cc + dd;
}
document.write(a + b + c + d);
</script>
private message
theAnswer
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
The algebra problem is unclear to me ... what are you searching for?
private message
xcrissxcrossx
[none yet]
aa = a * a * a * a + 80;
bb = b * b * b * b * b * 5;
cc = c * c * c - 110;
dd = d * d * d * d * d + 1234;
all = aa + bb + cc + dd;

all == 6342


I must find a, b, c, and d. i do not need the double letters. i also know they are all 1 digit numbers.
Edited by xcrissxcrossx on 13.05.2006 19:19:03
private message
theAnswer
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
What about:


<script type="text/javascript">
var a, b, c, d, limit = 10;
for (a = 0; a < limit; a++) {
for (b = 0; b < limit; b++) {
for (c = 0; c < limit; c++) {
for (d = 0; d < limit; d++) {
if (((a * a * a * a + 80) + (b * b * b * b * b * 5) + (c * c * c - 110) + (d * d * d * d * d + 1234)) == 6342)
alert(a + " " + b + " " + c + " " + d);
}
}
}
}
</script>


I tried it out and there's a solution :thumbsup:
Edited by theAnswer on 13.05.2006 19:24:33
private message
xcrissxcrossx
[none yet]
thanks it worked. :)
private message
Dennis29
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
2 4 1 1 within 10 ms :)
private message
theAnswer
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
JS-Bruteforce rules!! ^^ :thumbsup:

May I ask which challenge needed that? :P Or outside of tbs?
private message

Topic: "why wont my javascript work?" (page 1 of 2)

1 2 >