Skip to content

Instantly share code, notes, and snippets.

😁
wow

Huei Tan hueitan

😁
wow
Block or report user

Report or block hueitan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hueitan
hueitan / Journey-to-the-Moon.js
Last active Jan 24, 2017
Journey to the Moon JavaScript Solution
View Journey-to-the-Moon.js
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++)
{
View digits_factorial.md
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
}
View three_points.md
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)
@hueitan
hueitan / spiral-order.md
Created May 10, 2015
spiral order (clockwise from top left) -
View spiral-order.md

It's from others.

function spiralMatrix(matrix) {

  var i;
  var top = 0;
  var left = 0;
  var bottom = matrix.length;
  var right = matrix[0].length;
@hueitan
hueitan / taller.md
Last active Aug 29, 2015
circle standing, who is taller challenge - https://codefights.com/feed/wG7zrPuKNMb9ppua6
View taller.md

Original answer

function Taller (N,M) {

var output = [];
// check every element
for (i=0;i<N;i++) {
   
   var temp = [];
View trailing_zero.md
function superfactorialZeros(N) {
    var result = 0;
    for (i = 1; i <= N; i++) {
        result += zeroes(i);
    }

    return result;
}
View gogo.md
function PrimeOperations(X, Y) {
var x = getPrimeFactors(X),
    y = getPrimeFactors(Y),
    k = 0;
  
  for(i=0;x[i];i++) {
    for (j=0;y[j];j++) {
      if (x[i] == y[j]) {
        k += 2;
View test.md
o = ''
b = arguments[0]

for (k in b)
  o += '                                                                                                                                                                                                  d3d4d5  d7  e6e5e4    f2  h2h1g1  e1d1c1b1  a2  c2'.substr(b[k].charCodeAt() *2,2)

return o
View ^6-^2.md

65 char

n = arguments[0]
s = n*n*++n*n/4


  while(k=--n*n*n)
	s -= k*k
  
  
View encrypt.md
function arr_encryption(msg) {
  var message = msg.split(' ').join('.'),
      output = '';
      
  // add . if needed
  for (k=0;k<message.length % 6;k++) {
    message += '.';
  }
  
You can’t perform that action at this time.