Tag Archives: Puzzle

CodinGame: Improve Your Programming Skill By Playing Games

Two weeks ago, I was told by a friend that there was a programming contest happening on a website called CodinGame.

CodinGame

Solve puzzles to improve skills

That was the first time I heard about CodinGame. It is a gaming platform for developers. I never knew such website existed. Last time, I used to join the programming contests organized by my department in my former company and it was fun. Now, there is a website offering the similar experience: write code to play game. It is very addictive.

There are actually many such websites providing competitive programming service and CodinGame is one of them. I was just too ignorant to not know about their existence earlier. CodinGame was online since 2012.

CodinGame: Programming is fun

If you were a programmer, you could improve your programming skill by playing games at CodinGame. I admit I learn great things working on some of their puzzles.

CodinGame online IDE

CodinGame online IDE

They organize programming contests every few months and you could join them for competing among other top programmers around the world (most programmers are from France since CodinGame is a french-based company). The last contest (Code vs Zombies) that I joined was on 29 November 2015 that lasted for 24 hours continuously. Most participants were really gurus who managed to extract most scores from the game. I only managed to score 58720 points and ranked 760 out of 3963 participants who managed to submit their solution before deadline. The winner scored 997k (!!) using a random strategy.

Code VS Zombies

Code VS Zombies

If you didn’t want to join the contest, there is another way for you to have fun: by going to their game section and solve the existing puzzles anytime convenient to you. The puzzles are categorized into four levels: easy, medium, hard and extreme hard.

Today, two weeks later, I had tried most of the puzzles. I can tell that most of the puzzles took time to solve (at least a few hours to days for some puzzles). The difficulty is range by simple programming concepts like if-else (easy), more complex logic and data structures (medium), the application of known algorithms (hard) to artificial intelligence (extreme hard). It is impossible to solve some of the hard and extreme hard puzzles alone without resorting to external resources (like wikipedia).

You can use most of the popular languages (more than 20 languages supported) to solve the puzzles. Each puzzle solved earns you certain coding points which is used for ranking.

Right now, I am ranked 779 out of a total of 276387 users. The ranking will drop each day if I didn’t continue work on new puzzles since everyday there are new comers overtaking you.

Track your progress

Track your progress

There are other features like clash of code and multiplayer games that I haven’t tried yet. You can explore them for yourself.

The main purpose of CodinGame is to link coders to companies. The job store section has a list of job openings from participating companies. However, almost all of them are European companies. The only Asian company is from Hong Kong.

I found that not many Malaysians are participating on the site. Only 936 Malaysians users out of 276k total users. This translates to only 0.34 % of total users. Hopefully more people (especially programmers) can benefit from this platform. The best way to learn is to have fun while learning. 🙂





Cocos2d-JS: Edward de Bono’s L Game

With recently acquired game development skills with Javascript, I tried to work on another simple project. This time, it is a simple board game which is called L game.

L game

The L game was invented by Edward de Bono, who is the author of the book Six Thinking Hats
and also the originator of the term Lateral Thinking.

Six Thinking Hats

The six-thinking-hats is a practical thinking tool for humans to direct their attention into certain areas and let their ideas flow without any premature judgement when exploring new ideas. It is a software for human mind. The six thinking hats come in six different colors where white is for the neutral and factual thinking, green is for the creative thinking, red is for the emotional thinking, black is for the negative and cautious thinking, yellow is for the positive thinking and blue is for the cool and organizing thinking.

Lateral Thinking: Creativity Step by Step (Perennial Library)

Lateral thinking was first coined by Edward de Bono in the 1960s. According to him, traditional and conventional thinking has always been criticizing somethings. People remove and reject what are wrong until they reach a point where nothing else can be removed and called it the truth. They reach a conclusion by criticizing and by using logic … which is excellent. But anything is logical by hindsight, said Edward de Bono. This critical thinking is vertical and dangerous if used alone. Based on the author, we need another mode of thinking, which is the lateral thinking, to complement the excellent vertical thinking.

L game is a two-player game played on a 4×4 board. There are only two types of pieces. The first type is the 2×3 L-shape piece and there are only two pieces of L on the board. It is also why the game is called L game. The second type is the 1×1 dot piece and there are also two pieces of dot on the board.

Each player takes turn to change his/her L position (either the red or the blue L) and the L must be in different position than the initial position. Then he/she can move the one of the dot to any empty square or skip by giving up the right to move the dot.

The goal is to block the opponent until there is no more move for the opponent where the game ends and a winner is determined.

The game is being described in detail in this book The 5-Day Course in Thinking.

The 5-Day Course in Thinking

This book allows readers to find out their own thinking style by solving a series of problems that require no special knowledge and no mathematics. Edward de Bono stressed that being right is not always important since an error can lead to the right decision. The L game can be found in the book as an exercise.

In Edward de Bono’s own words,

The intention was to produce the simplest possible game that could be played with a high degree of skill. An attempt (L game) was made to fulfil the following conditions:

  1. A minimum number of playing pieces, preferably one each.
  2. The smallest possible board.
  3. A game with very few rules, one that would be very simple to learn and play.
  4. A game that could be played with a high degree of skill.
  5. A game that would not be determinate. A determinate game such as nim or noughts and crosses, is one in which the starting player could always win if he knew the strategy. An indeterminate game is one which two perfect players would play for ever.

Motivation

The motivation behind developing this game is that there are not many people doing it. I can only find one web version, one Apple store version and one Google Play version. And that’s it. Probably the game is not that popular. Still, I decided to make my version of it.

Another reason is to practice new skills on simple project. This game is simple enough for this purpose. You can learn more about the game from the wikipedia.

Development

Once again, I am using the open-source Cocos2d-JS game engine for this project.

It took me 3 days to complete the minimal-viable-product. 60 % of the time was used to understand the detail of the game’s dynamic like:

  • how to determine a valid move (it is not that obvious as I initially thought),
  • how to calculate all the valid moves,
  • how to allow player to undo steps,
  • how to write a simple AI (Artificial Intelligence) to play against human or even with AI itself,
  • etc.

There is no sound at all for this version to save the development time.

Final result

L Game

L Game

My version of L game is available on the web here.

It is also available on Google Play.

Get it on Google Play

Get it on Google Play

What I like about the game is the capability to allow the computer to play against the computer. It is really amazing to look at game played automatically by the robot. I admit I spent most of the time watching the computer playing the game on automation. It almost seems like it has a life of its own.

Demo

You can try the game below.

Thanks.

Heuristic for Solving NP Planning Problem

Continue from last post about NP-Problem. Today, I am going to study a planning puzzle which is a type of NP-problem.

In fact, planning problems are NP-Hard (Scary).

Disclaimer: This post is for self-study and for research purposes only. I reuse some of the content from third party website (the Bus-Driver-Planning Puzzle). If it caused any unintended troubles to whatever party, please leave comment below and I will remove the post. Continue reading