Hello world! with limited character repetition
Ruby (1.9+)
Since this is a popularity contest let's try to not use ANY of the characters from 'Hello world!' while still using other characters only a maximum of two times:
puts("S\107VsbG8gV29ybGQhCg".unpack(?m))
It's 40 chars btw.
Bash
And this one uses unicode magic.
Notes:
- While the orignal characters appear elsewhere (unlike the ruby example), the printed string contains only non-ascii characters.
- Two from the three spaces are actually tabs, so there are no utf-8 characters that appear more than 2 times
- As binary some of the octets do appear more than 2 times, hopefully that's not against the rules. I'm trying to resolve them though.
Code:
echo ' ¡'|iconv -t asCIi//TRANSLIT
For those who don't have a proper font installed it looks like this:
Here is the hexdump:
00000000 65 63 68 6f 20 27 f0 9d 93 97 f0 9d 90 9e f0 9d |echo '..........|
00000010 91 99 f0 9d 92 8d f0 9d 93 b8 e2 80 8a f0 9d 93 |................|
00000020 a6 f0 9d 97 88 f0 9d 96 97 f0 9d 96 91 f0 9d 98 |................|
00000030 a5 c2 a1 27 7c 69 63 6f 6e 76 09 2d 74 09 61 73 |...'|iconv.-t.as|
00000040 43 49 69 2f 2f 54 52 41 4e 53 4c 49 54 0a |CIi//TRANSLIT.|
0000004e
You have to run it on a machine where the default charset is utf-8. I tried on an OSX10.8 using iTerm2 with the following environment:
PHP 5.4
This uses zLib: (unfortunately it does uses the characters e
and o
)
<?=gzuncompress('x▒▒H▒▒▒W(▒/▒IQ▒!qh');
Hexdump:
00000000 3c 3f 3d 67 7a 75 6e 63 6f 6d 70 72 65 73 73 28 |<?=gzuncompress(|
00000010 27 78 9c f3 48 cd c9 c9 57 28 cf 2f ca 49 51 e4 |'x..H...W(./.IQ.|
00000020 02 00 21 71 04 68 27 29 3b |..!q.h');|
00000029
+1
Here is the ruby 2.0 code I used to test for duplicates:
d=ARGF.read
p [d.split(//),d.unpack('C*')].map{|x|x.inject(Hash.new(0)){|i,s|i[s]+=1;i}.select{|k,v|v>2}}
You have to use more expressive languages.
Chinese, 6 4 3 chars
喂世!
Running google translate on this produces Hello world!
(thanks @sreservoir and @Quincunx for the update)
HQ9+, 1 char
H
keeping it simple :)