This is a programming task. It lays out a problem which Rosetta Code users are encouraged to find solutions to using languages they know.
Each solution should be tested. Please mention details such as compiler, platform, libraries, etc. required to use code.