repl.it
@CarlyRaeJepsenS/

Beautiful Hexagons

Nodejs

Running snippets of node.

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let arr = [1,12,2,3,1,1,2,3,1,3,4,3,1,5,0,3,2,6,1,19,1,19,9,23,1,23,9,27,1,10,27,31,1,13,31,35,1,35,10,39,2,39,9,43,1,43,13,47,1,5,47,51,1,6,51,55,1,13,55,59,1,59,6,63,1,63,10,67,2,67,6,71,1,71,5,75,2,75,10,79,1,79,6,83,1,83,5,87,1,87,6,91,1,91,13,95,1,95,6,99,2,99,10,103,1,103,6,107,2,6,107,111,1,13,111,115,2,115,10,119,1,119,5,123,2,10,123,127,2,127,9,131,1,5,131,135,2,10,135,139,2,139,9,143,1,143,2,147,1,5,147,0,99,2,0,14,0]

///*
for (i = 0; i < arr.length + 1; i += 4) {
  if (arr[i] == 1) {
    let a = i + 1;
    let b = i + 2;
    let newNumber = arr[arr[a]] + arr[arr[b]];
    arr[arr[i + 3]] = newNumber;
  } else if (arr[i] == 2) {
    let c = i + 1;
    let d = i + 2;
    let newNumber2 = arr[arr[c]] * arr[arr[d]];
    arr[arr[i + 3]] = newNumber2;
  } else if (arr[i] == 99) {
    console.log(`The program has terminated at position ${i}`);
  }
}
console.log(arr[0]);
//*/