KevToTo
Need help
public static string CaesarTower(int n)
{
if (n < 1)
{
throw new ArgumentException();
}
int to;
string res = $"Moves for {n} disks\n";
int total = (int)Basix.MyPow(2, n) - 1;
for (int i = 1; i <= total ; i++)
{
if (n%2==1)
{
res += (i & i - 1) % 3 + 1 + " -> " + (((i | i - 1) + 1) % 3 + 1);
}
else
{
...
}
if (i != total)
res += "\n";
}
return res;
public static string CaesarTower(int n)
{
if (n < 1)
{
throw new ArgumentException();
}
int to;
string res = $"Moves for {n} disks\n";
int total = (int)Basix.MyPow(2, n) - 1;
for (int i = 1; i <= total ; i++)
{
if (n%2==1)
{
res += (i & i - 1) % 3 + 1 + " -> " + (((i | i - 1) + 1) % 3 + 1);
}
else
{
...
}
if (i != total)
res += "\n";
}
return res;
3 replies