Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,24 @@
import std.stdio, std.algorithm;
void pancakeSort(bool tutor=false, T)(T[] data) {
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)
writeln("With: ", data, " doflip ", maxIndex + 1);
data[0 .. maxIndex + 1].reverse();
}
static if (tutor)
writeln("With: ", data, " doflip ", i);
data[0 .. i].reverse();
}
}
}
void main() {
auto data = "769248135".dup;
data.pancakeSort!true;
data.writeln;
}