Hacking The Python Challenge

and no, I’m not talking about the Utah Summer Games Arm Wrestling competition.

I’m talking about Python, the programming language. And to encourage adoption of that language some clever people created a little Python programming game (back in 2005.) You’re presented with a riddle of sorts and you’re supposed to code up a python script to solve it. Only, I don’t like people telling me what to do, so I intentionally did NOT code up python to solve them. I used PHP mostly. Here are my notes:

QUESTION 1: what’s 2^38?
ANSWER: I asked google: http://www.google.com/search?hl=en&q=2%5E38&btnG=Google+Search
and then I used the answer to get to the next step: 274877906944.html

QUESTION 2: given: K->M, O->Q, E->G, decode: g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr’q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.
ANSWER: I used an online cryptogram solver (though i could have written a simple script to shift up two letters…)
“map” then, shifts to “ocr”, which leads to http://www.pythonchallenge.com/pc/def/ocr.html

QUESTION 3: Find rare characters in the mess below (mess omitted)
ANSWER: php:

<span style="color: #000088;">$challenge</span><span style="color: #339933;">=</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="">'phychall2.txt'</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/ereg_replace"><span style="color: #990000;">ereg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[^a-z]&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$challenge</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;

which produces: http://www.pythonchallenge.com/pc/def/equality.html

QUESTION 4: “One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.”
ANSWER: I used textpad’s regex ([a-z][A-Z][A-Z][A-Z][a-z][A-Z][A-Z][A-Z][a-z]) and found “linkedlist”, which means: http://www.pythonchallenge.com/pc/def/linkedlist.html

QUESTION 5: “urllib may help. DON’T TRY ALL NOTHINGS, since it will never end. 400 times is more than enough”
ANSWER:

<span style="color: #000088;">$linked</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;12345&quot;</span>;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">400</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$page</span><span style="color: #339933;">=</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=$linked&quot;</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span>;
 <span style="color: #000088;">$previouslinked</span><span style="color: #339933;">=</span><span style="color: #000088;">$linked</span>;
 <span style="color: #000088;">$linked</span><span style="color: #339933;">=</span><span style="">''</span>;
<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$blank</span><span style="color: #339933;">,</span><span style="color: #000088;">$linked</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=@</span><a href="http://www.php.net/split"><span style="color: #990000;">split</span></a><span style="color: #009900;">&#40;</span><span style="">'and the next nothing is '</span><span style="color: #339933;">,</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span>;
 <span style="color: #000088;">$pos</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Divide&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pos</span> <span style="color: #339933;">===</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$linked</span><span style="color: #339933;">==</span><span style="">''</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$linked</span><span style="color: #339933;">=</span><span style="color: #000088;">$previouslinked</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span>;
   <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;divide found!!&quot;</span><span style="color: #009900;">&#41;</span>;
 <span style="color: #009900;">&#125;</span>
<a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$linked</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>

which produces: http://www.pythonchallenge.com/pc/def/peak.html

QUESTION 6: peak hell
ANSWER:
arghh. have to use python…need to load the pickle dump:

<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">pickle</span>
unpicklefile = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'banner.p'</span>, <span style="color: #483d8b;">'r'</span><span style="color: black;">&#41;</span>
unpickledlist = <span style="color: #dc143c;">pickle</span>.<span style="color: black;">load</span><span style="color: black;">&#40;</span>unpicklefile<span style="color: black;">&#41;</span>
unpicklefile.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> unpickledlist:
        <span style="color: #ff7700;font-weight:bold;">print</span> item
&nbsp;
python unpickle.<span style="color: black;">py</span> <span style="color: #66cc66;">&gt;</span> nextstep.<span style="color: black;">txt</span>

lines look like: [(' ', 14), ('#', 5), (' ', 70), ('#', 5), (' ', 1)]

parse them with:

<span style="color: #000088;">$problem</span><span style="color: #339933;">=</span><a href="http://www.php.net/file"><span style="color: #990000;">file</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;nextstep.txt&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$parseout</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="">'('</span><span style="color: #339933;">,</span><span style="">']'</span><span style="color: #339933;">,</span><span style="">')'</span><span style="color: #339933;">,</span><span style="">'['</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">function</span> printit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #339933;">,</span><span style="color: #000088;">$times</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$loop</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #000088;">$loop</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$times</span>;<span style="color: #000088;">$loop</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$problem</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$tuples</span><span style="color: #339933;">=</span><a href="http://www.php.net/split"><span style="color: #990000;">split</span></a><span style="color: #009900;">&#40;</span><span style="">'),'</span><span style="color: #339933;">,</span><span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tuples</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tuple</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$first</span><span style="color: #339933;">,</span><span style="color: #000088;">$second</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><a href="http://www.php.net/split"><span style="color: #990000;">split</span></a><span style="color: #009900;">&#40;</span><span style="">','</span><span style="color: #339933;">,</span><span style="color: #000088;">$tuple</span><span style="color: #009900;">&#41;</span>;
      <span style="color: #000088;">$first</span><span style="color: #339933;">=</span><a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parseout</span><span style="color: #339933;">,</span><span style="">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$first</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$first</span><span style="color: #339933;">==</span><span style="">''</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$first</span><span style="color: #339933;">=</span><span style="">' '</span>;
      <span style="color: #000088;">$second</span><span style="color: #339933;">=</span><a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parseout</span><span style="color: #339933;">,</span><span style="">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$second</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
      printit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$first</span><span style="color: #339933;">,</span> <span style="color: #000088;">$second</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
  <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>

