
Microsoft Research in its blog
announced the launch of
Code Hunt, a browser-based puzzle game on learning programming in C # and Java.
The player is given code snippets with previously unknown functionality. The goal of the game is to, on the basis of the input data and the expected result, change the code of the method or function so that the output corresponds to this expected result.

At the beginning of the game, the player chooses in which language (Java or C #) the code fragments will be presented. In the future, during the game at any time, you can switch from one language to another. The game is divided into sectors corresponding to different programming topics (cycles, arrays, working with strings, etc.). Each sector, in turn, consists of several levels arranged in order of increasing complexity. Passing a level is estimated by one, two or three “bricks” depending on the “elegance” of the written code. The shorter the code, the more elegant it is. For example, in the task of counting the number of characters
'a' in a line, the code
public class Program { public static int Puzzle(String s) { int result = 0; for (char c : s) { if (c == 'a') ++result; } return result; } }
It is estimated at one brick on the elegance scale, but the code that has the same functionality, but written using regular expressions, is already three blocks:
public class Program { public static int Puzzle(String s) { return s.replaceAll("[^a]", "").length(); } }
Of course, this game fits more into the category of puzzles or puzzles than programming tutorials, but as a warm-up for the brain is quite addictive.