Skip to content

Instantly share code, notes, and snippets.

@vdonchev
Created June 4, 2015 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdonchev/3f10c329d381fbc413d3 to your computer and use it in GitHub Desktop.
Save vdonchev/3f10c329d381fbc413d3 to your computer and use it in GitHub Desktop.
TextBombardment
using System;
class TextBombardment
{
static void Main()
{
string word = Console.ReadLine();
int lineWidth = int.Parse(Console.ReadLine());
string[] columns = Console.ReadLine().Split(' ');
int match = 0;
foreach (var item in columns)
{
int bomb = int.Parse(item);
for (int i = bomb; i < word.Length; i += lineWidth)
{
if (match > 0 && char.IsWhiteSpace(word[i]))
{
break;
}
else if (char.IsWhiteSpace(word[i]))
{
continue;
}
else
{
word = word.Remove(i, 1).Insert(i, " ");
match++;
}
}
match = 0;
}
Console.WriteLine(word);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment