Skip to content

Instantly share code, notes, and snippets.

View yoshiokatsuneo's full-sized avatar

Tsuneo Yoshioka yoshiokatsuneo

View GitHub Profile
print "aiueo";
print "iii";
@yoshiokatsuneo
yoshiokatsuneo / fibonacci.js
Created March 8, 2012 09:21
fibonacci in javascript (O(log(N)))
function multiply_matrix(a, b)
{
var c = new Array;
for(y=0;y<a.length;y++){
c[y] = new Array;
for(x=0;x<b[0].length;x++){
sum = 0;
for(i=0;i<a[0].length;i++){
sum += a[y][i] * b[i][x];
}
@yoshiokatsuneo
yoshiokatsuneo / vokaaliharmonia.dot
Created March 16, 2012 13:41
vokaaliharmonia in dot format (for graphviz)
graph G {
subgraph cluster_1{
label = "takavokaalit"
a -- o
o -- u
u -- a
}
a -- e
o -- e
teste
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
int main(void)
@yoshiokatsuneo
yoshiokatsuneo / finnish-kpt.sh
Created November 30, 2012 23:05
Finnish kpt changing in one line ruby
ruby -pe 'BEGIN{kpt="k:,p:v,t:d,kk:k,pp:p,tt:t,nk:ng,nt:nn,lt:ll,rt:rr,sk:sk,tk:tk,sp:sp,st:st"; kpt_h=Hash[*(kpt.split(/[:,]/))]}; $_.gsub!(Regexp.new("(" + kpt_h.keys.join("|") + ")(.\n?)$")){kpt_h[$1] + $2}'
@yoshiokatsuneo
yoshiokatsuneo / gist:4691533
Created February 1, 2013 14:13
voice from twitter.
ruby -r json -n -e 'print (JSON.parse($_))["text"];STDOUT.flush;' | (while read line; do say "$line"; done)
@yoshiokatsuneo
yoshiokatsuneo / rev_linked_list_finnish.cpp
Created February 22, 2013 13:46
Reverse linked list in Finnish C...
#include <stdlib.h>
#include <stdio.h>
struct node_t{
node_t *seuraava;
int val;
};
node_t *rev_linked_list(node_t *list)
{
@yoshiokatsuneo
yoshiokatsuneo / dijkstra.cpp
Last active November 2, 2016 21:00
dijkstra
#include <vector>
#include <queue>
#include <stdio.h>
using namespace std;
#define INF 1e9
class Graph{
struct edge_t{
#!/usr/bin/ruby
def normalize_pointset(pointset)
minx = 1000;
miny = 1000;
pointset.each{|p|
minx = [minx, p[0]].min
miny = [miny, p[1]].min
}
normalized_pointset = []