Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

3 of 6
tester code
SztupY
  • 3.9k
  • 1
  • 31
  • 46

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("S107円VsbG8gV29ybGQhCg".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 'Hello World¡'|iconv -t asCIi//TRANSLIT

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

+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}}
SztupY
  • 3.9k
  • 1
  • 31
  • 46

AltStyle によって変換されたページ (->オリジナル) /