Skip to content

Instantly share code, notes, and snippets.

@leeacto
Created July 1, 2013 20:48
Show Gist options
  • Select an option

  • Save leeacto/5904504 to your computer and use it in GitHub Desktop.

Select an option

Save leeacto/5904504 to your computer and use it in GitHub Desktop.
ans = {}
for i in 1..1_000_000
moves = 0
morph = i
until morph == 1 do
if ans[morph] != nil
moves += ans[morph]
break
else
moves += 1
if morph % 2 == 0
morph /= 2
else
morph *= 3
morph += 1
end
end
end
ans[i] = moves
end
puts ans.key(ans.values.max)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment