Skip to content

Instantly share code, notes, and snippets.

@spookylukey
Created January 21, 2010 11:37
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 spookylukey/282739 to your computer and use it in GitHub Desktop.
Save spookylukey/282739 to your computer and use it in GitHub Desktop.
// See http://www.reddit.com/r/programming/comments/as759/hey_reddit_out_of_these_4_programmers_who_would/
using System;
class MainClass {
static int Main(string[] argv) {
foreach (string s in new string[] {"hello", "λ", Char.ConvertFromUtf32(0x1D161)}) {
Console.WriteLine(s);
Console.WriteLine(Reverse(s));
}
return 0;
}
// Candidate 3
static string Reverse(string input)
{
char[] chars = input.ToCharArray();
Array.Reverse(chars);
return new String(chars);
}
}
// Output - hello and λ work as expected, 0x1D161 is a musical note symbol which gets trashed on reversing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment