language: Ruby (ruby-1.9.2)
date: 110 days 6 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def choose(m)
    self.factorial / (m.factorial * (self - m).factorial)
  end
  def fact(n)
    (2..n).inject(1) { |f, n| f * n }
  end
 
t = gets.to_i
(1..t).each { |i|
s = gets.chomp
n = s.length
count = []
(1..n).each { |i|
count << s.count(s[i])
}
deno = 1
(1..n).each{ |i|
deno = deno * fact(count[i])
}
puts "#{fact(n)/deno}"
}
  • upload with new input
  • result: Runtime error     time: 0s    memory: 4760 kB     signal: -1

    4
    ab
    aa
    aA
    AAbaz
    prog.rb:14:in `count': can't convert nil into String (TypeError)
    	from prog.rb:14:in `block (2 levels) in <main>'
    	from prog.rb:13:in `each'
    	from prog.rb:13:in `block in <main>'
    	from prog.rb:9:in `each'
    	from prog.rb:9:in `<main>'