Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import std.stdio, std.algorithm;
|
||||
|
||||
void pancakeSort(bool tutor=false, T)(T[] data) {
|
||||
foreach_reverse (i; 2 .. data.length + 1) {
|
||||
immutable maxIndex = i - data[0 .. i].minPos!q{a > b}().length;
|
||||
foreach_reverse (immutable i; 2 .. data.length + 1) {
|
||||
immutable maxIndex = i - data[0 .. i].minPos!q{a > b}.length;
|
||||
if (maxIndex + 1 != i) {
|
||||
if (maxIndex != 0) {
|
||||
static if (tutor)
|
||||
|
|
@ -18,7 +18,7 @@ void pancakeSort(bool tutor=false, T)(T[] data) {
|
|||
}
|
||||
|
||||
void main() {
|
||||
char[] data = "769248135".dup;
|
||||
pancakeSort!true(data);
|
||||
writeln(data);
|
||||
auto data = "769248135".dup;
|
||||
data.pancakeSort!true;
|
||||
data.writeln;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue