Wow! Nice solution. I have been thinking about it for a while and I still have two open quiestions:
The first one seems to be true (at least the cases tested) but I can't see why. I am not so sure about the second one.
Can you give me any clue about them?
Due to my background I would go for a graph search based solution. The nodes of the graph are the state of the row of pancakes and the neighbors of a node are those states reachable by a flip action.
It is not the fastest one, but it is exhaustive and the solution is optimal.
Does it work in any case?
I cannot show you the mathematical explanation but I have some hints.
Let's take the example of the post but reversed:
These are exactly the same flips made above.
I think the key point here is that you should never touch happy pancakes, unless forced to do so because of a nearest unhappy one.
This is not fair !!
I was trying to solve it with other ways.
solution is so simple that its raising Questions..?
does its a complete solution ?
How many rounds do I need to pass if i want to have a job in google🤔
I don't know... I think you should be notable (anything that means) :)
Huh, I can't believe the solution is so simple in the end!
I tried to solve it using XOR and discrete mathematics :(
Thanks for the post!
BTW you got a typo ("at the and")
Yes, that was my thought too!
(thanks for the typo ;) )
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.