The octopus has the ability to solve puzzles, learn from observation and even use tools. Its intelligence comes from an amazing biological structure, quite different from ours. It has a complex nervous system with around 500 millions neurons, spread out in a network throughout the whole body. Only around 10% of the neurons are located in the brain, and most of them in the tentacles.
This allows for tentacles to basically “think for themselves”. Thanks to that and the fact that it has no bone structure, the octopus can find creative solutions to problems like opening jars and containers, how to best blend with its surroundings to escape threats, or navigate mazes.
If you want to learn more about it I recommend the animation video from Ted-Ed