Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Created September 1, 2011 14:54
Show Gist options
  • Save nwjsmith/1186334 to your computer and use it in GitHub Desktop.
Save nwjsmith/1186334 to your computer and use it in GitHub Desktop.
Dave's solution
[1,1,1,1,2,2,2,1,1,1,3,3,3].inject([]) {|on_boundary_array,x|
if on_boundary_array == [] || on_boundary_array[-1][0] != x
on_boundary_array = on_boundary_array + [[x]]
else
on_boundary_array[-1] << x
end
on_boundary_array
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment