Skip to content

Instantly share code, notes, and snippets.

View minsooshin's full-sized avatar

Ted Shin minsooshin

  • Lunit Inc.
  • Seoul, Korea
View GitHub Profile
class Node {
constructor(element) {
this.element = element;
this.next = null;
}
}
class LinkedList {
constructor() {
this.head = new Node('head');
const swap = (array, a, b) => {
const temp = array[a];
array[a] = array[b];
array[b] = temp;
return array;
};
function bubbleSort(array) {
const n = array.length;
let swapped = false;
const swap = (array, a, b) => {
const temp = array[a];
array[a] = array[b];
array[b] = temp;
return array;
};
function selectionSort(array) {
const n = array.length;
@minsooshin
minsooshin / insertion_sort.js
Last active July 6, 2016 05:24
Insertion Sort Algorithm
function insertSort(array) {
const n = array.length;
// loop from second element of array to last element
// because first element is first element of sorted portion
// at the beginning
for (let i = 1; i < n; i++) {
const element = array[i];
let j = i;
'use strict';
import can from 'can';
import template from './nav.stache!';
import ViewModel from './nav.viewmodel';
import './nav.less!';
import './button';
export default can.Component.extend({
init: function(element) {
// Bonfire: Missing letters
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-missing-letters
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function fearNotLetter(str) {
var start = str.charCodeAt(0);
var end = str.charCodeAt(str.length - 1);
var arr = [];
for (var i = start; i <= end; i++) {
@minsooshin
minsooshin / bonfire-arguments-optional.js
Created November 26, 2015 05:27
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Arguments Optional
// Bonfire: Arguments Optional
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-arguments-optional
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function add() {
var args = Array.prototype.slice.call(arguments),
numberType = true;
args.forEach(function(val) {
@minsooshin
minsooshin / bonfire-everything-be-true.js
Created November 26, 2015 04:31
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Everything Be True
// Bonfire: Everything Be True
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-everything-be-true
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function every(collection, pre) {
// Is everyone being true?
var falsyArr = collection.filter(function(val) {
return !(val[pre]);
});
// Bonfire: Binary Agents
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-binary-agents
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function binaryAgent(str) {
var arr = str.split(' '),
newStr = '';
arr.forEach(function(val) {
var sum = 0;
// Bonfire: Steamroller
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-steamroller
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function steamroller(arr) {
// I'm a steamroller, baby
function flatten(array, newArr) {
if (newArr === undefined) newArr = [];