commit deletes
This commit is contained in:
parent
776bba907c
commit
372c577f83
233 changed files with 0 additions and 6724 deletions
|
|
@ -1,21 +0,0 @@
|
|||
class Array
|
||||
def func_power_set
|
||||
inject([[]]) { |ps,item| # for each item in the Array
|
||||
ps + # take the powerset up to now and add
|
||||
ps.map { |e| e + [item] } # it again, with the item appended to each element
|
||||
}
|
||||
end
|
||||
|
||||
def non_continuous_subsequences
|
||||
func_power_set.find_all {|seq| not seq.continuous}
|
||||
end
|
||||
|
||||
def continuous
|
||||
each_cons(2) {|a, b| return false if a+1 != b}
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
p (1..3).to_a.non_continuous_subsequences
|
||||
p (1..4).to_a.non_continuous_subsequences
|
||||
p (1..5).to_a.non_continuous_subsequences
|
||||
Loading…
Add table
Add a link
Reference in a new issue