tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,18 @@
|
|||
import std.stdio;
|
||||
|
||||
T[][] ncsub(T)(in T[] seq, in int s=0) pure nothrow {
|
||||
if (seq.length) {
|
||||
T[][] aux;
|
||||
foreach (ys; ncsub(seq[1..$], s + !(s % 2)))
|
||||
aux ~= seq[0] ~ ys;
|
||||
return aux ~ ncsub(seq[1..$], s + s % 2);
|
||||
} else
|
||||
return new T[][](s >= 3, 0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
writeln(ncsub([1, 2, 3]));
|
||||
writeln(ncsub([1, 2, 3, 4]));
|
||||
foreach (nc; ncsub([1, 2, 3, 4, 5]))
|
||||
writeln(nc);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue