Here is a very simple python function that requires no libraries, implements some of the deepest python magic and is still remarkably easy to understand: