Skip to content

Instantly share code, notes, and snippets.

Avatar

Huei Tan hueitan

View GitHub Profile
View frontendDevlopmentBookmarks.md
View chessboard-knight-move.md
function blackOrWhite(s) { // true: black, false: white
  var vertical = s[0].charCodeAt(0) - 'a'.charCodeAt(0) + 1;
  var horizon = s[1];
  if (vertical % 2 == 1) { // vertical odd
    if (horizon % 2 == 0) { // horizon even
      return false;
    }
    return true;
  } else { // vertical even
View anagrams.md
function numberOfAnagrams(S) {

  // S.length!/repeat!
  
  var total = factorial(S.length),
	repeat = 1,
      array = S.split('').sort();
  
  for (var i=1;i<array.length;i++) {
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 += '.';
  }
  
View ^6-^2.md

65 char

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


  while(k=--n*n*n)
	s -= k*k
  
  
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 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 trailing_zero.md
function superfactorialZeros(N) {
    var result = 0;
    for (i = 1; i <= N; i++) {
        result += zeroes(i);
    }

    return result;
}
@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 = [];
@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;
You can’t perform that action at this time.