Developer Blog

May 4th, 2012: A matches game puzzle

Matches everywhere

Photo: aftermat(c)h by ankaatjeCC

This nifty little puzzle comes from an excercise sheet of our algorithms and data structures course at the university. Our task was to find a winning formula for a game and prove it.

Imagine 100 matches laying on the table. Alice and Bob take at most 10 matches from the table in turn. They can choose how many matches they want to take, but they have to take at least one match. Whoever gets the last match, wins the game. Suppose Alice starts, how should she play to win the game every time?

You should really try to solve this puzzle on your own before reading my explanation after the jump.

Continue reading »

Filed under Mathematics | No comments »

February 9th, 2012: The Google weather API

If you happen to want a quick way for looking up the weather in your own applications, you can use the hidden Google weather API. To access it, just fetch the response for http://www.google.com/ig/api?weather=[your city]. You can replace [your city] with anything you want… a ZIP code or the name of the city you want to look up. This API provides the current weather and a three-day forecast in a handy XML format.

The usage is quite straight forward… just try it out. Originally it’s apparently used for iGoogle’s weather widget, so it’s not very detailed. However it’s still very handy for a quick look at the weather.

Filed under C# | No comments »

January 6th, 2012: Monte Carlo Pi

Unit circle

Today we’re gonna calculate pi. You might say, it doesn’t seem too interesting; it’s an old hat. You may be true, but we’re going to calculate pi using a method, other than approximating a circle with a polygon. So here’s what we do:

  1. We draw the unit circle on our cartesian coordinate system.
  2. We randomly drop points on the square, which contains our unit circle.
  3. The probability of the point dropping on the circle is Pi/4

    Continue reading »

Filed under C#, Mathematics | One comment »


Copyright © Yichuan Shen 2012

→ Project icons by Mihaiciuc Bogdan → Vegur header font by arro → Glyphish icons by Joseph Wain → Thumbnail generatior by Joe Lencioni