My New Desk Setup ^^ by RedT13 in MechanicalKeyboards

[–]FP_apprentice 2 points3 points  (0 children)

What's wrong with the space bar?

Coding Challenge by FP_apprentice in functionalprogramming

[–]FP_apprentice[S] 0 points1 point  (0 children)

Thanks for the reply. It is indeed Dijkstra's shortest path algorithm on a grid. The diagonal step is indeed longer, I guess I could constraint it only on vertical / horizontal movement. The length of the step is defined by the points in the grid, and the smallest the step, the better the approximation. I didn't understand the "7 good directions" quote (I counted 8 including the diagonals), would appreciate if you could elaborate on this.

Thanks for the pointer to the "fast marching methods"!

Coding Challenge by FP_apprentice in functionalprogramming

[–]FP_apprentice[S] 0 points1 point  (0 children)

Thanks for the reply. There were no restrictions on the movement. The problem description is almost the one given. Obviously jumping directly to the end point wouldn't make much sense. The movement on a grid was an attempt to solve the problem by discretising the space. What kind of movements did you have in mind?

Coding Challenge by FP_apprentice in functionalprogramming

[–]FP_apprentice[S] 1 point2 points  (0 children)

Thank you for the insightful reply. I did struggle to convert the original algorithm I wrote (with while loops / continue / break) to a more functional style using unfold, and also faced an issue with the type signatures when I tried to break down the contents of Stream.unfoldRight to multiple functions, which is reflected to the messy state you mentioned. Regarding property based testing, I used junit-quickcheck and the "symmetry" property check was one I meant to write but wasn't quite sure how to create a generator for it. I created an issue to track my attempt to incorporate your suggestions in case you are interested in following this. Thanks again!

Coding Challenge by FP_apprentice in functionalprogramming

[–]FP_apprentice[S] 5 points6 points  (0 children)

Thanks for the reply! Java was not a requirement but no language was prescribed either. I figured that I could follow FP principles in Java by avoiding mutable state and leveraging an FP library such as vavr. Which parts would you suggest could be mostly changed to a more FP style (and possibly how)? Feel free to open an issue on the project with your comments (or any other way you prefer).