Skip to content

Instantly share code, notes, and snippets.

@yutaono
yutaono / quicksort.js
Last active December 15, 2015 23:59
JavaScriptでクイックソート実装
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]);
@yutaono
yutaono / delete.js
Created April 9, 2013 10:33
JavaScriptで配列からある要素全て削除するdelete関数をArrayメソッドに定義
/*
* 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) {
<!--
Snake Game
version: 0.3
created at: 2013/04/11
author: yutaono
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
@yutaono
yutaono / url2titile.rb
Created October 4, 2013 15:42
urlからtitleを取得するスクリプト
# -- coding: utf-8
require "open-uri"
require "rubygems"
require "nokogiri"
url = "https://gist.github.com/"
charset = nil
html = open(url) do |f|
@yutaono
yutaono / fizzbuzz.sh
Created February 11, 2014 06:53
Fizz-Buzz Problem Solver by Shell Script
#!/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"
// *を使って次の図を書くプログラムを作成せよ。ただし、必ずfor文を使用すること
//
// *
// **
// ***
// ****
// ***
// **
// *
//
@yutaono
yutaono / gist:10612219
Last active August 29, 2015 13:59
.emacs
(load (expand-file-name (concat (getenv "HOME") "/.emacs.d/common.el")))
@yutaono
yutaono / gcd.java
Created May 2, 2014 08:32
最大公約数をユークリッドの互除法で求める
private int gcd(int m, int n) {
int r = m % n;
if (r == 0) {
return n;
}
return gcd(n, r);
}
@yutaono
yutaono / eratosthenes.py
Last active August 29, 2015 14:01
Sieve of Eratosthenes by python.
# coding: utf-8
import math
def eratosthenes(x):
sieve = []
prime = []
for num in range(2, x):
sieve.append(num)
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