Rough copy of Problem24. Arrays or string manipulation?