Skip to content

Instantly share code, notes, and snippets.

View hanachin's full-sized avatar
🌺
OKA

Seiei Miyagi hanachin

🌺
OKA
View GitHub Profile
// 9x9, 奇数に使えるパターン 55 byte, 53 chars
for(i=81;i--;document.write("■□"[i&1],i%9?"":"<br>"));
// 10x10, 偶数に使えるパターン 54 byte, 52 chars
for(i=110;i--;document.write(i%11?"□■"[i&1]:"<br>"));
var N = 10;
var pat = "■□■";
for (i = 0; i < N; ++i) {
var $ = function (id) { return document.getElementById(id); };
var makeDraw = function (draw) {
return function (ev) {
var canvas = $('ichimatsu');
if (canvas.getContext) {
draw(canvas.getContext('2d'));
} else {
alert('canvas not supported');
}
@hanachin
hanachin / factorial.scm
Created November 18, 2010 15:17
calculate factorial of 5 in 4 ways
(define (fact n)
(if (= 0 n)
1
(* n (fact (- n 1)))))
(fact 5)
(define (fact n)
(define (iter n result)
(if (= 0 n)
_={__:![]+![],_:-~[],$:-~-~[],$_:-~!![]-~[],$$:~!![]*~!![],$$_:~!""*~!""+!"",$$$:~!""*~!""-~!"",$$$_:~!""*~!""*-~!""+~[],$$$$:~!""*~!""*-~!"",$$$$_:-~!""*(~!""*~!""+!"")-!""};$={_:""+!"",$:""+![],_$:""+{},$_:""+{}[{}]};__=$._$[_.$$_]+$._$[_._]+$.$_[_._]+$.$[_.$_]+$._[_.__]+$._[_._]+$._[_.$]+$._$[_.$$_]+$._[_.__]+$._$[_._]+$._[_._];$$=$.$[_._]+$.$[_.$]+$._[_.$_]+$._[_._]+$._[_.__];$_=$.$_[_.$$_]+$._[_.__]+(""+-_._)[_.__]+$._$[_.$$_]+$._$[_._]+$.$[_.$]+$.$[_.$]+$._[_.$_]+(/./[__]+"")[_.$$$*_.$-_._]+$._[_.$_];({}[__][__])($$+"($_);")();
@hanachin
hanachin / noname_fizz_buzz.js
Created December 9, 2010 11:13
lambda lambda lambda... fizzbuzz
(function (MAX) {
return ((function (f) {
return (function (p) {
return f(function (arg) {
return (p(p))(arg); }); })(function (p) {
@hanachin
hanachin / noname_fizz_buzz_18.js
Created December 9, 2010 14:11
js 1.8でFizzBuzzのようなもの。さっきのよりすっきりだね
(function (MAX)
((function (f)
(function (p)
f(function (arg)
(p(p))(arg)))
(function (
@hanachin
hanachin / uppi_diary_urls.rb
Created January 10, 2011 10:45
学内SNSで自分の過去日記のurl一覧をとりだすためのもの。もうちょっと整理したい。
# -*- coding: utf-8 -*-
require 'rubygems'
require 'highline/import'
require 'mechanize'
top_page_url = URI.parse('http://uppi.it-college.ac.jp/')
username = ask("Enter your username: "){|q| q.echo = true }
password = ask("Enter your password: "){|q| q.echo = '*' }
agent = Mechanize.new
@hanachin
hanachin / gist:849596
Created March 1, 2011 18:23
苦C 練習問題10
#include <stdio.h>
int main(void) {
int score;
do {
printf("テストの点数を入力してください\n");
scanf("%d", &score);
} while (0 > score || 100 < score);
@hanachin
hanachin / gist:849727
Created March 1, 2011 19:35
苦C 練習問題11 説明ちゃんとよんでなかった。
include <stdio.h>
int olympics(int year);
int main(void) {
int year;
scanf("%d", &year);
if (olympics(year)) {
@hanachin
hanachin / gist:849770
Created March 1, 2011 20:01
苦C 練習問題13
include <stdio.h>
int main(void) {
int numbers[10];
int i;
for (i = 0; i < 10; i++) {
scanf("%d", &numbers[i]);
}