finished problems 23 and 24 in python