Last active
December 10, 2015 04:08
-
-
Save ShayDavidson/4378567 to your computer and use it in GitHub Desktop.
7-boom test function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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