Ja, das mit den Permutationen weiß ich, wieviele das sind.
Nur bekomme ich es immernoch nicht wirklich hin.
Ich fühle mich grad ein wenig verschusselt und hab keine Ahnung, was ich dort wie aus meiner Rekursion ersetzen muss:
do
{
Console.SetCursorPosition(0, 0);
Console.WriteLine("Alte Reihenfolge: " + reiheString);
Console.WriteLine("Suche neue Reihenfolge . . . bitte warten . . .");
for (x = 8; x >= 1; x--)
{
if (int.Parse(reiheString.Substring(x, 1)) > int.Parse(reiheString.Substring(x - 1, 1)))
{
n = x - 1;
x = 0;
}
}
nString = reiheString.Substring(n, 1);
z = -1;
sString = "";
do
{
z++;
if (z >= 9)
{
return;
}
sString = reiheString.Substring(int.Parse(nString) + z 1);
s = reiheString.IndexOf(sString, n + 1);
} while (s == -1);
for (x = 0; x < 9; x++)
{
rxString[x] = reiheString[x];
}
Swap(ref rxString, n, s);
reiheString = reiheString.Substring(0, n) + sString;
for (x = 0; x < 9; x++)
{
for (y = n+1; y < 9; y++)
{
if (rxString[y] == (char)(49 + x))
{
reiheString = reiheString + rxString[y];
}
}
}
anzahlInt = anzahlInt + 1;
for (x = 0; x < 9; x++)
{
r = int.Parse(reiheString.Substring(x, 1));
for (b = 0; b < 5; b++)
{
kString[x, b] = dString[r - 1, b];
}
}
Display(kString);
if (Dreh(ref kString))
{
Display(kString);
Console.ReadKey();
}
} while (reiheString != "987654321");
private static void Swap(ref char[] a, int iPos1, int iPos2)
{
char c = a[iPos1];
a[iPos1] = a[iPos2];
a[iPos2] = c;
}
Ich habe momentan leider ein totales Blackout und weiß absolut nicht, wie ich das da rein bekommen könnte, sodass es mit MEINEN Variablen funktioniert. Würdest du dir die Mühe machen, und mir das da rein packen? Wäre echt lieb.