Skip to content

Instantly share code, notes, and snippets.

@ShayDavidson
Last active December 10, 2015 04:08
Show Gist options
  • Save ShayDavidson/4378567 to your computer and use it in GitHub Desktop.
Save ShayDavidson/4378567 to your computer and use it in GitHub Desktop.
7-boom test function.
sevenBoom = function(n) {
return xBoom(n, 7);
}
xBoom = function(n, boom) {
return dividedBy(n, boom) || containsDigit(n, boom);
}
dividedBy = function(n, x) {
return n % x == 0;
}
containsDigit = function(n, x) {
return n.toString().indexOf(x.toString()) >= 0;
}
def seven_boom(n)
x_boom(n, 7)
end
def x_boom(n, boom)
divided_by(n, boom) or contains_digit(n, boom)
end
def divided_by(n, x)
n % x == 0
end
def contains_digit(n, x)
n.to_s.include?(x.to_s)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment