Ha ha

Ruby code posted
created at 29 Jan 16:42

Edit | Back
1
2
3
4
5
6
7
8
class Integer;def fact;(1..self).reduce(:*) || 1;end;end

def numberOfTrials(phoneNumber, expectedLength)
  k = phoneNumber.length-expectedLength
  raise "labonneblague" if k <= 0
  n = phoneNumber.squeeze.length
  return k >=n ? 1 : n.fact/(k.fact * (n-k).fact)
end
273 Bytes in 2 ms with coderay