Problem 776. TRON strategy toggle
Suggestion on implementation. Usage of persistent with a flag that bikes are isolated will save time.
Anyone knows why I cannot change recursion limit by set(0,'RecursionLimit',1200)? As far as I recall, I had done it before in Cody. Has Cody blocked access to this option?
Hello Rifat. I've made some tests and had no problem to change 'RecursionLimit' to 1200 although for a very simple function I've been able to do up to 993 recursions, but for any higher number cody server returned 'temporary unavailability of MATLAB Service' error. Please note that this problem occured when a function which was using recursion were changeing 'RecursionLimit' by itself (even if 'set(...' is called only once). When limit was changed from main function and a subfunction was recursed, or when limit was changed from testsuite everything works normal.
yes.. I changed recursion limit from the subfunction. thanks for the tips.. :)
As I commented elsewhere, only 1198 loops are necessary. The longest path in a square array avoiding adjacent squares is a spiral from a corner to a point near the center. (For odd, a deep slalom gives the same answer.) The number of steps is:
For 48, this is 1198, not 2500.
Lessons from other solutions:
My convolution should have been with:
[ 0 1 0; 1 1 1; 0 1 0].
filter2 works better than conv2 here; no need to trim edges.
Great solution, and proper!
I doubt you're saving anything with t, as you only use it once and don't need to enclose it in parenthesis.
2500 is overkill. Should be based on 48^2, and then only a bit over half. The longest possible path separated by "tracks" is a spiral in from one corner. For odd boards (where a slalom can be as long), the formula is (n^2+2n-3)/2. For even, it's (n^2+2n-4)/2. For 48, this is 1198.
Problem Recent Solvers17
Make the vector [1 2 3 4 5 6 7 8 9 10]
Remove the small words from a list of words.
Remove white space from the string
More from this Author3
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!