[#62904] [ruby-trunk - Feature #9894] [Open] [RFC] README.EXT: document rb_gc_register_mark_object — normalperson@...
Issue #9894 has been reported by Eric Wong.
3 messages
2014/06/02
[#63321] [ANN] ElixirConf 2014 - Don't Miss Jos辿 Valim and Dave Thomas — Jim Freeze <jimfreeze@...>
Just a few more weeks until ElixirConf 2014!
6 messages
2014/06/24
[#63391] Access Modifiers (Internal Interfaces) — Daniel da Silva Ferreira <danieldasilvaferreira@...>
Hi,
3 messages
2014/06/28
[ruby-core:63108] Re: [ruby-trunk - Bug #9932] [Open] Permutation - Segment fault
From:
Calamitas <calamitates@...>
Date:
2014-06-11 14:28:37 UTC
List:
ruby-core #63108
On Wed, Jun 11, 2014 at 1:12 PM, <tak2siva@gmail.com> wrote:
> Execute the following program with the inputs
>
>
> ######################################################################################
> # hash.rb
>
> t = gets.chomp.to_i
>
> def hash str
> res = str.count "A"
> if str.size > 1
> s1 = str[0..(str.size/2 - 1)]
> s2 = str[(str.size/2)..-1]
> #p "#{s1}, #{str}"
> res += [hash(s1), hash(s2)].max
> end
>
> res
> end
> #puts hash("AAEAAE")
>
> t.times do |x|
> a = gets.chomp.to_i
> e = gets.chomp.to_i
> v = gets.chomp.to_i
>
> pos = ("A"*a + "E"*e).split('').permutation.map(&:join).uniq
>
> r = 0
>
> pos.each do |y|
> r += 1 if(hash(y)==v)
> end
>
> puts (r % 1000000007)
> end
>
>
> ######################################################################################
>
> $ ruby hash.rb
> $ 1
> $ 234234
> $ 224
> $ 754674567
>
> Then the follwing error is produced
>
>
This looks a lot like a solution to a programming contest problem. Can you
provide a link to the problem statement?
The number of permutations you are asking for is humongous: (234234 + 224)!
which, if my calculations are right, is between 10 ** 1157233 and 10 **
1157234. There won't be a computer that can calculate and store that many
permutations for a long time (if ever).
Peter