Introduction
Matrices have always been of interest in the field of encryption, specifically matrix rotations which leads to a symmetric as well as asymmetric cryptography. To learn more about regular matrix rotation please check my recent posts on the subject. This however is a fancy Ring wise Matrix Rotation and is no where related to the regular rotation of matrices.
Problem Statement
You are given a M*N grid with the restriction that the minimum of M and N is an even number. Rotate each of the rings by a distance K. We can choose the direction of rotation to be either clockwise or anti-c...

Read More
# Author: dharam

## Closest Pair Points

Introduction
A very interesting problem, indeed. I presume, not a complex one either. Here is what the problem statement looks like. "Given a set of N points in a plane, find the closest pair points". A question which is always asked in interviews in various forms, here we will not just look at the solution but will also understand the intuition behind the solution.
In the adjoining image, we have five points (A, B, C, D, E) in the plane. As a result of the solution we need to return one pair which has the smallest distance between them. Of course there can be multiple such pairs, we a...

Read More
## Seed in Random Number Generation

Random Numbers
Randomization is an awesome concept. Efficiency of most of the algorithms are proportional to how randomly the algorithm is implemented. Talking about one the best sort algorithms - Quick Sort. The efficiency depends on the choice of pivot and it is wise to choose a pivot randomly to get an even distribution of elements around it.
Of course no one can beat my bad luck if my randomly chosen pivot misbehaves. But still you will be luckier and have a better running time and upper bound on the running time of this algorithm.
This is not the only algorithm where randomization ...

Read More
## Resource Management in Game

Introduction
This post is the next in the game development series. In this post we will learn about Resource Management in the Game. After writing the game engine, now we can add some background to our game. We will try to add our menu as well and try to add navigation in the menu. Once that is done we will be able to move through the menu and choose various options. Without wasting much time, lets dive in.
Objects in the Game
There are many different type of entities in our game. They can be categorized into Screens and Actors and few more. You have absolute freedom to make it more gran...

Read More
## Writing a Game Engine

Introduction
This is the second post in the series and I suggest you to read the Basics of Game Development first.
There are two important things in this game.
Drawing the Game Canvas
Writing a Game Engine (The Game FSM - Finite State Machine)
In this post we will discuss about both.
The Game Canvas
The Game Canvas is a rectangular area on which we will draw all our game objects. It will have a predefined size (WIDTH and HEIGHT). The best way to make our game canvas is to extend the java.awt.Canvas class.
[crayon-5a933041d983f552718416/]
Now let us create a frame and add...

Read More