which produces a nifty ascii art version of: http://www.pythonchallenge.com/pc/def/channel.html

QUESTION 7: : now there are pairs (in http://www.pythonchallenge.com/pc/def/channel.zip)
ANSWER:

<span style="color: #000088;">$linked</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;90052&quot;</span>;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">909</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$bigArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><a href="http://www.php.net/system"><span style="color: #990000;">system</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;zipinfo -v channel.zip {$linked}.txt|tail -3|head -1&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$retval</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #000088;">$page</span><span style="color: #339933;">=</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;{$linked}.txt&quot;</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #000088;">$previouslinked</span><span style="color: #339933;">=</span><span style="color: #000088;">$linked</span>;
  <span style="color: #000088;">$linked</span><span style="color: #339933;">=</span><span style="">''</span>;
  <a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$blank</span><span style="color: #339933;">,</span><span style="color: #000088;">$linked</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=@</span><a href="http://www.php.net/split"><span style="color: #990000;">split</span></a><span style="color: #009900;">&#40;</span><span style="">'Next nothing is '</span><span style="color: #339933;">,</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #000088;">$pos</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Collect&quot;</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pos</span> <span style="color: #339933;">===</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #b1b100;">else</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">10000</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$counter</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">2</span>;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bigArray</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$dot</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dot</span><span style="color: #339933;">==</span><span style="">''</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$dot</span><span style="color: #339933;">=</span><span style="">' '</span>;
  <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dot</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$counter</span><span style="color: #339933;">++%</span><span style="color:#800080;">65</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span>;
 <span style="color: #009900;">&#125;</span>

Which produces more ASCII art and leads to: http://www.pythonchallenge.com/pc/def/oxygen.html

QUESTION 8: the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121]
ANSWER:

<span style="color: #000088;">$im</span> <span style="color: #339933;">=</span> imagecreatefrompng<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;oxygen.png&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">3</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">629</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$rgb</span> <span style="color: #339933;">=</span> imagecolorat<span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">46</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$r</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rgb</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0xFF</span>;
<span style="color: #000088;">$g</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rgb</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0xFF</span>;
<span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rgb</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0xFF</span>;
 <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/chr"><span style="color: #990000;">chr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$r</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>

more code:

<span style="color: #000088;">$thelist</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">105</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">110</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">116</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">101</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">103</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">114</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">105</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">116</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">121</span><span style="color: #009900;">&#41;</span>;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thelist</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/chr"><span style="color: #990000;">chr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>

http://www.pythonchallenge.com/pc/def/integrity.html

QUESTION 9:
un: 'BZh91AY&SYAxafx82rx00x00x01x01x80x02xc0x02x00 x00!x9ah3Mx07<]xc9x14xe1BAx06xbex084'
pw: 'BZh91AY&SYx94$|x0ex00x00x00x81x00x03$ x00!x9ah3Mx13<]xc9x14xe1BBPx91xf08'
ANSWER: missing link : bee
use commandline python, arghh...

