I’m trying to achieve this output:
LOWEST LOW MEDIUM HIGH HIGHEST HIGHEST HIGH MEDIUM LOW LOWEST
I know there are many ways to do it, but I’m trying it in single loop, is it achievable?
My code is basically like this:
class Program {
static void Main()
{
string[] phases = ["LOWEST", "LOW", "MEDIUM", "HIGH", "HIGHEST"];
int fullRotation = (phases.Length - 1) * 2;
for (int i = 0; i <= fullRotation; i++)
{
int index;
if (i <= (phases.Length - 1))
{
index = i;
}
else
{
index = fullRotation - i;
}
Console.Write(phases[index] + " ");
}
}
}
I’m getting:
LOWEST LOW MEDIUM HIGH HIGHEST HIGH MEDIUM LOW LOWEST