Hier ist die Aufgabe:

Das habe ich soweit:

public static long waysHome(int length, int x, int y) {

if (x == length && y == 0) { // Base case: reached the end

return 1;

} else if (x > length || y < 0 || y > (length - x)) { // Edge case: exceeded the boundary

return 0;

} else {

// Recursive case: count the number of ways to reach the end by going right and swaying left or right

return waysHome(length, x + 1, y) + waysHome(length, x + 1, y + 1) + waysHome(length, x + 1, y - 1);

}

}

Leider funktioniert es nicht. Wäre cool, wenn ihr mir hilft .