setup helper functions for problem 18