Created
June 4, 2015 21:04
-
-
Save vdonchev/3f10c329d381fbc413d3 to your computer and use it in GitHub Desktop.
TextBombardment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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