Can somebody describe the recursive solution of the Tower of Hanoi?
825058
Tower of honoi\n\nTo some its a never ending game, to others its a good way to test the speed of their CPU, but, to us it is a great example of recursion.\n\nIn the original Tower of Honoi, you have 64 disks in position A stacked on top of each other. The largest disk at the bottom and smallest at the top and disks sorted from large to small. The task at hand is to move all 64 disks from position A to position B using position C, without ever putting a larger disk on top of a smaller one and only moving 1 disk at a time. How long do you think that would take you to complete? Chinese priest thought that the completion of this task will bring the end of the world, it was considered an unendable task. But, that was before the age high speed computers. How many moves do you think it takes to moves all 64 disks?\n\nThe recursive algorithm is extremely simple to state, note that the larger the number associated with a disk is, the larger the disk:\n\nif (N == 1)\n   Move disk N from position A to position B\nelse\n   Move (N-1) disks from position A to position C using B\n   Move disk N from position A to position B\n   Move (N-1) disks from position C to position B using A\nendif\n\nHere is a method that prints all moves needed for N disks. To realize that time complexity of this method grows exponentially as n gets larger, you can copy the program that tests this method and try it for bigger Ns. The file is test_honoi.java You can use the Save As option in the File pull-down menu of netscape to save it in your account once the file is loaded in netscape.\n\npublic static void towerOfHonoi (int N, char from, char to, char using){\n   if (N == 1)\n      System.out.println("Move disk "+ N + " from position " + from + " to position " + to);\n   else {\n      Tower_Of_Honoi (N-1,from,using,to);\n      System.out.println("Move disk "+ N + " from position " + from + " to position " + to);\n      Tower_Of_Honoi (N-1,using,to,from);\n   }\n}\n\nHere is the output from this function when moving 3 disks from A to B using C:\n\nEnter the number to try: 3\nMove disk 1 from position A to position B\nMove disk 2 from position A to position C\nMove disk 1 from position B to position C\nMove disk 3 from position A to position B\nMove disk 1 from position C to position A\nMove disk 2 from position C to position B\nMove disk 1 from position A to position B\n**** MOVES COMPLETED ****
747559
Simply draw a chart that has each of the 6 variables at right angles to each other, draw lines between the linked variables such coke-greenbike (#3), then use process of elimination.\n\nYeah, right... draw a 6-dimensional hypercube....\n\n Jeez, I've spent about 3 hours on this, and so far it looks like Carla, who was on the yellow bike which was 1st in line, was Bigbird and brought rootbeer and jelly beans.  Either Emily, who was dressed as either dracula or the clown, or Daniel dressed as the other, brought the candycorn.  But at the moment I have a contradiction, which means that somewhere I made a logical error.  I'll try to get back to this sometime later - good luck
730496
iteration1: a = 3, b = 2\niteration2: a = 13, b = 8\niteration3: a = 51, b = 30\nloop exit:  a = 81, b = 30 // condition a = a + b executed before exit
769753
Without knowing the relationship between successive elements, I think the best you can do is this:\n[k=0, n-1]∑(x_(k+1) - x_k)²\n[k=0, n-1]∑(x_(k+1)² - 2x_k*x_(k+1) + x_k²)\n[k=0, n-1]∑x_(k+1)² - 2[k=0, n-1]∑(x_k*x_(k+1)) + [k=0, n-1]∑x_k²\n[k=1, n]∑x_k² - 2[k=0, n-1]∑(x_k*x_(k+1)) + [k=0, n-1]∑x_k²\n\nx_0 + x_n + 2[k=1, n-1]∑x_k² - 2[k=0, n-1]∑(x_k*x_(k+1))
383543
For a moment, I thought that Gabrielwyl had the correct pattern, then I noticed a mistake in for n=14. If there are 14 people, you should sit in the 13th spot.\n\nThen I checked gulabo's answer, and he did a good job of trying to find an expression to the pattern, except that it doesn't work. He wrote, "So, if n is even just SIT AT FIRST POSITION." Not true. You can check it yourself. His expression for if n = an odd integer is also incorrect.\n\n\n\nAnyways, the pattern for n people (yourself included) is to sit at the listed position. It's similiar to Gabrielwyl's except with the mistake corrected, and the pattern defined.\n\nN.Pos\n------\n1.1\n2.1\n3.3\n4.1\n5.3\n6.5\n7.7\n8.1\n9.3\n10.5\n...\n14.13\n15.15\n16.1\n...\n30.29\n31.31\n32.1\n...\n63.63\n64.1\n...\nn=2^n+x : 1+2x\nn=2^k : 1\n\n\nSo here's the strategy. It's simple:\n\nLet:\n\nn = # of knights including you\nk = an integer >=0\nx = an integer such that 1 <= x < 2^k\n\n1. For every n=2^k where k is an interger>=0, you must sit in the first seat to win.\n\n2. For every interger, n=2^n+x, you must sit in the seat # (1+2x).
665944
I am giving you the pseudocode. You need to implement it yourself.\nAssume the notation [abc] means allowed permutations of string 'abc'\nHence  [abc] = a[bc] + [bc]a\nThe most trivial case is [a] = a\nThis logic lends itself to a recursive routine that should be implementable in each of the languages you mentioned.\nIncase you cant, tell me, I might look into it! :-)
455504
I will explain a method that is the most easy on this planet, and a unique one.\n\nI will illustrate with the help of a simple example.\n\nEg. 4-2.\n\nDraw no. line as follows:\n\n<-6--5--4--3--2--1--0--1--2--3--4--5--6--7-->\n\nNumbers left to zero are negative integers\nand to the right are the positive ones.\n\nLocate 4 on this line. Now move 2 steps behind 4 as the operation to be carried out is subtraction.\n\nThis will give answer as 2. \n\nSimilarly for addition move the steps ahead.
356197
OK, here is what is going on and then the answer:\n\nFirst, assuming that we have the array a (which we assume we do according the problem), then this algorithm is going to look at each item in an array and will assign B a value. The value B holds will be true only if B was true to start and the current item in the array is less than the next.\n\nTherefore if the array A was defined as follows:\n\na[0] = 1\na[1] = 2\na[2] = 3\na[3] = 5\na[4] = 6\na[5] = 8\n\nThe algorithm checks if a[0] <= a[1], and since it is and B is true as well, then B is set to true;\nthen we check a[1] <= a[2], and this is true. Since B is true and this is true, B is set to true. \nthen we check a[2] <= a[3], and this is true. Since B is true and this is true, B is set to true.\nthen we check a[3] <= a[4], and this is true. Since B is true and this is true, B is set to true.\nthen we check a[4] <= a[5], and this is true. Since B is true and this is true, B is set to true.\n\nTherefore it can be determined that as long as the items in the array keep increasing or staying the same (or non-decreasing) then the algorithm will end with B true. So, Answer D is the correct answer.\n\n\nGood luck!
893295
http://obelix.ee.duth.gr/~apostolo/TowersOfHanoi/hanoiA.html
979866
If I am reading this as you have submitted, then, the solution of x=2secx is transcendental, and needs to be solved graphically giving a set of values that satisfy it; you plug that set of values for x that satisfy it into y=3+2tanx, and that gives the solution set for y.
972511
A fascinating subject.\n\nIt's recursively defined.  \n\nf(n+2) = f(n+1) + f(n) for n>0\n\nwhere f(1) = f(2) = 1.\n\nIt has some really neat properties and shows up in nature.
966925
There are 3 solutions for ABCDEFGHJ -\n\n2 6 7 8 3 5 1 4 9\n2 6 7 9 5 3 1 4 8\n6 7 8 4 1 3 2 5 9
723712
One way to solve this is to draw it on graph paper and count up the squares.  Howevr, I think I have a solution that doesn't resort to graphing:\n\nThe units 15 and 42 have a common divisor of 3.  So, if the diagonal starts at (0,0), it will also intersect (5,14) and (10,28).  Therefore, we can reduce this problem to testing a 5 by 14 rectangle and multplying by 3.\n\nFor the 5 by 14 rectangle, since this diagonal won't hit any vertices of the unit squares, just figure you will pass through 14 squares as you make your way across, and you will move up 4 squares.  So, 4 + 14 = 18 squares.  \n\nMultiple by 3 to get your answer for the 15 by 42 rectangle: 18 * 3 = 54.
395570
You can't!  \n\nDefine a recursive sequence as follows:\n\nx_{n+1} = 1/2(x_n - 1)\n\nThen for any x_0 you plug in for x, you can determine the values of all x_i (i nonnegative integer).  The general formula for this sequence is as follows:\n\nx_n = (1/2)^n * (x_0 - n)\n\nNote then that if you plug in a rational number, all numbers in this sequence will be rational while if you plug in an irrational number, all numbers in this sequence will be irrational.\n\nTherefore, all such sequences that share a common element MUST both have a rational seed, x_0 so that they only contain rational numbers, or both have an irrational seed x_0, so that they only contain irrational numbers.\n\nWithout the condition of continuity then, the function g defined by g(x) = 1 if x is rational and g(x) = 0 if x is irrational is a nonconstant function that will satisfy the given condition.
826583
Yes, this is a difficult one.\nI'll keep trying, but don't hold your breath.\nAll I can say so far is that I could find\nonly one solution : (x, y) = (7,1).\nThere do not seem to be any more\nsolutions with x >= 8, and this is what\nneeds to be proved. So good luck with\nfinding someone who can do this.
296877
It has a solution, indeed. It actually has two solutions, -3 and 7. To find it out, set each pair of nomials, (e.g. (x + 3)) to zero. So it would be (x+3)=0. Then solve for x. Do the same for the other nomial, and there you have it.
502102
well chinaren got it started but I believe his explianation is weird.\nLets assume x=3^t\nthen log3(x)+log2(x+1)=3\n=>log3(3^t)+log2(3^t+1)=3\n=>tlog3(3)+log2(3^t+1)=3\n=>log2(3^t+1)=3-t\n=>3^t+1=2^(3-t)\n=>3^t+1=2^3/2^t\n=>(3^t+1)*2^t=2^3\n=>3^t*2^t+2^t=8\n=>6^t+2^t=8\nfrom here there is one one solution possible as t=1\nso x=3^1=3