Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
func psort(x, d=x.end) {
|
||||
|
||||
if (d.is_zero) {
|
||||
for i in (1 .. x.end) {
|
||||
(x[i] < x[i-1]) && return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
(d+1).times {
|
||||
x.prepend(x.splice(d, 1)...);
|
||||
x[d] < x[d-1] && next;
|
||||
psort(x, d-1) && return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var a = 10.of { 100.irand };
|
||||
say "Before:\t#{a}";
|
||||
psort(a);
|
||||
say "After:\t#{a}";
|
||||
Loading…
Add table
Add a link
Reference in a new issue