Jeroen's Weblog

  • Archive
  • RSS

Text to Morse Code in C#

This was one of those questions on code golf that was very interesting: “Write the shortest program to transform the standard input into Morse code. Characters not in the table should be printed as they are.”

The C# Answer was actually a pretty clever one: class P{static void Main(string[] a){foreach(var t in a[0]){var c=”“;for(int i=” ETIANMSURWDKGOHVF L PJBXCYZQ 54 3 2 16 7 8 90”.IndexOf(t);i>0;i/=2)c=”-.”[i—%2]+c;System.Console.Write(c+” “);}}}

Here are the details: http://codegolf.stackexchange.com/questions/131/morse-code-translator

  • 11 months ago
  • Comments
  • Permalink
  • Share
    Tweet

Recent comments

Blog comments powered by Disqus
← Previous • Next →

About

Software development, architecture and fun!

Pages

  • About Jeroen
  • Calendar

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr