Created
July 27, 2015 21:00
-
-
Save vznvzn/34805d8c38126922ccb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hist(l, i) | |
return if (l.size == 1) | |
l = l.dup | |
l.map! { |x| x.to_s(2).length } | |
mn = l.min | |
mx = l.max | |
r = (mx - mn) | |
w = 100 | |
h = [0] * (w + 1) | |
l.each { |x| h[((x.to_f - mn) / r * w).to_i] += 1 } | |
h.each_with_index { |y, x| puts([x, y, i].join("\t")) } | |
puts | |
end | |
l = [1] | |
seen = {} | |
ARGV[0].to_i.times \ | |
{ | |
|i| | |
l2 = [] | |
l.each \ | |
{ | |
|x| | |
next if (seen.member?(x)) | |
seen[x] = nil | |
l2 << x * 2 | |
l2 << (x - 1) / 3 if (x % 3 == 1 && ((x - 1) / 3).odd?) | |
} | |
l = l2 | |
hist(l, i) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment