Skip to content

Instantly share code, notes, and snippets.

@jashmenn
Created February 26, 2009 17:45
Show Gist options
  • Save jashmenn/70979 to your computer and use it in GitHub Desktop.
Save jashmenn/70979 to your computer and use it in GitHub Desktop.
def keep_splitting(values)
return if values.empty?
if values.include?(true) && values.include?(false)
puts
puts "Values"
p values
puts "have a mixture, keep splitting"
column_2 = (column_1 = values.dup).slice!(0, values.size/2)
keep_splitting(column_2)
keep_splitting(column_1)
else
puts
puts "Values"
p values
puts "are all the same. we are done."
return
end
end
values = [true, false, true, true, true, true, false, false]
keep_splitting(values)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment