title: HASKELL : Solving Towers of Hanoi
body: <p>The code below solves hanoi returning a list of moves using predefined functions moveLOD,swapLOI and swapLID.</p>
  
  <p>MoveLOD: moves 1 disc from the first position to third the pin in the third position of the triplet. Additionally a string with information about the movement is piling on list of strings.</p>
  
  <pre><code>type Pin = (Char, Int)        -- Represents a rod, named for a character and the number of disks in it.
  type Plate = (Pin, Pin, Pin)  -- Represents the configuration of the three rods.(Origin,Intermediate,Destination
  type Log = (Plate, [String])  -- Represents a state formed by the configuration of rods and a list of strings that will record the movements made by the algorithm.
  
  
  moveLOD :: Log -&gt; Log
  moveLOD (((o,n), i ,(d,k)),s) = (((o,n-1), i ,(d,k+1)), (o:" -&gt; " ++ [d]):s)
  
  -- swapLOI: Change the positions of the origin rods and intermediate rods.
  swapLOI:: Log-&gt;Log
  swapLOI ((o,i,d),s) = ((i,o,d),s) 
  
  -- swapoLID : Change the positions of the intermediate rods and destination rods.
  swapLID:: Log-&gt;Log
  swapLID ((o,i,d),s) = ((o,d,i),s)
  
  hanoi :: Log -&gt; Log
  hanoi:: Int-&gt;Log-&gt;[String]
  hanoi 1 log = transformaLista(moveLOD log)
  hanoi n log = hanoi (n-1) (swapLID log) ++ hanoi 1 log ++ hanoi (n-1) (swapLOI(log))
  
  changeToList::Log-&gt;[String]
  changeToList(p,s) = s
  
  callHanoi:: Int-&gt;[String]
  callHanoi n = hanoi n ((('O',n),('I',0),('D',0)),[])
  </code></pre>