This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <cstdlib> | |
using namespace std; | |
void partitions(int n, int max_n, vector<int>& v, vector<vector<int> >& vv) | |
{ | |
if (n == 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <functional> | |
using namespace std; | |
// Y-combinator for the int type | |
function<int(int)> y(function<int(function<int(int)>, int)> f) | |
{ return bind(f, bind(&y, f), placeholders::_1); } | |
int main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os, pickle, time, android | |
from oauthtwitter import * | |
CONSUMER_KEY = "CONSUMER_KEY" | |
CONSUMER_SECRET = "CONSUMER_SECRET" | |
KEY_FILE = "/sdcard/ase/scripts/twitter_key.dat" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CellularAutomaton.as | |
// by nox, 2010.7.9 | |
// http://handasse.blogspot.com/ | |
/* | |
1-9 : ルール設定 - セルの周りの生存セル数(0-8)に対応 | |
: '.' 死亡, '&' 変化, '+' 誕生, '=' 維持 | |
SPACE : 一時停止 | |
ENTER : リセット | |
V : メッセージ表示/非表示 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys;L=[];S=lambda D:(0in D)and[L.append(D.index(0)),[(D.__setitem__(L[-1],i),S(D),D.__setitem__(L.pop(),0))for i in set(range(1,10))-set(D[L[-1]/9*9:L[-1]/9*9+9]+D[L[-1]%9:81:9]+[d for n in(0,1,2)for d in D[L[-1]/27*27+L[-1]%9/3*3+n*9:L[-1]/27*27+L[-1]%9/3*3+n*9+3]])]]or([sys.stdout.write('%d'%d+('\n'if i%9==8 else' '))for i,d in enumerate(D)],sys.exit());S([int(c)if c!='.'else 0for c in'..53.....8......2..7..1.5..4....53...1..7...6..32...8..6.5....9..4....3......97..']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<int> primes; | |
for (int i = 3; i < 100; i += 2) primes.push_back(i); | |
auto end = primes.end(); | |
for (auto x = primes.begin(); *x * *x <= *(end-1); ++x) | |
end = std::remove_if(x + 1, end, [&x](int p){ return p % *x == 0; }); | |
primes.erase(end, primes.end()); | |
for (auto p = primes.begin(); p != primes.end(); ++p) std::cout << *p << " "; | |
std::cout << std::endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import sys,android | |
droid=android.Android() | |
L=[] | |
def S(D): | |
if 0 in D: | |
L.append(D.index(0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android | |
from wsgiref.simple_server import make_server | |
droid=android.Android() | |
pic='/sdcard/snapshot.jpg' | |
def camera(env,res): | |
if env['PATH_INFO']=='/': | |
droid.cameraCapturePicture(pic) | |
res('200 OK',[('Content-type','image/jpeg')]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import cgi,sqlite3,datetime | |
from wsgiref.simple_server import make_server | |
LIMIT=50 # 最大表示記事数. | |
DB_FILE='/sdcard/bbs.sqlite' | |
con=sqlite3.connect(DB_FILE) | |
cur=con.cursor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import android | |
import sys,os,urllib,urllib2,simplejson | |
from BeautifulSoup import BeautifulSoup | |
YAHOO_APP_ID='Yahoo!デベロッパーネットワークのアプリケーションID' | |
KEITAISO_API='http://jlp.yahooapis.jp/MAService/V1/parse?appid=%s&results=ma&sentence=%s' | |
KANA=[u'きゃ',u'きぃ',u'きゅ',u'きぇ',u'きょ', |