Skip to content

Instantly share code, notes, and snippets.

Avatar

Yoshio HANAWA hnw

View GitHub Profile
View 数独ソルバ
import Data.List
import Data.List.Split
-- 数独を解く
solveSudoku matrix
| matrix /= solved = solveSudoku solved
| solved /= backtracked = solveSudoku backtracked
| otherwise = matrix
where
solved = solveSudokuDirectly matrix
View android-4.4-syscall.txt
accept
accept4
access
acct
add_key
adjtimex
alarm
bdflush
bind
brk
@hnw
hnw / pell.hs
Last active Aug 29, 2015
Pell's equation solver
View pell.hs
import Data.List
-- ペル方程式 x^2 - d * y^2 = ±1について、
-- 指定されたdに対して最小の解(x,y)を返す
-- 参考:http://www004.upp.so-net.ne.jp/s_honma/pell/pell.htm
minSolutionForPellEquation d
| even n = ((x_m0^2+d*y_m0^2) `div` h_m,
(2*x_m0*y_m0) `div` h_m)
| otherwise = ((x_m0*x_m1+d*y_m0*y_m1) `div` h_m,
(x_m0*y_m1+x_m1*y_m0) `div` h_m)
View prob17.hs
last50digits = 55723761467908866712060720593684978725896677308273
findCandidates xs = filter ((lastDigits==).(`mod` m).(^101).read) candidates
where
candidates = [c:x | c<-['0'..'9'], x<-xs]
len = length $ head candidates
m = 10^len
lastDigits = last50digits `mod` m
main = print . take 50 $ iterate findCandidates [""]
View php-5.6.2-new-mm-patch.txt
diff -c -r php-5.6.2-orig/Zend/zend.h php-5.6.2/Zend/zend.h
*** php-5.6.2-orig/Zend/zend.h 2014-10-15 21:59:32.000000000 +0900
--- php-5.6.2/Zend/zend.h 2014-11-02 13:26:51.000000000 +0900
***************
*** 291,298 ****
--- 291,300 ----
#define INTERNAL_FUNCTION_PARAM_PASSTHRU ht, return_value, return_value_ptr, this_ptr, return_value_used TSRMLS_CC
#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
+ # define ZEND_NORETURN __attribute__((noreturn))
View equal-test.php
<?php
$values = array(null, true, false, 0, 0.0, '', ' ', '0', '00', '0.0', '0x0', '0X0', 1, 1.0, '1', '01', '1.0', '0x1', '0X1', '1e0', '1E0', 'a', '1a', INF, -INF, NAN, PHP_INT_MAX, ~PHP_INT_MAX, 9223372036854775808.0, '9223372036854775807', '9223372036854775807.0', '9223372036854775808', '9223372036854775808.0', '9999999999999999999.0', '9999999999999999999.1', '10000000000000000000.0', '10000000000000000000.00', '1e19', '1E19');
foreach ($values as $a) {
if (is_float($a)) {
$a_str = sprintf('%-20.1f', $a);
} else {
$a_str = var_export($a, true);
}
foreach ($values as $b) {
View donot_work_on_php_563.php
<?php
class Foo {
function __invoke() {
echo 'foo';
}
function bar(callable $function) {
echo 'bar';
}
}
View phalanger_install_3.0.sh
#!/bin/bash -e
#Check mono version
s=`mono --version`;
a=( $s );
mono_version=`echo ${a[4]}`;
mono_version_major=`echo $mono_version | awk -F"." '{print $1}'`
mono_version_minor=`echo $mono_version | awk -F"." '{print $2}'`
mono_version_build=`echo $mono_version | awk -F"." '{print $3}'`
View Overload.java
public class Overload{
public static void foo(int x){
System.out.println("int");
}
public static void foo(double x){
System.out.println("double");
}
View bench.php
<?php
if (function_exists("date_default_timezone_set")) {
date_default_timezone_set("UTC");
}
function simple() {
$a = 0;
for ($i = 0; $i < 1000000; $i++)
$a++;
You can’t perform that action at this time.