solution to Ferdinand singer and Andrew PYTEL