平均投几个三分才会连续进 3 个?

今天男篮对澳大利亚虽然输了,但是王仕鹏表现神勇,三分球 10 投 7 中拿下 21 分;梦十对尼日利亚,安东尼更是有如神助,出场 16 分钟,三分球 12 投 10 中!可是平常看 NBA 比赛,不要说 10 中了,一个人连进三个三分都不常见。那平常要扔多少个三分才能看到一次连中三元呢?
Continue reading “平均投几个三分才会连续进 3 个?”

WP LaTeX 中的反斜杠

刚刚升级到 WordPress 3.4.1,我很郁闷地发现,每次我输入一个 LaTeX 公式,反斜杠就消失了。我得把 \ 换成 \\,但每次一保存,两个就变成了一个,再保存一次就没了。研究了一下终于发现了罪魁祸首,把它去掉就好了:

/wp-includes/load.php

function wp_magic_quotes() {
	// If already slashed, strip.
	if ( get_magic_quotes_gpc() ) {
		$_GET    = stripslashes_deep( $_GET    );
//      $_POST   = stripslashes_deep( $_POST   );
		$_COOKIE = stripslashes_deep( $_COOKIE );
	}

	// Escape with wpdb.
	$_GET    = add_magic_quotes( $_GET    );
	$_POST   = add_magic_quotes( $_POST   );
	$_COOKIE = add_magic_quotes( $_COOKIE );
	$_SERVER = add_magic_quotes( $_SERVER );

	// Force REQUEST to be GET + POST.
	$_REQUEST = array_merge( $_GET, $_POST );
}

Emacs 图片支持

新装了最新的官方 Emacs 24.1,一启动发现图片不是光滑的 png 而是 xpm
于是查看 png 支持
M-: (image-type-available-p 'png) RET
返回nil。再看
C-h v libpng-version RET
返回 10403。这才想起来官方 Windows 版里面不带 libpng,原来的版本里面 libpng 版本可能不对。去 bin 目录下面看果然发现 libpng 是 1.2 版本。下载新的 1.4 版本 libpng14-14.dll 替换搞定。
另外实际上 Emacs 显示 png 还需要 zlib1.dll。

补:现在24.4版本里面已经需要10612版。

所有的文件都可以在这里下载。

Sudoku Solution – Project Euler #96

This is a Python solution for Project Euler #96, to find the solution for sudokus.

The speed is modest (0.750s with pypy on Windows 7 @ i5 2.60GHz), but the code is relatively short and hopefully the idea is clear. Enjoy.
1. Find candidates for all items. If only one exists for a blank, fill it in.
2. Note down the blank with least but more than one candidates.
3. Copy the matrix and trial the candidates recursively until all blanks are filled.
Continue reading “Sudoku Solution – Project Euler #96”