Skip to content

Instantly share code, notes, and snippets.

@vznvzn
Created September 2, 2015 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vznvzn/46ec103a900eb289d79a to your computer and use it in GitHub Desktop.
Save vznvzn/46ec103a900eb289d79a to your computer and use it in GitHub Desktop.
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