-
-
Save lbvf50mobile/21c2e668dd0db89838c2bf374fa5ee3a to your computer and use it in GitHub Desktop.
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 number_of_varitans y | |
s = y.size | |
z = y.count(0) | |
d = (y - ['0']).uniq.size | |
( s - z) * f( s - 1 )/( f(z) * f(d)) # https://stackoverflow.com/a/47616628/8574922 | |
end | |
def f n | |
(1..n).inject(:*) || 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment