r-Permutations With Repetitions

Problem : To generate all r-Permutation with repetitions of a set of distinct elements

Before we start discussing about the implementation we will go through the basic definitions of Permutations. Then we discuss the method to generate r-Permutations with repetitions with examples, and at last we implement a C Language Program of the problem. Continue reading.

Continue reading “r-Permutations With Repetitions”

Swapping Values

Problem:Developing Algorithm to interchange of the values stored in two given variables.

The exchanging of the values between two given variables is commonly known as value “swap” and the process is known as “swapping”.This can be archived by various approaches. Below, we will discuss about two different approaches with a total of three processes, and see their benefits and pitfalls.

Continue reading “Swapping Values”

Linux / Unix Shell Commands: Problems and Solutions (1st issue)

This is the first issue of the “Linux / Unix Shell Commands: Problems and Solutions” series. This issue features the questions taken from different year question papers of Computer Science Honours, Part II Practical examination of Calcutta University, India, Kolkata. This section carries 5 marks. When going through the papers I noticed that the questions were repeated in different years. Also there were common questions in different groups in the same year. I have tried by best to solve the questions and kept it as simple as possible. Each solution comes with a description of what the sequence of commands do. I have also provided more than one solution where applicable.

A note for the students: Please do not try to remember each and every command without understanding how they work. If you do not know the commands it is recommended that first learn the basics and know what the commands do. Refer any standard text book, the command manual pages, or the GNU website. If anything cannot be understood in this solution refer the man pages, if any mistake is found please leave a comment or contact me. The main intention of this solution is to act as a ready reference to save time.

Update Information: Updated at 17.03.2012

Continue reading “Linux / Unix Shell Commands: Problems and Solutions (1st issue)”

Jumble Word Solver


Jumbled Word: A string of characters is given, the task is to find all the meaningful words that can be created by rearranging its letters. Solving a jumble word means to find all the meaningful words that can be made with the initial string.

Objective Of The Article

In this article first we will describe how a jumbled word can be solved and then we present a very simple computer program. After this we present an advanced computer program which will make the solution very fast with the help of a specially designed tree.

Article Revision: 3
Notice 25.9.2009 : This article is undergoing an update and will be made online soon .

Here is another related post Jumbled word solver with C++ and Perl implementation with hash and list: Jumble word solver again.
*Please Note:* This article is very old and lengthy, I am planning for either a revision or a rewrite for the trie tree part which reflect the recent modifications. At the time I wrote this I did not know that the datastructure which I worked out was a trie :) therefore the long explanation.
Continue reading “Jumble Word Solver”

Generating Twin Primes, Cousin Primes and Sexy Primes

Twin Prime: A twin prime is a set of two prime numbers whose absolute difference is 2. Let p1 and p2 primes such that p2 – p1 = 2, then the set { p1 , p2 } are twin primes.

Objective Of The Article

The objective of this article is to describe the basic algorithm to search for the twin primes first, and then make some modifications to make it better and faster. At last we present the final code

Article Revision: 2

Continue reading “Generating Twin Primes, Cousin Primes and Sexy Primes”

Allegro 4.2.2

Introduction

Allegro Logo
Designing and programming games is anything but easy. One needs to understand the game logic (algorithm) and the graphics manipulation techniques, the core of the game, and good planning and synchronization between these, to design a game. And I don’t think anyone would debate the fact the graphics alone makes a huge impact on games. That means the core logic needs priority and concentration than the eye candy graphics.

To begin programming the games and their graphics we need to have the basic concepts of game programming clear, as well as a good graphics and I/O tool which does not drag a beginner into the complex world of syntaxes, datastructres, procedures, complex internals, etc. Thus, I’m sure everyone agrees that starting with OpenGL or DirectX programming becomes quite a job for beginners. So game making needs very good management and planning at first, then it needs coding knowledge, and a good programming tool or API is needed to complete the task smoothly. Selecting an API is very important, it should be simple and is usable and also powerful at the same time which will let you spend more time on the planning the game and code the techniques. Now all the properties are difficult to find.

In this article we will introduce you with a 2D and 3D game and graphics library called Allegro, primarily to be used with C Programming Language, which brings you a great platform to start game programming. Though you still will need to know the basic techniques and algorithms to design the core, but Allegro is a great API which takes a good care of the graphics, sound, I/O and all the other components. So you can do the core design with more concentration, and then create the multimedia components, and the I/O using Allegro with great simplicity. Allegro does this by hiding the complex internals with its simple abstract datastructres and similarly simple routines. And all this is not only for beginners, but this library also has the power inside for advanced and professional-level programming. Read the whole article to know about Allegro in details and jump start into allegro programming

Continue reading “Allegro 4.2.2”