A quick implementation

Made a quick implementation respecting some constraints as told on
wikipedia.