If you switched the order of checking if x and y are within range and switched the check on x to maze[y].Length, this code would also work for mazes with uneven shapes.
The two-dimensional int array could be bools instead, making this slightly more readable and lessening the impact of converting from a string (a one-dimensional char array).
I agree with @dlcoe, This is an excellent answer and beautifully simple! I went with a sans-regex approach for my solution. Wanted to try out a recursive method since I don't use recursion often.
You are genuis , keep going
If you switched the order of checking if x and y are within range and switched the check on x to maze[y].Length, this code would also work for mazes with uneven shapes.
I do not get this solution man, can you explain?
Who gives this piece of a bad code "best practices"? He could also name every variable a/b/c/d/e/f....
The two-dimensional
int
array could bebool
s instead, making this slightly more readable and lessening the impact of converting from a string (a one-dimensional char array).This is clean and simple.
& in this code is a bitwise operator that looks up the lowest bit of a and compare with 1?
Great solution
Wow this is an elegant solution. Good work.
I think NextValue would be better named: "LastValue" to better convey its description as the last value in the range.
tailrec
can be prepended tofun
I think using a seperate (nested) class for your list item would improve readability dramatically.
can i get bonus points for letting the integer division do all the work instead of bringing in if/else or a modulus
I agree with @dlcoe, This is an excellent answer and beautifully simple! I went with a sans-regex approach for my solution. Wanted to try out a recursive method since I don't use recursion often.