Advertisement
Lenstt

Untitled

Nov 28th, 2020
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const inp = [1,12,2,3,1,1,2,3,1,3,4,3,1,5,0,3,2,9,1,19,1,9,19,23,1,23,5,27,2,27,10,31,1,6,31,35,1,6,35,39,2,9,39,43,1,6,43,47,1,47,5,51,1,51,13,55,1,55,13,59,1,59,5,63,2,63,6,67,1,5,67,71,1,71,13,75,1,10,75,79,2,79,6,83,2,9,83,87,1,5,87,91,1,91,5,95,2,9,95,99,1,6,99,103,1,9,103,107,2,9,107,111,1,111,6,115,2,9,115,119,1,119,6,123,1,123,9,127,2,127,13,131,1,131,9,135,1,10,135,139,2,139,10,143,1,143,5,147,2,147,6,151,1,151,5,155,1,2,155,159,1,6,159,0,99,2,0,14,0];
  2.  
  3. function parser(inp) {
  4.     let index = 0;
  5.     while (true) {
  6.         let opcode = inp[index];
  7.         if (opcode === 1) {
  8.             const idx_2 = inp[index + 1];
  9.             const idx_3 = inp[index + 2];
  10.             const idx_4 = inp[index + 3];
  11.            
  12.             const const1 = inp[idx_2];
  13.             const const2 = inp[idx_3];
  14.            
  15.             const res = const1 + const2;
  16.             inp[idx_4] = res;
  17.             index = index + 4;
  18.            
  19.         } else if (opcode === 2) {
  20.             const idx_2 = inp[index + 1];
  21.             const idx_3 = inp[index + 2];
  22.             const idx_4 = inp[index + 3];
  23.            
  24.             const const1 = inp[idx_2];
  25.             const const2 = inp[idx_3];
  26.            
  27.             const res = const1 * const2;
  28.             inp[idx_4] = res;
  29.             index = index + 4;
  30.            
  31.         } else if (opcode === 99) {
  32.             const res = inp[0];
  33.             return res;
  34.             break;
  35.         } else {
  36.             break;
  37.         }
  38.     }
  39. }
  40.  
  41. for (let i = 0; i < 100; i = i + 1) {
  42.     for (let j = 0; j < 100; j = j + 1) {
  43.         let inpt = [];
  44.         for (let k = 0; k < array_length(inp); k = k + 1) {
  45.             inpt[k] = inp[k];
  46.         }
  47.         inpt[1] = i;
  48.         inpt[2] = j;
  49.         if (parser(inpt) === 19690720) {
  50.             display(i);
  51.             display(j);
  52.             break;
  53.         } else {
  54.             continue;
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement