Monthly Archives: July 2008

C# 3.0 一行求方差

某python程序员说用C#求方差需要五十行。于是我试了试 pythondef variance (*l):      return sum([(i – sum(l) * 1.0 / len(l)) ** 2 for i in l]) / len(l) C# Func<List<double>, double> variance = numbers => (from n in numbers select Math.Pow((n – numbers.Sum() / numbers.Count), 2)).Sum() / numbers.Count; … Continue reading

Posted in .NET | Leave a comment

三角形拼图 这怎么可能?

我看了半天没看出破绽,于是用Canvas + jQuery UI做了个网页拼图,拼了半天终于发现了其中的奥妙。 我讨厌剧透,所以贴出代码占位,以免想独立思考的同学意外看到答案。 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Missing Square?</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="ui.core.js"></script> <script type="text/javascript" src="ui.draggable.js"></script> <script type="text/javascript" src="missingsquare.js"></script> </head> <body> <div style="float:left"><img src="missingsquare.jpg"/></div> <div style="float:left; … Continue reading

Posted in Uncategorized | 3 Comments