Algorithm for Liquid sort puzzle

1.6k Views Asked by At

I recently came across this game and it is really interesting. https://play.google.com/store/apps/details?id=com.picolaf.liquidsortpuzzle&hl=en_US&gl=US

The goal here is to sort the liquid of all the bottles. I was looking if someone can guide me to what it is called and what should be the algorithm for it?

I figured out few things from the game that I can use for the code..

  1. Use Stack
  2. Cannot Push new element if Limit is reached
  3. Cannot push if not Same color
  4. While Pop if there are more than 1 elements of same color then it should pop all of them
  5. While Pushing if there are more than 1 elements of same color then add all of them
  6. There will be two blank arrays.
  7. If the limit is reached and if all the elements are of same color remove that bottle from the sort list..

Please help and guide me to figure out the algorithm and code for this puzzle. Thanks.