Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Tuesday, July 19, 2011

GameBoard


A simple "Conway's Game of Life" Board using a trivial over-the-weekend framework.



Works at-least...


Tuesday, September 21, 2010

RECEME - Remote Command Execution through eMail Exchange

A service concept is implemented here for seamless & connectionless computation from anywhere to anywhere

REmote Command Execution through eMail Exchange or RECEME successfully attempts to solve the problem of remote code execution. The proposed solution executes any .Net runnable code on a computer(where the service application is up and running) in the form of a 'ICommand'.

The commands can be fired from any other location by sending an email/twit/(or any other mode in principle eg sms/phone/etc) to the connected communication client (email-box in the current implementation).

more at codeproject.com...



Sunday, December 13, 2009

#60

WinHooksDemo

Capture mouse click/move points and a small area around it as image.




















#59

DicomPuppy

A short Dicom Searcher/Sorter/Reporting tool helps to find dicom files from a dicom database of huge size. Files with specific attributes can be found and sorted in a notepad/excel, which can then be used to look for exact values.














Saturday, December 12, 2009

#58

PROBLEM: Game of life

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbours, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

1. Any live cell with fewer than two live neighbours dies, as if by loneliness.
2. Any live cell with more than three live neighbours dies, as if by overcrowding.
3. Any live cell with two or three live neighbours lives, unchanged, to the next generation.
4. Any dead cell with exactly three live neighbours comes to life.
5. Any dead cell with age > 3 dies (additional rule). Every generation creates an age for the cells

The initial pattern constitutes the 'seed' of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed — births and deaths happen simultaneously, and the discrete moment at which this happens is sometimes called a tick. (In other words, each generation is a pure function of the one before.) The rules continue to be applied repeatedly to create further generations.

Problem.
The inputs below represent the cells in the universe as X or - . X is a alive cell. - is a dead cell or no cell . The below inputs provide the provide pattern or initial cells in the universe . The output is the state of the system in the next tick (one run of the application of all the rules) , represented in the same format.

Answer:

Tuesday, September 9, 2008

#57

ScreenShot
with mouse cursor (shape and position)



Windows default screenshot generator (using print-screen) does not capture the mouse position and shape. This is a nifty tool to capture the mouse shape and position using basic win32.

Keep pressing F7 and the images are dumped in C:\

---------- Source available on request

Download

Friday, March 7, 2008

#56

PROBLEM : MARS ROVERS

A squad of robotic rovers are to be landed by NASA on a plateau on Mars.This plateau, which is curiously rectangular, must be navigated by therovers so that their on-board cameras can get a complete view of thesurrounding terrain to send back to Earth.

A rover's position and location is represented by a combination of x and yco-ordinates and a letter representing one of the four cardinal compasspoints. The plateau is divided up into a grid to simplify navigation. Anexample position might be 0, 0, N, which means the rover is in the bottomleft corner and facing North.

In order to control a rover, NASA sends a simple string of letters. Thepossible letters are 'L', 'R' and 'M'. 'L' and 'R' makes the rover spin 90degrees left or right respectively, without moving from its current spot.'M' means move forward one grid point, and maintain the same heading.

Assume that the square directly North from (x, y) is (x, y+1).

INPUT:
The first line of input is the upper-right coordinates of the plateau, thelower-left coordinates are assumed to be 0,0.

The rest of the input is information pertaining to the rovers that havebeen deployed. Each rover has two lines of input. The first line gives therover's position, and the second line is a series of instructions tellingthe rover how to explore the plateau.

The position is made up of two integers and a letter separated by spaces,corresponding to the x and y co-ordinates and the rover's orientation.

Each rover will be finished sequentially, which means that the second roverwon't start to move until the first one has finished moving.

OUTPUT
The output for each rover should be its final co-ordinates and heading.

INPUT AND OUTPUT
Test Input:
5 5
1 2 N
LMLMLMLMM
3 3 E
MMRMMRMRRM

Expected Output:
1 3 N
5 1 E
==========

Answer:

Friday, September 21, 2007

#55

In the mathematical discipline of linear algebra, the Strassen algorithm, named after Volker Strassen, is an algorithm used for matrix multiplication. It is asymptotically faster than the standard matrix multiplication algorithm, but slower than the fastest known algorithm, and is useful in practice for large matrices.

Volker Strassen published the Strassen algorithm in 1969. Although his algorithm is only slightly faster than the standard algorithm for matrix multiplication, he was the first to point out that Gaussian elimination is not optimal. His paper started the search for even faster algorithms such as the Winograd algorithm in 1980 (which uses 7 binary multiplications, but 15 binary additions instead of 18 with the Strassen algorithm), and the more complex Coppersmith–Winograd algorithm published in 1987.

http://en.wikipedia.org/wiki/Strassen_algorithm


Answer:



Tuesday, May 8, 2007

#51

What is the smallest quine you've found so far ?

Answer:

    int main(){char c[]="int main()%c{%cchar c[]=%c%s%c;%cprintf(c,10,10,34,c,34,10,10,10);%c}%c";printf(c,10,10,34,c,34,10,10,10);}

#50

Check out a need coding for multidimesional arrays:

Answer:

    for(int i=0; i <>>a[i/n][i%n];
    You can generalize this to whatever size and way you wanna :D

#49

Caps off code

Answer:

    void main(){ *(char far *)1047 &= 191; }

Caps on code

Answer:

    void main(){ *(char far *)1047 = 64; }

#48

1. Printing "Hello World" without using a single semi colon in C:

Answer:

    This is an age old problem, and most people have known it by now.

    main(){if(printf("hello world")){}}

    check I havnt used a semi colon :D

2. Ever thought of finding the greatest of 2 numbers without using using any comparison operators ?


Answer:

    Same old problem. Basically a little maths:

    a = 10;
    b = 5;

    c = [(a + b) + abs(a - b)]/2;// c will hold the greater of a and b
    d = [(a + b) - abs(a - b)]/2;// d will hold the lesser of a and b

#47

What is the “condition” such that .. this snippet of code prints HelloWorld!!

if condition
printf(”Hello);
else
print(”World!!);

Answer:

    This problem ... tampered my senses a lot .. and after asking a lot of people ... i could manage a very ordinary solution ... And still not satisfied with that ... I look for a solution ... where the condition would be suh that both parts get executed.. though its a falacy or WRONG in the words of compiler .. The current irritating solution is:

    if ( printf(”Hello”)<0)>
    printf(”Hello”);
    else
    printf(”World!!);

    There seems to be another solution by writing just one more line:

    #define else ;

Wednesday, April 25, 2007

#33

How can you find the minimum or maximum of 2 numbers without using relational operations ?

Answer:

    r = y + ((x - y) & -(x <>
    r = x - ((x - y) & -(x <>