Simple problem solved in Python