Monday, September 10, 2007

Microsoft Dynamics

RECURSION IN AXAPTA

Axapta can handle recursive method calls and you can see the standard application making use of it in some places, for example in \Classes\ReqTransFormExplosion\treeBuildNode. But just deep can you go before it bugs out?

Let’s take a classic example of recursive programming: Towers of Hanoi.

The Tower of Hanoi puzzle was invented by the French mathematician Edouard Lucas in 1883. We are given three pegs and a tower of n disks, initially stacked in increasing size on one of three pegs. The objective is to transfer the entire tower to one of the other pegs, moving only one disk at a time and never a larger one onto a smaller.

The code to solve this puzzle is minimal, very intuitive – and recursive.

static void TowersOfHanoi(Args _args)
{
void move(int _n,str _from, str _to, str _transfer)
{
if (_n > 1)
{
move(_n-1,_from,_transfer,_to);
move(1,_from,_to,_transfer);
move(_n-1,_transfer,_to,_from);
}
else
print strfmt("%1 -> %2",_from, _to);
}
;

move(3,"Peg #1","Peg #3","Peg #2");
pause;
}

The parameters instruct the function to move 3 discs from peg #1 to peg #3 and use peg #2 as a buffer.
The solution is to move n-1 discs to the buffer, the last (biggest) disc to the destination and then move the rest from the buffer to the destination. How do you move the rest from the buffer to the destination? Well, you move n-1 discs… you get the point.

Back to original question: How far can you go before it crashes? The answer is 400. Try it out. Change _n from 3 to 400 and run the job. No problem. It will take a long time to finish, so unless you really need to know how to move 400 discs, I suggest you interrupt with Ctrl+Break :-).
Now change _n to 401. It crashes almost instantly.
Each call to move adds one level of recursion (if _n > 1), so that’s 399 + 1 for the initial call = 400.

Btw: Don’t use info() for the output. You would run into a whole other limitation with the infolog.

Wednesday, December 13, 2006

POSITION HOLDERS :) (from the Last)



YES!! We got Position 1st, 2nd and 3rd :p

Saturday, December 2, 2006

Me, My Friends and University











the pictures of me and my friends, refreshes the sweet memories of my NED University, my second home...........

Saturday, November 25, 2006

ACADEMIC PROJECTS

  • An Intelligent graphical solution of Towers of Hanoi in Turbo C++ using Object Oriented Paradigm.

  • Designed an ATM Banking system with backend tool Oracle and front end Forms Developer6i.
  • Designed a website which handles Online Result Management System using ASP.net and DreamweaverMX.
  • Designed Fingerprint Recognition System (biometrics) in JAVA.
  • Working on e-Election Management System of Pakistan.

Achievments

  • Represented BCIT at Code Run 2006 (NED Karachi) in programming Competitions.

  • 4th Position at SPARC 2005 (Muhammad Ali Jinnah University) in Programming Competition.
  • 1st Position in SENTEC 2006 Software Competition and Science Fair Conducted in NED University of Engineering and Technology