Skip to content

Instantly share code, notes, and snippets.

@fukajun
Created October 29, 2012 11:46
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 fukajun/3973130 to your computer and use it in GitHub Desktop.
Save fukajun/3973130 to your computer and use it in GitHub Desktop.
split number
# a >= b >= c
def split(no, min, bit)
if bit <= 3
no.times do |a|
b = no - a
if a >= b && b >= min
split1(a, b, bit + 1)
if bit == 2
puts "#{a}:#{b}"
elsif bit == 3
puts "#{a}:#{b}:#{min}"
end
end
end
end
end
split(number, 0, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment