fork download
  1. def choose(m)
  2. self.factorial / (m.factorial * (self - m).factorial)
  3. end
  4. def fact(n)
  5. (2..n).inject(1) { |f, n| f * n }
  6. end
  7.  
  8. t = gets.to_i
  9. while t > 0
  10.  
  11. s = gets.chomp
  12. n = s.length
  13. count = []
  14. (1..n).each { |i|
  15. count << s.count(s[i])
  16. }
  17. deno = 1
  18. (1..n).each{ |i|
  19. deno = deno * fact(count[i])
  20. }
  21. puts "#{fact(n)/deno}"
  22. t= t - 1
  23. end
Runtime error #stdin #stdout 0s 4760KB
stdin
4
ab
aa
aA
AAbaz
stdout
Standard output is empty