Python solution
Solution with command line