Skip to content

Instantly share code, notes, and snippets.

View sinya8282's full-sized avatar

Ryoma Sin'ya sinya8282

View GitHub Profile
@sinya8282
sinya8282 / fealdiff.py
Created November 7, 2011 15:38
This program can calculate FEAL's one-round characteristics with probability.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ryoma SHINYA
def sfunc(a, b):
p = bin((a + b) & 0x7F).count("1")
a = a + b % 256
b = (a >> 6) & 0x03
a = (a << 2) % 256
return (a | b, p)
struct Transition {
int t[256];
Transition(int fill = REJECT) { std::fill(t, t+256, fill); }
int &operator[](std::size_t index) { return t[index]; }
const int &operator[](std::size_t index) const { t[index]; } // <- forget 'return' stmt.
}
@sinya8282
sinya8282 / gist:948710
Created April 29, 2011 17:54
gcc 4.5.3 build error log
checking for a thread-safe mkdir -p... ../../../gcc-4.5.3/libgomp/../install-sh -c -d
checking for gawk... awk
checking whether make sets $(MAKE)... yeschecking for x86_64-apple-darwin10.7.0-gcc... /Users/ryoma/dev/compiler/build-gcc-4.5.3/./gcc/xgcc -B/Users/ryoma/dev/compiler/build-gcc-4.5.3/./gcc/ -B/Users/ryoma/dev/compiler/build-gcc-4.5.3/INSTALL_DIR/x86_64-apple-darwin10.7.0/bin/ -B/Users/ryoma/dev/compiler/build-gcc-4.5.3/INSTALL_DIR/x86_64-apple-darwin10.7.0/lib/ -isystem /Users/ryoma/dev/compiler/build-gcc-4.5.3/INSTALL_DIR/x86_64-apple-darwin10.7.0/include -isystem /Users/ryoma/dev/compiler/build-gcc-4.5.3/INSTALL_DIR/x86_64-apple-darwin10.7.0/sys-includechecking for C compiler default output file name...
configure: error: in `/Users/ryoma/dev/compiler/build-gcc-4.5.3/x86_64-apple-darwin10.7.0/libgomp':configure: error: C compiler cannot create executablesSee `config.log' for more details.
make[1]: *** [configure-target-libgomp] Error 1make: *** [all] Error 2
@sinya8282
sinya8282 / gist:948494
Created April 29, 2011 15:45
gcc 4.6 (minimal) configure option
../gcc-4.6-20110305/configure --disable-boostrap --program-suffix=-4.6 --prefix=$HOME/opt --disable-nls --disable-multilib --enable-languages=c,c++
#http://googledevjp.blogspot.com/2011/04/google-code-jam-2011.html
def solve(rest, boards, counts):
if boards == []:
return rest == 0
board = boards[-1]
count = rest / board
rest = rest % board
while count >= 0:
if solve(rest, boards[0:-1], counts):
@sinya8282
sinya8282 / gist:834304
Created February 18, 2011 20:03
why latter is fast ? (reject called from main loop continuously)
void
reject(UCHARP beg, UCHARP buf, UCHARP end, ENVP env){
if (buf >= end) {
if (env->print_count) {
if (env->filename) {
printf("%s:", env->filename);
}
printf("%d\n", env->count);
}
return;
@sinya8282
sinya8282 / turing_machine.py
Created October 20, 2010 09:28
Turing-Machine Simulator
We couldn’t find that file to show.