Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * One of the final puzzles in Resident Evil 3 (PSX). This puzzle is obnoxious.
- * Use this tool to crack the puzzle if you've been beating your
- * head against a wall and lost track of what the initial puzzle state was
- *
- * To use: (rudimentary javascript knowledge recommended)
- * 1. paste this script into a javascript console but don't hit enter
- * 2. go to the top of the pasted script and make sure the four arrays match the game
- * 3. hit enter
- *
- * The gauges are in 8 groups of 2, and shift 2 units, as such there are 8^3=512
- * combinations possible printarray() prints the array as it appears in-game,
- * i.e. in 8 groups of 2
- *
- * When bruteforce() is run, it will tell you how many times you need to shift each
- * channel left to solve the puzzle.
- * Shifts in this crack are always left because why over-complicate things.
- * And since this is mod 8, you can subtract from 8 to get the equivalent right
- * shift count.
- * In the state shown below, the output is 0, 6, 2, which also means 0 2R 2L
- *
- * -Braden
- */
- let want = [2,1,1,1,3,0,2,0,2,1,3,1,1,0,2,1];
- let A = [1,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1];
- let B = [1,0,1,0,1,0,1,1,0,0,1,0,0,0,0,0];
- let C = [1,0,0,0,1,1,0,0,1,0,1,0,0,0,1,0];
- function shift(array){
- return array.slice(2).concat(array.slice(0,2));
- }
- function printarray(arr){
- let outbuf = "";
- for(let i = 0; i < arr.length; i += 2)
- outbuf += arr[i] + "" + arr[i+1] + " ";
- console.log(outbuf);
- }
- function test(a,b,c){
- let result = a.map((x, i) => x + b[i] + c[i]);
- printarray(want);
- printarray(result);
- for(let i = 0; i < result.length; ++i)
- if(result[i] != want[i])
- return false;
- return true;
- }
- function nshift(arr, n){
- let out = arr;
- for(let i = 0; i < n; ++i)
- out = shift(out);
- return out;
- }
- function ntest(a,b,c){
- return test(nshift(A, a), nshift(B, b), nshift(C, c));
- }
- function bruteforce(){
- /* cubic loop, 512 iterations max */
- for(let a = 0; a < 8; ++a)
- for(let b = 0; b < 8; ++b)
- for(let c = 0; c < 8; ++c)
- if(ntest(a,b,c))
- return console.log(`${a} left, ${b} left, ${c} left`);
- }
- bruteforce();
Add Comment
Please, Sign In to add comment