Skip to content

Instantly share code, notes, and snippets.

@sakamotodesu
sakamotodesu / drinkandtearsandmanandwoman.java
Created May 22, 2013 10:24
酒と泪と男と女をオブジェクト指向で表現してみた
public class Man extends Human {
@Override
void ProtectMyself() {
drink(new Happoushu());
}
private void drink(Alcohol alcohol) {
if (alcohol != null) {
memory = null;
@sakamotodesu
sakamotodesu / komadai_20120904_en.md
Created November 28, 2012 04:49
Issues that have been questions in math TV show Takeshi Kitano (04/09/2012)

Q. There is a computer that is programmed to draw a locus of points starting from the point A on grid 8 × 8. The point we move on to the next random point up, down, left, and right. We will not be able to move again on the trail drawn already, however. The point is able to straight any number of times, but turning is up to 15 times. Find the longest distance of the trajectory of this computer may be drawn.

       p   p   p   p   p   p   p   p
walker:ProbWalker(80%)
steps:76
turn:15
List(Point(4,0), Point(4,1), Point(4,2), Point(4,3), Point(4,4), Point(4,5), Point(3,5), Point(2,5), Point(1,5), Point(1,4), Point(1,3), Point(1,2), Point(1,1), Point(2,1), Point(3,1), Point(4,1), Point(5,1), Point(6,1), Point(6,2), Point(6,3), Point(6,4), Point(6,5), Point(6,6), Point(5,6), Point(4,6), Point(3,6), Point(2,6), Point(1,6), Point(0,6), Point(0,5), Point(0,4), Point(1,4), Point(2,4), Point(3,4), Point(4,4), Point(5,4), Point(6,4), Point(7,4), Point(7,5), Point(7,6), Point(7,7), Point(6,7), Point(5,7), Point(4,7), Point(3,7), Point(2,7), Point(2,6), Point(2,5), Point(2,4), Point(2,3), Point(2,2), Point(2,1), Point(2,0), Point(3,0), Point(4,0), Point(5,0), Point(6,0), Point(7,0), Point(7,1), Point(7,2), Point(7,3), Point(6,3), Point(5,3), Point(4,3), Point(3,3), Point(2,3), Point(1,3), Point(0,3), Point(0,2), Point(1,2), Point(2,2), Point(3,2), Point(4,2), Point(5,2), Point(6,2), Point(7,2))
p p
@sakamotodesu
sakamotodesu / .screenrc
Created October 7, 2012 06:50
screen configration
escape ^z^z
# 画面行末にステータス行表示
hardstatus alwayslastline "[%02c] %`%-w%{=b bw}%n %t%{-}%+w"
# 画面バッファ行数を増やす
defscrollback 10000
@sakamotodesu
sakamotodesu / komadai_20120904.md
Created September 8, 2012 03:52
たけしのコマ大数学科 2012/09/04の問題と回答

Q. 8×8の格子点上にAから出発する点の軌跡を描くようにプログラムされてるコンピューターがあります。 点は上下左右の隣の点にランダムに移って行きますが既に描かれた軌跡の上をもう一度移動することはできません。 点は15回向きを変え、直進した後、止まります。 このコンピューターが描く可能性のある最長の軌跡の距離を求めなさい。

       p   p   p   p   p   p   p   p

 p p p p p p p p
eval (%w( p
r i n
t f
( " %s ",[02* 0x0 2*0b1
0 *0 b 10 1 0 0 0
0 0 0 1 * 0b1
1 0 0 1 0 00
0 0 0 1 1 1 1 1
1111 111 11* 0x86d 56fc3 35,0b
@sakamotodesu
sakamotodesu / gist:3292817
Created August 8, 2012 06:26
Firefox Bug? When you click the text, the cursor goes out of it
<label><input type="radio"><input type="text" ></label>
@sakamotodesu
sakamotodesu / gist:2872538
Created June 5, 2012 03:56
まだ途中
import io.Source
object Main {
val toFizzBuzz = ((x:Int) => (x%3,x%5) match {
case (0,0) => "fizzbuzz"
case (0,_) => "fizz"
case _ => "buzz"
})
@sakamotodesu
sakamotodesu / ApacheCommonExec.java
Created March 28, 2012 03:54
apache commons exec "write end dead" sample
package com.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;