solved ruby 30. could probably have smarter way to limit upper bound