Decode the following string and encode it back.
Any programming language is welcome, the point is to create a solution with the minimum amount of characters.
Formatting and new lines does not count toward the char count.
Here's the message:
1010100 1101000 1100101 1110010 1100101 1100001 1110010 1100101 110001 110000 1110100 1111001 1110000 1100101 1110011 1101111 1100110 1110000 1100101 1101111 1110000 1101100 1100101 101110 1000100 1100101 1100011 1101111 1100100 1100101 1110100 1101000 1101001 1110011 1110011 1110100 1110010 1101001 1101110 1100111 1100001 1101110 1100100 1100101 1101110 1100011 1101111 1100100 1100101 1101001 1110100 1100010 1100001 1100011 1101011
EDIT
Sigh .... anyway, just for the record:
I create this code-golf after reading google's first message on Twitter: http://twitter.com/google
Yes, probably most of you will find that initial message pointless too, obscure or stupid, but I find it amusing.
Since I wanted to know what it mean, I get to code the simplest binary coder / decoder I could think of:
public static String encode( String s ) {
char [] ca = s.toCharArray();
StringBuilder sb = new StringBuilder();
for( char c : ca ) {
sb.append( c == ' ' ? c : Integer.toString(c,2 ) );
sb.append( ' ' );
}
return sb.toString();
}
public static String decode( String b ) {
String [] p = b.split(" ");
StringBuilder sb = new StringBuilder();
for( String s : p ) {
sb.append( "".equals(s) ? " ": ( char ) Integer.parseInt( s , 2 ) );
}
return sb.toString();
}
Simple, yet verbose, which obviously led me to think: I bet code-golf on SO will show tons of shorter/elegants solutions for this in perl/python/ruby/c# etc