<?xml version="1.0" encoding="windows-1252"?>
<node id="31571" title="'nother P(erl|ython) Hacker" created="2000-09-08 10:18:12" updated="2005-08-15 09:17:27">
<type id="1588">
obfuscated</type>
<author id="21732">
BooK</author>
<data>
<field name="doctext">
&lt;p&gt;As you can see,  this is not obfuscated and the game is quite stupid.
This is in fact my try to make Perlists and Pythonists friends again.&lt;/p&gt;
&lt;p&gt;Juste note that the Perl code could be way shorter, whereas the Python one
could not. &lt;tt&gt;:-)&lt;/tt&gt;&lt;/p&gt;
&lt;code&gt;
######################################################################
# Python                       # Perl                                #
######################################################################
q = -1 ;                       #=; $n = int rand 1001; print '? ';  q#
import whrandom ; i = 1        #;  while(&lt;&gt;){                       q#
n = whrandom.randint(0,1000)   #;      $i++;                        q#
while q != n :                 #;      last if $_ == $n;            q#
  q = int(raw_input('? '))     #;      print 'Too ';                q#
  if q == n :                  #;      print ($_&gt;$n?'big':'small'); q#
    break                      #;      print "\n? ";                q#
  print 'Too',                 #;  }                                q#
  if q &gt; n :                   #;  print "You won in $i tries\n";   q;
    print 'big'                #
  else:                        #
    print 'small'              #
  i = i + 1                    #
print 'You won in', i, 'tries' #;
&lt;/code&gt;
&lt;p&gt;You might as well imagine this as documenting Python code in Perl,
and Perl code in Python, for beginners in any of the two languages.&lt;/p&gt;
</field>
</data>
</node>
