Skip to content

Instantly share code, notes, and snippets.

N = _fArgs[0]

P1 = N[0]
P2 = N[1]
P3 = N[2]

// area - check http://www.gottfriedville.net/mathtools/triarea.html
Area = Math.abs((P1[0]*(P2[1]-P3[1]) + P2[0]*(P3[1]-P1[1]) + P3[0]*(P1[1]-P2[1]))/2)
function length_of_factorial(N) {
    if (N < 2) return 1;
    sum = 0;
    for (i = 2; i <= N; i++) {
        sum += Math.log(i) / Math.log(10)
    }

    return Math.floor(sum) + 1
}
@hueitan
hueitan / Journey-to-the-Moon.js
Last active June 2, 2022 01:01
Journey to the Moon JavaScript Solution
function processData(input) {
var temp = input.split('\n')
var [ N, I ] = temp.shift().split(' ').map( Number )
// generate graph
var graph = [] // store in an array of Set [ 0 : [ 0, 1 ], 1 : [ 3, 2 ] ] (to prevent duplicate)
var relationalMap = {} // use to remember the map { 0 : 0, 1 : 0, 2 : 1, 3 : 1 }
for(let i = 0; i < I;i++)
{