Skip to content

Instantly share code, notes, and snippets.

View boxp's full-sized avatar
👩‍💻
in reality

Keitaro Takeuchi boxp

👩‍💻
in reality
View GitHub Profile
@boxp
boxp / fibonacci.scala
Last active December 10, 2015 05:18
This code is test for scala.
object fibonacci {
def main(args: Array[String]) {
var fibonacci = List(1,1)
while(fibonacci.length < args(0).toInt) {
fibonacci = fibonacci :+ fibonacci.takeRight(2).sum
}
println(fibonacci.apply(args(0).toInt - 1))
@boxp
boxp / jcurses-test.clj
Created May 6, 2013 15:45
jcursesのexampleをclojureで写経したもの。結局jcursesをスタンドアロン出来ず、使わないので放置。
(ns grimoire.jcurses
(:import (jcurses.system CharColor)
(jcurses.widgets DefaulLayoutManager)
(jcurses.widgets WidgetsConstants)
(jcurses.widgets Window)))
(def lbl
(doto
(Label.
"All gone to hell!"
@boxp
boxp / fizzbuzz.clj
Created June 3, 2013 20:54
clojureでFizz Buzz
(defn fizzbuzz
"fizzbuzz"
[x]
(cond (and (= (mod x 3) 0)
(= (mod x 5) 0)) "Fizz Buzz"
(= (mod x 3) 0) "Fizz"
(= (mod x 5) 0) "Buzz"
:else x))
@boxp
boxp / t071-func.c
Last active December 18, 2015 11:59
プログラム基礎Ⅱの小テストを変数無しで解いてみる試みその1
#include <stdio.h>
int sum(const int num[],const int count,const int result){
if (count == 0) {
return result + num[count];
} else {
sum(num,(count-1),(result + num[count]));
}
}
@boxp
boxp / dolls.c
Last active December 18, 2015 15:18
Cで作ったなんちゃってclojure関数たち
// 文字列版take
void take_char(int n, char* string, char* substring) {
int i;
for (i = 0; i < n; i++) {
substring[i] = string[i];
}
substring[i+1] = '\0';
}
@boxp
boxp / sum.c
Created June 19, 2013 00:09
東京電機大学未来科学部ロボット・メカトロニクス学科の学生として恥じることの無い洗礼されたプログラム☝( ◠‿◠☝)(コンピュータ基礎再履の課題)
#include <stdio.h>
int main(int argc, char const* argv[])
{
const int a = 500,b = 300,c = 0;
int as,bs,cs;
printf("PC|゚Д゚)ノ  イラッシャイ\n");
printf("[おしながき]\nクソネミ( ˘ω˘ ):%d円\nエクストリームドドスコンダーオ:%d円\nスマイル( ◠‿◠ ):%d円\n", a, b, c);
printf("いくつ買う? -> クソネミ( ˘ω˘ ):");
scanf("%d", &as);
@boxp
boxp / problem1.clj
Created June 22, 2013 14:15
clojureでproject-eulerに挑戦 〜第一問〜
(reduce +
(filter
(fn [x]
(or (= 0 (rem x 5))
(= (rem x 3))))
(range 1 1001)))
@boxp
boxp / problem2.clj
Created June 22, 2013 14:16
clojureでproject-eulerに挑戦 〜第二問〜
(println
(reduce +
(loop [result [1 2]]
(if (> (last result) 4000000)
(filter even? (drop-last result))
(recur (conj result (reduce + (take-last 2 result))))))))
@boxp
boxp / problem4.clj
Created June 22, 2013 14:17
clojureでproject-eulerに挑戦 〜四問目〜
(defn palindromic? [number]
(loop [numseq (seq (str number))]
(cond (<= (count numseq) 1) true
(= (first numseq) (last numseq)) (recur (drop-last (rest numseq)))
:else false)))
(def thdigits
(range 100 1000))
(println (last (sort (filter palindromic? (for [x thdigits y thdigits] (* x y))))))
@boxp
boxp / problem5.clj
Created June 22, 2013 14:20
clojureでproject-eulerに挑戦 〜五問目〜
(defn coll-divides? [x coll]
(every? true? (filter #(not= (mod x %) 0) coll)))
(print
(loop [x 20]
(if (coll-divides? x (range 1 21))
x
(recur (+ x 10)))))