How to recursively get the number of elements until reached all sqaures in 5 x 5 grid in scala : So I have a grid 5 x 5 grid. And my initial position is at (0,0)

    0 0 0 0 0
    0 0 0 0 0
    0 0 0 0 0
    0 0 0 0 0
    # 0 0 0 0
I have a method that finds all possible position in 'L' shape from that position
So from **`(0,0)`**. 

So either 

- **( x + 2 )( y + 1 )**

or

- **( x + 1 )( y + 2 )**  

We have two positions


    0 0 0 0 0
    0 0 0 0 0
    0 # 0 0 0
    0 0 0 0 0
    # 0 0 0 0

    or

    0 0 0 0 0
    0 0 0 0 0
    0 0 0 0 0
    0 0 # 0 0
    # 0 0 0 0

Then my method will call it self from the list of all the possible moves and finds the position of each one.

The recursion only breaks if the last position in the possible moves list is the same as the initial position.

So the possible moves for position:

- `(0)(0)` is `List((1,2),(2,1))`

- `List((possible moves for (1,2) ), (possible moves for (2,1) ) )`

and so on:

My method so far
=

<!-- language: scala -->

    def CountTour(dimension: Int, path: Path): Int = {
      // possibleMoves returns list of possible moves
      val Moves = possibleMoves(dim, path, path.head).contains(path.last)
      
      // if the last element is not the same as first position, and has visited the whole graph, then break the recursion
      if (legalMoves && path.size == (dim * dim)) {
        1
      } else {
        // else call the same method again with each possible move
        val newList = for (i <- legal_moves(dim, path, path.head)) yield i
        count_tours(dim,newList)
      }
    }

<!-- end snippet -->

However this won't work. How can i fix it?
