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 quicksort = function(seq){ | |
if(seq.length<=1){ | |
return seq; | |
} | |
var pivot = seq[0]; | |
var left = new Array(); | |
var right = new Array(); | |
for(var i=1; i<seq.length; i++){ | |
if(pivot>seq[i]){ | |
left.push(seq[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
/* | |
* array = new Array(1,2,3,2,4); | |
* => array (1,2,3,2,4) | |
* array.delte(2); | |
* => array (1,3,4) | |
*/ | |
Array.prototype.delete = function(v) { | |
var check = false; | |
for (var i in this) { | |
if (this[i] == v) { |
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
<!-- | |
Snake Game | |
version: 0.3 | |
created at: 2013/04/11 | |
author: yutaono | |
--> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset=utf-8> |
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
# -- coding: utf-8 | |
require "open-uri" | |
require "rubygems" | |
require "nokogiri" | |
url = "https://gist.github.com/" | |
charset = nil | |
html = open(url) do |f| |
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
#!/bin/bash | |
# | |
# Fizz-Buzz Problem Solver by Shell Script | |
# | |
for i in `seq 1 30` | |
do | |
if [ `expr $i % 3` -eq 0 ] && [ `expr $i % 5` -eq 0 ]; then | |
echo "fizzbuzz" |
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
// *を使って次の図を書くプログラムを作成せよ。ただし、必ずfor文を使用すること | |
// | |
// * | |
// ** | |
// *** | |
// **** | |
// *** | |
// ** | |
// * | |
// |
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
(load (expand-file-name (concat (getenv "HOME") "/.emacs.d/common.el"))) |
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
private int gcd(int m, int n) { | |
int r = m % n; | |
if (r == 0) { | |
return n; | |
} | |
return gcd(n, r); | |
} |
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
# coding: utf-8 | |
import math | |
def eratosthenes(x): | |
sieve = [] | |
prime = [] | |
for num in range(2, x): | |
sieve.append(num) |
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 scala.io.Source | |
val source = Source.fromFile("triangle.txt") | |
val triangle = collection.mutable.Map[Int, List[Int]]() | |
source.getLines foreach { line => | |
triangle += triangle.size -> line.split(" ").map(_.toInt).toList | |
} | |
def neighborsMaxList(list: List[Int]): List[Int] = list match { | |
case l if l.length == 1 => Nil |
OlderNewer