Posts

2048

You may have seen or played this game on your nearest cell phone: http://en.wikipedia.org/wiki/2048_%28video_game%29 . It is becoming a fever across geeks and addictive-games enthusiastic players across the world. IBM "Ponder This" of this month (April 2014) refers to this game, but instead of a 2D version of it, they came up with a simpler 1D version of it. Link is here: http://domino.research.ibm.com/Comm/wwwr_ponder.nsf/Challenges/April2014.html  and here is the problem copied/pasted from their site: " Inspired by the viral 2048 game ( http://en.wikipedia.org/wiki/2048_%28video_game%29 ) game, this month's question is a simpler one-dimensional version of it. Assume that random independent numbers, either 2 or 4 with a 50% chance each, come in from the right side of a bar with N slots. The numbers are always squeezed to the left and every time two adjacent numbers are the same - they are replaced by their sum. The game ends when all the N slots are occupied...

A Calculator

Image
A calculator . So simple, yet, so powerful. Calculators have been around for a long time, and Bing provides one of the best Calculators out there on the web better than Google’s: http://www.bing.com/search?q=42*35     Now, let’s suppose that you want to validate the code behind a calculator. What you really want are two things: 1) A generator of well-formed mathematical expressions 2) An evaluator (an oracle) of mathematical expressions   The first is needed to generate a vast battery of test cases. The second is needed to compare the results against what the calculator is giving you (fight fire with fire!). This post is focusing on the former. The latter can be accomplished thru a variety of different means: a) Use another well-known engine as the oracle, such as WolframAlfa (cool) b) Use off-the-shelf tools to evaluate mathematical expressions (cooler) c) Write your own! (coolest!)   The idea to generate a valid math expres...