This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" | |
src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script>//<![CDATA[ | |
$(document).ready(function(){ | |
var p = function(val){ | |
$("#result").append(val+"<br/>"); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML5> | |
<meta charset=\"UTF-8\"/> | |
<html> | |
<title>Google Employment Exam</title> | |
<body> | |
1<br/> | |
11<br/> | |
21<br/> | |
1211<br/> | |
111221<br/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1..1000000) .each {|i| | |
result=(i%FIZZ_NUM==0 ? "Fizz":"")+(i%BUZZ_NUM==0 ? "Buzz":"") | |
p result.empty? ? i.to_s : result | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
################################################## | |
# | |
# author: Hiroshi Kori | |
# Extract csv from DML in a specific format: | |
# INSERT INTO `table_name` (`column1`, `column2`, ..) VALUES | |
# (value1, value2, ..), | |
# (value1, value2, ..), | |
# (value1, value2, ..); | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Environment | |
import System.Directory | |
import System.IO | |
import Data.List | |
import Control.Exception | |
dispatch :: String -> [String] -> IO () | |
dispatch "add" = add | |
dispatch "view" = view | |
dispatch "remove" = remove |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sleepSort = function(array){ | |
for (var i=0, length=array.length; i<length; i+=1) { | |
setTimeout((function(n){ | |
return function(){ | |
console.log(n); | |
}; | |
})(array[i]), array[i]*100); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bubbleSort = function(array) { | |
for (var i=0, length=array.length; i<length; i+=1) { | |
for (var j=0; j<array.length-i-1; j+=1) { | |
if (array[j]>array[j+1]) { | |
var smallNum = array[j+1]; | |
array[j+1]=array[j]; | |
array[j]=smallNum; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var combSort = function (array) { | |
var interval = Math.floor(array.length/1.3); | |
while (interval > 0) { | |
for(var i=0; i+interval<array.length; i+=1) { | |
if (array[i] > array[i+interval]) { | |
var small = array[i+interval]; | |
array[i+interval] = array[i]; | |
array[i] = small; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var selectionSort = function(array) { | |
for(var i=0, length=array.length; i<length; i+=1) { | |
var min_i = i; | |
for(var j=i+1; j<length; j+=1) { | |
if (array[j] < array[min_i]) { | |
min_i = j; | |
} | |
} | |
var small = array[min_i]; | |
array[min_i] = array[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var insertionSort = function(array) { | |
for(var i=1, length=array.length; i<length; i+=1) { | |
var insertion = array[i], j=i; | |
if (insertion < array[i-1]) { | |
do { | |
array[j] = array[j-1]; | |
j-=1; | |
} while (array[j] > insertion && j > 0) | |
array[j] = insertion; | |
} |
OlderNewer