Skip to content

Instantly share code, notes, and snippets.

View ryoppippi's full-sized avatar
🪀
yoyo

ryoppippi ryoppippi

🪀
yoyo
View GitHub Profile
@ryoppippi
ryoppippi / CodePiece.c
Last active October 12, 2015 11:54
昨日ハノイの塔が解けなくて本読んだら再帰という概念に出くわした。あまりにも強力でくらっとした。漸化式をそのままかけてしまう。美しい。そしてこれがそのコード。 #課題 #coding #c #CodePiece
void func1(int n,int from, int to,int work,FILE *fq){
if (n>0) {
func1(n-1,from,work,to,fq);
fprintf(fq,"%d %d %d\n",n, from, to );
func1(n-1,work,to,from,fq);
}
}
@ryoppippi
ryoppippi / CodePiece.c
Created October 12, 2015 11:52
力ずくで解いたヨセフスの問題。kがならばされた人の数で、l毎に殺されていきます。本当はもっと高尚な数式とかあったけどなあ。使いたいけどそれは主旨と違う。 #coding #課題 #CodePiece
int list[k];
for ( b = 0; b < k; b++) {
list[b] = 0;
}
int alive = k;
int check = -1;
while (alive !=0) {
for (c = 0; c < l; c++) {
do {
check++;
@ryoppippi
ryoppippi / calculateNetPresentValue.swift
Last active February 4, 2016 05:12
数々のバグを乗り越えて(human errorだろ....)割引現在価値を求めるプログラムを書いた。 ミクロ受講者使うなら使ってね #CodePiece
//: Playground - noun: a place where people can play
import UIKit
func jyou(n : Double, x:Int) -> Double {
var ans = 1.0
for _ in 1...x{
ans *= n
}
return ans
@ryoppippi
ryoppippi / calculateNetPresentValue2.swift
Last active February 7, 2016 14:21
Calculate "net present value" for economics assignment
//: Playground - noun: a place where people can play
//:累乗をするための関数を定義する
func jyou(n : Double, x:Int) -> Double {
var ans = 1.0
for _ in 1...x{
ans *= n
}
return ans
}
@ryoppippi
ryoppippi / Euler18.swift
Created February 20, 2016 07:48
I solved https://projecteuler.net/problem=18 with the concept of DP!!
var cashe :Dictionary<String, Int> = [:]
func search (list: [[Int]], i:Int, j:Int) -> Int {
if cashe["\(i):\(j)"] != nil {
return cashe["\(i):\(j)"]!
}
if i > 14{
return 0
}
else {
import UIKit
let array = ["ズン", "ドコ"]
var zun = 0
while true {
let a = Int(arc4random_uniform(2))
print(array[a])
if a == 0 {
zun += 1
}
else if a == 1 && zun == 4 {
@ryoppippi
ryoppippi / NL100_0.ipynb
Last active April 16, 2017 07:53
自然言語処理100本ノック00-09 http://www.cl.ecei.tohoku.ac.jp/nlp100/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ryoppippi
ryoppippi / NL100_1.ipynb
Created April 16, 2017 08:27
自然言語処理100本ノック10-19 http://www.cl.ecei.tohoku.ac.jp/nlp100/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ryoppippi
ryoppippi / Lecture3-1.ipynb
Last active April 27, 2017 07:21
Numerical Method/Lecture3-1.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ryoppippi
ryoppippi / Lecture3-2.ipynb
Last active April 27, 2017 11:48
Lecture3-2.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.