s = <span style="color: #483d8b;">&quot;BZh91AY&amp;SYAxafx82rx00x00x01x01x80x02xc0x02x00 x00!x9ah3Mx07&lt;]xc9x14xe1BAx06xbex084&quot;</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">bz2</span>
<span style="color: #dc143c;">bz2</span>.<span style="color: black;">decompress</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>
<span style="color: #483d8b;">'huge'</span>
t = <span style="color: #483d8b;">&quot;BZh91AY&amp;SYx94$|x0ex00x00x00x81x00x03$ x00!x9ah3Mx13&lt;]xc9x14xe1BBPx91xf08&quot;</span>
<span style="color: #dc143c;">bz2</span>.<span style="color: black;">decompress</span><span style="color: black;">&#40;</span>t<span style="color: black;">&#41;</span>
<span style="color: #483d8b;">'file'</span>
<span style="color: #66cc66;">&lt;</span>code<span style="color: #66cc66;">&gt;&lt;</span>/p<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>p<span style="color: #66cc66;">&gt;&lt;</span>strong<span style="color: #66cc66;">&gt;</span>QUESTION <span style="color: #ff4500;">10</span>: <span style="color: #66cc66;">&lt;</span>/strong<span style="color: #66cc66;">&gt;</span>first+second=<span style="color: #66cc66;">?&lt;</span>br /<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>strong<span style="color: #66cc66;">&gt;</span>ANSWER: <span style="color: #66cc66;">&lt;</span>/strong<span style="color: #66cc66;">&gt;</span>
connect the dots
<span style="color: #66cc66;">&lt;</span>code<span style="color: #66cc66;">&gt;</span><span style="color: black;">&#91;</span>php<span style="color: black;">&#93;</span>
$image = imagecreatefromjpeg<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;good.jpg&quot;</span><span style="color: black;">&#41;</span>;
$col_poly = imagecolorallocate<span style="color: black;">&#40;</span>$image, <span style="color: #ff4500;">255</span>, 0, 0<span style="color: black;">&#41;</span>;
$firstArray=<span style="color: #dc143c;">array</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">146</span>,<span style="color: #ff4500;">399</span>,<span style="color: #ff4500;">163</span>,...<span style="color: black;">&#41;</span>;
$secondArray=<span style="color: #dc143c;">array</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">156</span>,<span style="color: #ff4500;">141</span>,<span style="color: #ff4500;">165</span>,...<span style="color: black;">&#41;</span>;
imagepolygon<span style="color: black;">&#40;</span>$image, $firstArray,count<span style="color: black;">&#40;</span>$firstArray<span style="color: black;">&#41;</span>/<span style="color: #ff4500;">2</span>, $col_poly<span style="color: black;">&#41;</span>;
imagepolygon<span style="color: black;">&#40;</span>$image,$secondArray,count<span style="color: black;">&#40;</span>$secondArray<span style="color: black;">&#41;</span>/<span style="color: #ff4500;">2</span>,$colpoly<span style="color: black;">&#41;</span>;
header<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Content-Type: image/jpeg&quot;</span><span style="color: black;">&#41;</span>;
imagejpeg<span style="color: black;">&#40;</span>$image<span style="color: black;">&#41;</span>;

http://www.pythonchallenge.com/pc/return/cow.html

http://www.pythonchallenge.com/pc/return/bull.html

QUESTION 10: a = [1, 11, 21, 1211, 111221, len(a[30]) = ?
ANSWER:
googled for code:

<span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #0000ff;">$str</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;1&quot;</span>; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> .. <a href="http://perldoc.perl.org/functions/shift.html"><span style="color: #000066;">shift</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@ARGV</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$str</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;, &quot;</span><span style="color: #009900;">&#41;</span>; <span style="color: #0000ff;">@a</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/split.html"><span style="color: #000066;">split</span></a><span style="color: #009900;">&#40;</span><span style="color: #339933;">//,</span> <span style="color: #0000ff;">$str</span><span style="color: #009900;">&#41;</span>; <span style="color: #0000ff;">$str</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;&quot;</span>; <span style="color: #0000ff;">$nd</span><span style="color: #339933;">=</span><a href="http://perldoc.perl.org/functions/shift.html"><span style="color: #000066;">shift</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@a</span><span style="color: #009900;">&#41;</span>; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/defined.html"><span style="color: #000066;">defined</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$nd</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$d</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$nd</span>; <span style="color: #0000ff;">$cnt</span><span style="color: #339933;">=</span>0; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/defined.html"><span style="color: #000066;">defined</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$nd</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$nd</span> eq <span style="color: #0000ff;">$d</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$cnt</span>++; <span style="color: #0000ff;">$nd</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/shift.html"><span style="color: #000066;">shift</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@a</span><span style="color: #009900;">&#41;</span>; <span style="color: #009900;">&#125;</span> <span style="color: #0000ff;">$str</span> .<span style="color: #339933;">=</span> <span style="color: #0000ff;">$cnt</span>.<span style="color: #0000ff;">$d</span>; <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$str</span><span style="color: #009900;">&#41;</span>;

paste into textpad for character count

http://www.pythonchallenge.com/pc/return/5808.html

QUESTION 11: odd even
ANSWER:
PBM (Portable BitMap) file (PBM stores single bit pixel image as a series of ascii "0" or "1"'s. The magic identifier for PBM is "P1".)

32 0s and 1s (separated by spaces) on 20 rows makes 640
then switch to 1s and 0s and do this 240 times


print "P1n", "640 480n";
my $odd = ( "0 1 " x 16 . "n" ) x 20;
my $even = ( "1 0 " x 16 . "n" ) x 20;
for ( 1 .. 240 ) { print $odd, $even }

gimp:
load image
load mask.txt as a layer
select that layer
layer->color to alpha
white->alpha

produces: evil