Problem 018 and Problem 067 rewritten