Codegolf: Difference between revisions

From NoName e.V.
Jump to navigation Jump to search
No edit summary
No edit summary
Line 17: Line 17:


==== Ch3ka: php ====
==== Ch3ka: php ====
<?$a=file('/usr/share/dict/web2');while($b[]=strtolower(str_rot13(next($a)))){}foreach($a as $c)if(in_array(strtolower($c),$b))echo $c;?>
<?$a=file('/usr/share/dict/web2');while($b[]=strtolower(str_rot13(next($a)))){}foreach($a as $c)if(in_array(strtolower($c),$b))echo $c;?>


ch3ka@bihatsch: wc rot13test.php                                               
ch3ka@bihatsch: wc rot13test.php                                               
   1  4 138 rot13test.php
   1  4 138 rot13test.php




[[Category:Projekte]]
[[Category:Projekte]]

Revision as of 08:59, 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

PhilFry: Ruby

ruby -e'words={};IO.readlines(ARGV[0]).each{|w|words[w.downcase.chomp]=true};words.each_key{|w|r=w.tr("a-z","n-za-m");puts w+"->"+r if words[r]}' /usr/share/dict/web2 

136 Zeichen [Ausgabe]

real    0m9.114s
user    0m5.692s
sys     0m0.421s

Ch3ka: php

<?$a=file('/usr/share/dict/web2');while($b[]=strtolower(str_rot13(next($a)))){}foreach($a as $c)if(in_array(strtolower($c),$b))echo $c;?>
ch3ka@bihatsch: wc rot13test.php                                              
 1   4 138 rot13test.php