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 | ||
13.05.2006 19:03:49 |
|
|
theAnswer |
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 .. The output of the corrected script shows: 10111213141516171818181818181818... Intended? |
|
Edited by theAnswer on 13.05.2006 19:10:27 | ||
13.05.2006 19:09:38 |
|
|
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 | ||
13.05.2006 19:12:34 |
|
|
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> |
|
13.05.2006 19:15:51 |
|
|
theAnswer |
The algebra problem is unclear to me ... what are you searching for? |
|
13.05.2006 19:16:36 |
|
|
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 | ||
13.05.2006 19:18:04 |
|
|
theAnswer |
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 |
|
Edited by theAnswer on 13.05.2006 19:24:33 | ||
13.05.2006 19:23:51 |
|
|
xcrissxcrossx [none yet] |
thanks it worked. |
|
13.05.2006 19:27:24 |
|
|
Dennis29 |
2 4 1 1 within 10 ms |
|
13.05.2006 19:29:11 |
|
|
theAnswer |
JS-Bruteforce rules!! May I ask which challenge needed that? Or outside of tbs? |
|
13.05.2006 19:31:12 |
|