Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Created December 5, 2017 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/21c2e668dd0db89838c2bf374fa5ee3a to your computer and use it in GitHub Desktop.
Save lbvf50mobile/21c2e668dd0db89838c2bf374fa5ee3a to your computer and use it in GitHub Desktop.
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