title: Semi tower of hanoi
body: <pre class="lang-cpp prettyprint-override"><code>void semiHanoi(int n, char source, char destination, char temp) {
      if (n == 2) {//base case
          cout &lt;&lt; "Move from " &lt;&lt; source &lt;&lt; " to " &lt;&lt; destination &lt;&lt; endl;
          cout &lt;&lt; "Move from " &lt;&lt; temp &lt;&lt; " to " &lt;&lt; destination &lt;&lt; endl;
      }
      else {
          semiHanoi((n - 1), source, destination, temp);//to make moves
          semiHanoi(2, destination, temp, source);
          //semiHanoi(2 * (n - 1), destination, source, temp);
  
      }
  }
  </code></pre>
  
  <p>I am tried a lot but could not figure out what and how the recursive calls should go!
  Please Help</p>
  
  <p><strong>This is the question:</strong>
  Semi-Hanoi is a problem very similar to Hanoi problem. The only difference is that your input in semi-Hanoi must be an even number of disks like 2n and they are set as shown in the following figure-a. The peg A has all the even numbered disks such as 2,4,6, … and the peg B has the rest (all the odd numbered disks such as 1,3,5,...). the rules of movement in semi-Hanoi is the same as Hanoi’s rules: • only one disk can be moved at a time • a bigger disk cannot be placed on top of a smaller one The goal is to move all the disks on the peg C in order as shown in figure-b
  here is the image how disks initially looks like</p>
  
  <p><a href="https://i.stack.imgur.com/c3Keo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c3Keo.png" alt="enter image description here"></a></p>