Skip to content

Instantly share code, notes, and snippets.

View nikuuchi's full-sized avatar

uchida nikuuchi

  • Tokyo, Japan
View GitHub Profile
@nikuuchi
nikuuchi / random.sh
Created December 9, 2011 05:13
100個の8桁以下のランダムな整数を出力する。あんまりうまくない作りなので、もう少し良いものが必要になったら作る。
#!/usr/bin/env bash
for i in {0..99};\
do \
num=`expr $i % 8 + 1`\
cat /dev/urandom | tr -c -d "[:digit:]" | head -c $num |sed -e 's/^00*/1/g';\
echo '';\
done;
@nikuuchi
nikuuchi / split.cc
Created December 5, 2011 04:39
split関数の自作
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//split()
void split(string str,string delim,vector<string> *v){
int i=0;
while((i = str.find_first_of(delim)) != string::npos){
@nikuuchi
nikuuchi / fizzbuzz.ml
Created October 8, 2011 06:21
OcamlでFizzBuzz
let fizzbuzz n = match n mod 3, n mod 5 with
| 0,0 -> print_string "fizzbuzz\n"
| 0,_ -> print_string "fizz\n"
| _,0 -> print_string "buzz\n"
| _,_ -> print_int n;
print_string "\n";;
let rec loop x = match x with
| 100 -> fizzbuzz(x)
@nikuuchi
nikuuchi / brain.rb
Created August 20, 2011 12:47
テキストファイルをbrainf*ckにエンコードするスクリプト。とりあえず思いつくままに書いた。
def square op,len
s = (len**(0.5)).to_i
t = (s<8)? "+"*s : square("+",s)
m = len - (s**2)
m = (m< 8) ? op * m : square( op,m)
">"+t+"[<"+op*s+">-]<"+m
end
def encode ch,point