Codegolf: Difference between revisions
Jump to navigation
Jump to search
Line 13: | Line 13: | ||
==== [[User:PhilFry|PhilFry]]: Ruby ==== | ==== [[User:PhilFry|PhilFry]]: Ruby ==== | ||
ruby -e' | ruby -e'y={};$<.each{|w|w.downcase!;y[w]=0;r=w.tr"a-z","n-za-m";p w+"->"+r if y[r]}' < /usr/share/dict/web2 | ||
75 Zeichen | |||
==== Ch3ka: php ==== | ==== Ch3ka: php ==== |
Revision as of 13:08, 18 September 2007
Challenge #1
<SdK> gibts wörter, die nach rot13 n anderes existierendes wort ergeben?
mxf: Perl
perl -nle'$w{+lc}++}for(keys%w){$r=$_;y/a-z/n-za-m/;$w{$_}&&print"$r -> $_' /usr/share/dict/web2
65+2 Zeichen
urs: Perl
perl -nle'($u=$a{$i=$_=lc})&&print"$_->$u";y;a-z;n-za-m;;$a{$_}=$i' /usr/share/dict/web2
56+2 Zeichen
PhilFry: Ruby
ruby -e'y={};$<.each{|w|w.downcase!;y[w]=0;r=w.tr"a-z","n-za-m";p w+"->"+r if y[r]}' < /usr/share/dict/web2
75 Zeichen
Ch3ka: php
<?$f=file($argv[1]);while($a[]=strtolower(next($f))){}while($b[]=str_rot13(next($a))){$c=end($b);if(in_array($c,$a))echo$c;}?>
122 Chrs
Kungi: Python
import sys e={};a=open(sys.argv[1]).read().lower().split() for w in a:e[w]="" for w in a: b=w.encode('rot13') if e.has_key(b):e[b]=w for a,b in e.iteritems(): if b:print a+" -> "+b
kungi@BeerBook: wc golf2.py 8 23 184 golf2.py