I submitted a wrong answer to the paper-folding-curve puzzle but still got 100%.
I found it dubious my code worked so I ran some tests myself and found that my code fails for many situations (the longer the required substring, the more my code fails)
Am I in the right place to ask to increase the amount of test cases for this puzzle to cover my bad solutions so I wont get an undeserved 100% pass?
Here are some examples of start-end indexes where my code would fail
Don’t fold it like that. Instead take a thin but long paper, take the end on your right and move it to the end of your left. This way it will be folded once, both ends will be on your left and on your right there will be the folding. Then repeat, moving the end your your right and moving it to the left folding it twice.
If you unfold and put the paper sideways you will get the figure of order-n being n the number of times you fold it.
I had to write it down and fold many papers irl to figure out an algorithm.
Then I have written 5 different approaches in order to get one more or less correct, elegant and functional.
After completing I have seen simpler and more elegant solutions done by others.
I think the key is to look for patterns to be able to find out what goes into each position.
I think that your sequences for order 4 and 5 are wrong.
the lenght sequence for every order is 2**order-1. Then lenght for order 4 is 15 and lenght for order 5 is 31.
the right sequence is for order 4 is 110110011100100; your initial think about the begin of sequence N+1 (same as sequence N) works right in my opinion.
I think that my algorithm is ok, and my solution works with all tests cases except last two, because process has timed out. Now I´m looking for a way to give an answer without calculate all N-1 sequences. This is the very hard problem of this puzzle.
Your order-4 is incorrect. Your order-5 seems to be too short?
The sequence of order-1 curve is: 1
The sequence of order-2 curve is: 110
The sequence of order-3 curve is: 1101100
Note that all “correct” curve representations have a middle fold “1”. There are 4 possible representations because of different ways you look at the paper, but the puzzle fixed on using just one of them.
After some paper calculations and one long strip of paper used to check them, I went with the recursive symbol-by-symbol solution. I was a bit worried about the stack overflows (I used Typescript), but even on max depth it performed pretty well.
Overall pretty interesting problem, props to the author.
for order 4. with example if i begin left bottom i find left, left,right, left left, right, right, right, left , left and right not left.
if i begin right bottom i find left,left, right, left, right so not the right bottom but the left bottom.
thanks for the explanations. I solved the puzzle. it’s easy in reality but the order 4 can confused if you don’t translate correctly as for me.
maybe add the order 4 number in the list .in the puzzle explaining.