hw1 part1 and draft version of validator R function