Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
11
Task/Executable-library/Ruby/executable-library-2.rb
Normal file
11
Task/Executable-library/Ruby/executable-library-2.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# hsfreq.rb
|
||||
require 'hailstone'
|
||||
|
||||
h = Hash.new(0)
|
||||
last = 99_999
|
||||
(1..last).each {|n| h[Hailstone.hailstone(n).length] += 1}
|
||||
length, count = h.max_by {|length, count| count}
|
||||
|
||||
puts "Given the hailstone sequences from 1 to #{last},"
|
||||
puts "the most common sequence length is #{length},"
|
||||
puts "with #{count} such sequences."
|
||||
Loading…
Add table
Add a link
Reference in a new issue