Did #46 in python