Skip to content

Instantly share code, notes, and snippets.

@glpunk
Created November 19, 2014 00:44
Show Gist options
  • Save glpunk/b501f42851a5898a6071 to your computer and use it in GitHub Desktop.
Save glpunk/b501f42851a5898a6071 to your computer and use it in GitHub Desktop.
utopian tree example
#!/usr/bin/ruby
class Utopiantree
def cycle n
size = 1
if n > 0
for val in 0..n-1
if val % 2 == 0
size = size * 2
else
size = size + 1
end
end
end
size
end
end
p = Utopiantree.new
t = gets.to_i
for val in 1..t
p p.cycle gets.to_i
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment