[Solved] Illuminati Lock - Drawing C# Task

  

3
Topic starter

Hello 008, you have been tasked with assisting 007 on a top secret mission to bring down a Global Illuminati Conspiracy. You’re standing in front of the final lock to the Illuminati Secret Meeting. It is a very special lock which asks you to input a specific symbol. 007 quickly guesses that the symbol has to be the Illuminati symbol, luckily for you 007 is really good at drawing triangles, what he isn’t good at however is drawing eyes so he asks for your help.

You are given an integer number N (always odd) – the height of the eye is N+1, while the width is 3 * N

Input

The input data should be read from the console.

  • On the only input line you will be given the number N.

The input data will always be valid and in the format described. There is no need to check it explicitly.

 

Output

The output should be printed on the console. Use the “#” (number sign) for the eye and “.” (dot) for the rest. Follow the examples below.

Constraints

  • N will always be a positive odd number in the range [5  59].
  • Allowed working time for your program: 0.1 seconds. Allowed memory: 16 MB.

Examples

illuminati lock drawing c# task example 1

illuminati lock drawing c# task example 2

1 Answer
2

Here is my solution! 🙂

using System;
 
class Task3
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
 
        Console.WriteLine("{0}{1}{0}",
             new string('.', n),
             new string('#', n));//1ST PART
 
        Console.WriteLine("{0}{1}{2}{1}{0}",
            new string('.', n - 2),
            new string('#', 3),
            new string('.', n - 2));//2ND PART
 
        for (int i = 0; i < n / 2 - 1; i++)//3RD PART
        {
            Console.WriteLine("{0}{1}{2}{3}{4}{3}{2}{1}{0}",
                new string('.', ((n - 4) - 2 * i)),
                new string('#', 2),
                new string('.', 2 + 2 * i),
                new string('#', 1),
                new string('.', n - 2));
        }
 
        for (int i = 0; i < n / 2 - 1; i++)//4TH PART
        {
            Console.WriteLine("{0}{1}{2}{3}{4}{3}{2}{1}{0}",
                new string('.', (1 + (2 * i))),
                new string('#', 2),
                new string('.', (n - 3) - 2 * i),
                new string('#', 1),
                new string('.', n - 2));
        }
 
        Console.WriteLine("{0}{1}{2}{1}{0}",
                new string('.', n - 2),
                new string('#', 3),
                new string('.', n - 2));//2ND PART
 
        Console.WriteLine("{0}{1}{0}",
                 new string('.', n),
                 new string('#', n));//1ST PART
    }
}
Share: