Created
September 2, 2015 23:17
-
-
Save vznvzn/46ec103a900eb289d79a 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
l = [1] | |
seen = {1 => nil} | |
5000.times \ | |
{ | |
j = (0...l.size).min_by { |x| l[x] } | |
x = l.delete_at(j) | |
p(x) | |
([x * 2] + ((x % 3 == 1 && ((x - 1) / 3).odd?) ? [(x - 1) / 3] : [])).each \ | |
{ | |
|z| | |
next if (seen.member?(z)) | |
l << z | |
seen[z] = nil | |
p(z) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment