Hi friends,I'm having trouble solving this exercise

Problem
Consider an N by N chessboard and a knight positioned on cell (a, b) (with
0 ≤ a, b <N). The following question arises, given a positive natural integer k (i.e. k> 0),
how many lengths of k and exclusively within the board boundaries the rider
can take.
Your challenge is to answer this question.

Input Format

The entry for this exercise consists of a line containing the 4 integers N, k, a, and b, separated by
a space.

Output Format

A line with the integer M that indicates how many lengths of k difference are possible
on the board starting from (a, b).

Limits
1 ≤ N ≤ 50 1 ≤ k ≤ 8

Input Example
4 2 0 0
Output Example
8

Since this is your homework, you should probably do some work before asking for help. Do you have a general plan for how to solve the problem? Can you think of any subparts of the problem that might be easier to solve? For example, it might be useful to have a function that calculates all the possible knight moves from a given location of an N x N chessboard.

So far I have some lines of codigos where the variables were declared and the creation of the board, I read the elements occupied.

open Printf
open Scanf
open Array

(declarar variaveis)
let n, k, a, b = scanf(readline()) “%d %d %d %d” (fun a b c d -> (a, b, c, d));;

let ocupados = Array.init k (fun _ -> lerpar())
let tabuleiro = make_matrix n n 0

let () = Array.iter (fun (a,b) -> tabuleiro.(a).(b) <- -1) ocupados
let () = tabuleiro.(i).(j) <- 1

let possivel x y = (x>=0 && x<n && y >=0 && y<n && tabuleiro.(x).(y) = 0)
let possiveldes x y mov= (x>=0) && (x<n) && (y >=0) && (y<n) && (tabuleiro.(x).(y) = mov)

let cordx = [|-2; -2; -1; -1; 1; 1; 2; 2|]
let cordy = [|-1; 1; -2; 2; -2; 2; -1; 1|]

Good evening.

A little piece of advice would be to format your code with the Markdown syntax, and to write code in English, so that everyone is able to understand what you write, and help you solve your problem.

Moreover, I think I did not understand clearly what the k parameter means in your problem, so I cannot say more until I know.

Good luck !

But what’s your general plan for solving the problem? A good hint is to look for some way to solve the problem recursively.

As a side comment, I’m pretty sure you can solve the problem without any representation of a chessboard. There’s only one piece involved, so there are no “occupied” squares to worry about.

Like @cloudyhug, I’m not sure I understand the problem. Your description of the meaning of k is confusing. What I’m assuming is that you’re looking to count the number of paths of length k that the knight can take (using legal knight moves). This works for your example: there are 8 different paths of length 2 (as I counted, anyway).