Advertisement
ivanov_ivan

StripedTowel

Jun 3rd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace StripedTowel
  8. {
  9.     class StripedTowel
  10.     {
  11.         static void Main()
  12.         {
  13.             int width = int.Parse(Console.ReadLine());
  14.             int height = (int)Math.Floor(width * 1.5D);
  15.             string row = "";
  16.             List<string> hack = new List<string>();
  17.  
  18.             for(int i = 1; i <= 3; i++)
  19.             {
  20.                 if(i % 2 == 0 )
  21.                 {
  22.                     string pattern = "..#";
  23.                     for(int a = 0; a < width; a++)
  24.                     {
  25.                        row += pattern;
  26.                     }
  27.                 }
  28.                 else if(i % 3 == 0)
  29.                 {
  30.                     string pattern = ".#.";
  31.  
  32.                     for(int a = 0; a < width; a++)
  33.                     {
  34.                         row += pattern;
  35.                     }
  36.                 }
  37.                 else
  38.                 {
  39.                     string pattern = "#..";
  40.                     for(int a = 0; a < width; a++)
  41.                     {
  42.                         row += pattern;
  43.                     }
  44.                 }
  45.  
  46.                 hack.Add(row.Remove(width));
  47.                 row = "";
  48.             }
  49.             int rows = 0;
  50.             for(int i = 0; i < height; i++)
  51.             {
  52.                 Console.WriteLine(hack[rows]);
  53.                 rows++;
  54.                 if(rows == 3 )
  55.                 {
  56.                     rows = 0;
  57.                 }
  58.             }
  59.            
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement