Tower of Hanoi c#

44

Tower of Hanoi c# -

static void Move( int discs, Stack<int> fromPeg,  Stack<int> toPeg, Stack<int> otherPeg)
{
    if (discs == 0)
    {
        return;
    }

    Move(discs - 1, fromPeg, otherPeg, toPeg);

    toPeg.Push(fromPeg.Pop());

    Move(discs -1, otherPeg, toPeg, fromPeg);
}

Comments

Submit
0 Comments