Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Sunday, July 12, 2015

Coding the Conway’s Game Of Life

Written by Jonathan Paul (III MCA)
 
It was very hard to understand initially, “What is this Game of Life?”. It seemed so confusing. I was puzzled when Prof. Jibrael Jos first spoke to us about it . But then I read the four simple rules which determined the life of cells; approached sir, and he explained the life of an oscillator (Blinker). I was amazed ! It was like knife going through butter.
    I immediately got down to code it. Few if and else conditions, a little bit of concern for boundary conditions and ensure that no cells in the present generation were affected by cells of next generation ; gave me an ample of joy watching my first species oscillating on the terminal.
Then came the time to tweak the simulation. Sir asked us to discover new species. Just imagining the fact that I might find a new species in the huge ocean of the probabilistic matrix was awe-inspiring.
I wrapped the world of this simulation to allow an infinite space. Also provision for loading of discovered species into the world was given. Existing discoveries of interesting species was included in the simulation.

It was an interesting affair. I could watch these little bots moving on my screen for eternity. It has been an amazing experience coding this. And if you are interested to have fun, join the endeavor of finding new species.
 
 
 
I call this life a Village. It has a glider, blinkers which look like windmills, beehives, blocks which resemble huts, and loaves (food barn). I had fun, hope you do too.

Wiki URL : https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

 

Tuesday, September 16, 2014

CodeGuru, Gateways 2014

PG Courses @ Christ University
I  : Vora Parth Deepak  (winner for a second time)

II : Akashdeep Bhattacharya
III: Jophin P
Position 4th to 8th are as follows
Tenzin Chemi, Jonathan F P, Diganta Das, Amlanjyoti Saikia, Virapaxgouda C K

Questions were as follows
Currency Change is in denomination of
    1,2,5,10,20,50,100,500,1000

1. Store denomination in an array and display it.

2. Give a certain amount, convert it into denominations, (total number of sub denomination should be as less as possible)
    So 83 is 50+20+10+2+1

3. If this money has to be shared with two people then divide the change is such a way that it is as equal as possible
    So 83 for two people will be 41(20,20,1) and 42 (20,20,2)

4. Money shared with three people

5. Give change such that there are distinct number of pieces
  Say 86 return in  6 if possible : 50,20,10,2,2,2 or 50,10,10,10,5,1

6. If breaking up is not possible should say so
  10 in 3 is not possible 5,2,2,or 5,2,1

7. If there is a change in currency and denomination are now 1,3,5,10,50. Which number from 1 to 100 cannot be generated.

Sunday, September 4, 2011

Code Guru : Gateways 2011





Winners: Jino George (I) , Aditya Gopalkrishnan (II), Raju K (III)

Jino and Aditya were just a few seconds apart and deciding one over the other was nail biting close
Sowmya came fourth. Thanks for all who came and made it a success.
We had MS Computer Science, MCA and M.Sc Computer Science taking part

Questions Were

1. Display Grid 9 by 9
Able to input Food (2 to 9) at any position
Able to input Ant (Type 1 and Type 2) at any position
2. Take Shortest Route to Food
3. Two Ants, First Who reaches takes
4. If food is 4 ants can smell only 4 steps away, if 9 then can smell 9 steps away
5. Ant 2 is mightier than Ant 1. He can grab from Ant 1 if he gets chance
6. Keep walking if smell food, once you get food walk out using shortest path
In following set up (Next Sheet)
Ant goes always to closest food source and moves out using shortest path
Final Level
7. Implement Multiple Food Source and Ants


Saturday, October 16, 2010

Sudoko Solver

Wrote a small application to solve a Suduko puzzle in C#, I was doing C# coding after some years now and I thoroughly enjoyed it

If you are interested you may wont to give it a try.

Step 1: Make a grid of text boxes (81 of them !!! ), load it into an array of objects
Step 2: Write function checkRow to see if no two numbers are repeated
Step 3:Write function checkColumn
Step 4:Write function checkBox
Step 5:Write function findAllPossible(for a particular position)
Step 6:Write function findAll(for all 81 position)
Step 7: Check is their a number in a row which is allowed only in that position, then that number is to be placed there
Step 8: Check is their a number in a column which is allowed only in that position, then that number is to be placed there
Step 9: Check is their a number in a box which is allowed only in that position, then that number is to be placed there
Step 10:Do color coding for duplicates. Make new entries come in green or something

Future Enhancements : Undo, History, Game Generation, Guessing in case direct solving does not work

Time : ~15 hours of coding ..... more because there was many things I was not sure how to do in C#, because of the gap ... try it, it is fun

Thursday, August 26, 2010

Code Guru : Gateways 2010

Conducted Code Guru in Christ University for the MCA/M.Sc Students. There was 4 questions and an hour to code and get them executing. This time top three were able to do all four questions in the allotted time and competition ended up as a nail biting finish for the IInd and IIIrd place.

Winners are :
1. Aditya Gopalakrishnan
2. Heena Gupta
3. Mahesh D
4. Rakesh Kashyap
5. Jyothsna K
6. Andrew Pereira
7. Raju K
8. Lakshmi Narayanan
9. Sowmya Stephen
10. Mark Godfrey

Time : 1 Hour
Compiler : C/C++/Java/.Net
Questions :
1. Convert a mixed string to alternate upper and lower case
2. Validate a date in mm-dd-yy and convert to dd-mm-yy
3. If user enters 2 (line) 3 (triangle) 4 (square) 5 (pentagon)
4. Create a game which is like a puzzle
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15

1 2 3 4
5 6 7
9 10 11 8
13 14 15 12
User should be able to move left,right,up,down,randomise and sort the puzzle

Questions prepared by J S Saleema, Deepthi Das, Jibrael Jos

Friday, August 28, 2009

The Way I "C" It

C has been one of my favorite language for a very long time. The book I recommend would always be the book by Kernigan & Ritchie. Costing around Rs 100, this book is a steal by any standards.

The reason I got hooked to this book is much credit to Sunil Batra (my C mentor in London). Since my first cover to cover read in 1999 I have gone to read the book 3 times and have tried almost 90% of the excercises in this book.

Can you answer these questions
Read Pg 107 of KR Book for answers
What is this : Int (*daytab) [13])
What is difference between
Void *comp() and Void (*comp) ()
How many argurments in this function ?
List * CreateList (int (* compare)( void * argu1, void * argu2))
In this snippet do we need bracket arond pLoc and why ?
Node **pLoc
pLoc = (* pLoc ) -> Link;

Pg 209 KR Book
Did you know these are not errors ? What Happens ?

F ( a, (t=3,t+2),c) : How many arguments ?

Sample Code
a=3;
b=5;
a=b,c
Printf(“%d”,c); // What gets printed ??

Is this allowed in a for loop : For i=10,j=1;i<10;i++)

Is this allowed and what is result : b,b,a=3,4,a+2,9;

Pg 98
Int a[10];
Int *pa;
Pa=&a[0];
x=*pa; // what is X
Is *(pa+1) same as a[1]
Is *(pa+i) same as a[i]
Is *(a+i) same as a[i]

Which is error ? Why ?
pa=a;pa++;
or
a=pa;a++;