Skip to content

Instantly share code, notes, and snippets.

@yoshikazuendo
Created November 12, 2013 17:11
Show Gist options
  • Save yoshikazuendo/7434760 to your computer and use it in GitHub Desktop.
Save yoshikazuendo/7434760 to your computer and use it in GitHub Desktop.
CodeIQ じぇじぇじぇなコードを書いてくんろ! スパゲティ(spagetti)に紛れているナポリタン(neapolitan)を取り出して下さい。 のコードです。 https://codeiq.jp/ace/kansai_takako/q390
static void Main(string[] args)
{
var ret = "";
string spagetti = "gtgtsgipgttptinggipsppaigsesgpetgstpatetisiesagaeaigttetepitiatsegssieeeeatepaaiagtpieataatppiitgiapsteitatiiatpetetetttgpetpaasipttssstpeeeggtiagtttegtiipestsasgpsepaasapttgattgiatppegitiatpasgatgepttggapesaeetaeissttggieietgspagesiipestipggstttpateptitiaetottissgggtttaipappgstsptttgtpispattgegstltiappseisapgistaiagteeiptptpisaieisagstapeteietgteiisgtiptstgtstasspeatspptitttatteastsgtptgtasggpniaaeteaisett";
string neapolitan = "neapolitan";
for (int i = 0; i < spagetti.Length; i++) {
char ch = spagetti[i];
if (ch == neapolitan.First()) {
ret += "[" + ch + "]";
neapolitan = neapolitan.Remove(0, 1);
if (neapolitan == "") {
ret += spagetti.Substring(i, spagetti.Length - i);
break;
}
} else {
ret += ch;
}
}
Console.WriteLine(ret.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment