<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://feeds.qzone.qq.com/rss.xsl" version="1.0"?>
<rss version="2.0" xmlns:qz="http://qzone.qq.com">
<channel>
<title><![CDATA[任中方]]></title>
<description><![CDATA[啥？啥名称？]]></description>
<link>http://4907722.qzone.qq.com</link>
<lastBuildDate>Tue, 01 Dec 2009 14:49:31 GMT</lastBuildDate>
<generator>Qzone</generator>
<language>zh-cn</language>
<copyright>Copyright (C), 2005-2008, Tencent Tech. Co., Ltd.</copyright>
<pubDate>Mon, 02 Feb 2009 08:23:34 GMT</pubDate>

<item>
<title><![CDATA[代码发芽网代码高亮测试]]></title>
<link>http://4907722.qzone.qq.com/blog/1233563014</link>
<description><![CDATA[<span style="font-family:'Consolas';line-height:1.8em;"><span style="text-decoration:underline;"><wbr />Python语言</span><wbr />: <a href="http://www.fayaa.com/code/view/20/" target="_blank">Python - 人性化的时间（比如：两分钟以前）</a><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />01</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#人性化的时间：2008-01-27 08:37:29</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />02</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#发芽网使用此函数来显示人性化的时间：比如1分钟以前，三天前，等等</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />03</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />def</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#0060b0;line-height:1.8em;"><wbr />time_span</span><wbr /></span><wbr />(ts):<br><span style="color:#808080;line-height:1.8em;"><wbr />04</span><wbr />    delta <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> datetime<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />now() <span style="color:#303030;line-height:1.8em;"><wbr />-</span><wbr /> ts<br><span style="color:#f810b0;line-height:1.8em;"><wbr />05</span><wbr />    <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />days <span style="color:#303030;line-height:1.8em;"><wbr />&gt;=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />365</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />06</span><wbr />        <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />'</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />年前'</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> (delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />days <span style="color:#303030;line-height:1.8em;"><wbr />/</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />365</span><wbr /></span><wbr />)<br><span style="color:#808080;line-height:1.8em;"><wbr />07</span><wbr />    <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />elif</span><wbr /></span><wbr /> delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />days <span style="color:#303030;line-height:1.8em;"><wbr />&gt;=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />30</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />08</span><wbr />        <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />'</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />个月前'</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> (delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />days <span style="color:#303030;line-height:1.8em;"><wbr />/</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />30</span><wbr /></span><wbr />)<br><span style="color:#808080;line-height:1.8em;"><wbr />09</span><wbr />    <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />elif</span><wbr /></span><wbr /> delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />days <span style="color:#303030;line-height:1.8em;"><wbr />&gt;</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />:<br><span style="color:#f810b0;line-height:1.8em;"><wbr />10</span><wbr />        <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />'</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />天前'</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />days<br><span style="color:#808080;line-height:1.8em;"><wbr />11</span><wbr />    <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />elif</span><wbr /></span><wbr /> delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />seconds <span style="color:#303030;line-height:1.8em;"><wbr />&lt;</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />60</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />12</span><wbr />        <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />&quot;</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />秒前&quot;</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />seconds<br><span style="color:#808080;line-height:1.8em;"><wbr />13</span><wbr />    <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />elif</span><wbr /></span><wbr /> delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />seconds <span style="color:#303030;line-height:1.8em;"><wbr />&lt;</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />60</span><wbr /></span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />*</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />60</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />14</span><wbr />        <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />&quot;</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />分钟前&quot;</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> (delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />seconds <span style="color:#303030;line-height:1.8em;"><wbr />/</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />60</span><wbr /></span><wbr />)<br><span style="color:#f810b0;line-height:1.8em;"><wbr />15</span><wbr />    <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />else</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />16</span><wbr />        <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />&quot;</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />小时前&quot;</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> (delta<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />seconds <span style="color:#303030;line-height:1.8em;"><wbr />/</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />60</span><wbr /></span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />/</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />60</span><wbr /></span><wbr />)<br></span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[4907722@qq.com(任中方)]]></author>
<comments>http://4907722.qzone.qq.com/blog/1233563014#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Mon, 02 Feb 2009 08:23:34 GMT</pubDate>
<guid>http://4907722.qzone.qq.com/blog/1233563014</guid>
</item>

<item>
<title><![CDATA[test2]]></title>
<link>http://4907722.qzone.qq.com/blog/1233448846</link>
<description><![CDATA[<span style="font-family:'Consolas';line-height:1.8em;"><span style="text-decoration:underline;"><wbr />Python语言</span><wbr />: <a href="http://www.fayaa.com/code/view/64/" target="_blank">猜数字7步骤以内快速全求解程序</a><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />001</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#coding=utf-8</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />002</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />003</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#猜数字游戏8步以内的求解决策树生成程序</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />004</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#  通过遍历所有求解方案的方法进行求解</span><wbr /><br><span style="color:#f810b0;line-height:1.8em;"><wbr />005</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />006</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#使用方法：</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />007</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr /># 1. 保存代码为guessall.py</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />008</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr /># 2. 执行python guessall.py &gt; result.txt</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />009</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr /># 3. 打开result.txt看结果</span><wbr /><br><span style="color:#f810b0;line-height:1.8em;"><wbr />010</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />011</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#初始化所有可能的组合，为了可读性和简单性使用了列表推导</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />012</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />def</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#0060b0;line-height:1.8em;"><wbr />init_set</span><wbr /></span><wbr />():<br><span style="color:#808080;line-height:1.8em;"><wbr />013</span><wbr />     r10<span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /><span style="color:#007020;line-height:1.8em;"><wbr />range</span><wbr />(<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />10</span><wbr /></span><wbr />)<br><span style="color:#808080;line-height:1.8em;"><wbr />014</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> [(i, j, k, l)<br><span style="color:#f810b0;line-height:1.8em;"><wbr />015</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> i <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> r10 <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> j <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> r10 <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> k <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> r10 <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> l <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> r10<br><span style="color:#808080;line-height:1.8em;"><wbr />016</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> (i <span style="color:#303030;line-height:1.8em;"><wbr />!=</span><wbr /> j <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />and</span><wbr /></span><wbr /> i <span style="color:#303030;line-height:1.8em;"><wbr />!=</span><wbr /> k <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />and</span><wbr /></span><wbr /> i <span style="color:#303030;line-height:1.8em;"><wbr />!=</span><wbr /> l <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />and</span><wbr /></span><wbr /> j <span style="color:#303030;line-height:1.8em;"><wbr />!=</span><wbr /> k <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />and</span><wbr /></span><wbr /> j <span style="color:#303030;line-height:1.8em;"><wbr />!=</span><wbr /> l <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />and</span><wbr /></span><wbr /> k <span style="color:#303030;line-height:1.8em;"><wbr />!=</span><wbr /> l) ]<br><span style="color:#808080;line-height:1.8em;"><wbr />017</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />018</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#对给定的两组数，计算xAyB</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />019</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />def</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#0060b0;line-height:1.8em;"><wbr />get_match_ab</span><wbr /></span><wbr />(target, source):<br><span style="color:#f810b0;line-height:1.8em;"><wbr />020</span><wbr />     la, lb <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />021</span><wbr />     m <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> [<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />]<br><span style="color:#808080;line-height:1.8em;"><wbr />022</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> i <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />range</span><wbr />(<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />4</span><wbr /></span><wbr />):<br><span style="color:#808080;line-height:1.8em;"><wbr />023</span><wbr />         m[target<span style="font-style:italic"><wbr />] <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> i<span style="color:#303030;line-height:1.8em;"><wbr />+</span><wbr /><span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />024</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> j <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />range</span><wbr />(<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />4</span><wbr /></span><wbr />):<br><span style="color:#f810b0;line-height:1.8em;"><wbr />025</span><wbr />         mj <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> m[source[j]]<br><span style="color:#808080;line-height:1.8em;"><wbr />026</span><wbr />         <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> mj:<br><span style="color:#808080;line-height:1.8em;"><wbr />027</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> mj <span style="color:#303030;line-height:1.8em;"><wbr />==</span><wbr /> j <span style="color:#303030;line-height:1.8em;"><wbr />+</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />028</span><wbr />                 la <span style="color:#303030;line-height:1.8em;"><wbr />+=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />029</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />else</span><wbr /></span><wbr />:<br><span style="color:#f810b0;line-height:1.8em;"><wbr />030</span><wbr />                 lb <span style="color:#303030;line-height:1.8em;"><wbr />+=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />031</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> (la, lb)<br><span style="color:#808080;line-height:1.8em;"><wbr />032</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />033</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#对于给定集合的计算方法!!!</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />034</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#  1. 对于集合中每一个元素，把它作为猜测数</span><wbr /><br><span style="color:#f810b0;line-height:1.8em;"><wbr />035</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#  2. 如果level &gt; MAX_LEVEL，则跳出，对每一种xAyB，生成一个集合</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />036</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#  3. 对每一个生成的集合，调用1</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />037</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#  4. 直到有一次返回True，就返回True</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />038</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />039</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#根据一个guess返回所有的xAxB到所对应的set的映射</span><wbr /><br><span style="color:#f810b0;line-height:1.8em;"><wbr />040</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />def</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#0060b0;line-height:1.8em;"><wbr />split_set</span><wbr /></span><wbr />(ss, guess):<br><span style="color:#808080;line-height:1.8em;"><wbr />041</span><wbr />     <span style="color:#808080;line-height:1.8em;"><wbr />#a * 10 + b is used to indicate an &quot;a &amp; b&quot; combination</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />042</span><wbr />     ab_map <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> {}<br><span style="color:#808080;line-height:1.8em;"><wbr />043</span><wbr />     <span style="color:#808080;line-height:1.8em;"><wbr />#init ab_map, 实际上3A1B是不可能的，亦即不需要&quot;31&quot;</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />044</span><wbr />     <span style="color:#007020;line-height:1.8em;"><wbr />abs</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> (<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />2</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />3</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />4</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />10</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />11</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />12</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />13</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />20</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />21</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />22</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />30</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />31</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />40</span><wbr /></span><wbr />)<br><span style="color:#f810b0;line-height:1.8em;"><wbr />045</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> ab <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />abs</span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />046</span><wbr />         ab_map[ab] <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> []<br><span style="color:#808080;line-height:1.8em;"><wbr />047</span><wbr />     <span style="color:#808080;line-height:1.8em;"><wbr />#let's do the calculation</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />048</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> num <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> ss:<br><span style="color:#808080;line-height:1.8em;"><wbr />049</span><wbr />         (a, b) <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> get_match_ab(num, guess)<br><span style="color:#f810b0;line-height:1.8em;"><wbr />050</span><wbr />         ab_map[a <span style="color:#303030;line-height:1.8em;"><wbr />*</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />10</span><wbr /></span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />+</span><wbr /> b]<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />append(num)<br><span style="color:#808080;line-height:1.8em;"><wbr />051</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> ab_map<br><span style="color:#808080;line-height:1.8em;"><wbr />052</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />053</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />def</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#0060b0;line-height:1.8em;"><wbr />print_map</span><wbr /></span><wbr />(ab_map, level):<br><span style="color:#808080;line-height:1.8em;"><wbr />054</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /><br><span style="color:#f810b0;line-height:1.8em;"><wbr />055</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />&quot;level =&quot;</span><wbr />, level<br><span style="color:#808080;line-height:1.8em;"><wbr />056</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> ab <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> ab_map:<br><span style="color:#808080;line-height:1.8em;"><wbr />057</span><wbr />         <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /> ab, <span style="color:#007020;line-height:1.8em;"><wbr />len</span><wbr />(ab_map[ab])<br><span style="color:#808080;line-height:1.8em;"><wbr />058</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />059</span><wbr /> MAX_LEVEL <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />7</span><wbr /></span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#最多猜MAX_LEVEL次</span><wbr /><br><span style="color:#f810b0;line-height:1.8em;"><wbr />060</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />def</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#0060b0;line-height:1.8em;"><wbr />guess_set</span><wbr /></span><wbr />(gs, level, result, lastab):<br><span style="color:#808080;line-height:1.8em;"><wbr />061</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> level <span style="color:#303030;line-height:1.8em;"><wbr />&gt;</span><wbr /> MAX_LEVEL:<br><span style="color:#808080;line-height:1.8em;"><wbr />062</span><wbr />         <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />False</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />063</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />len</span><wbr />(gs) <span style="color:#303030;line-height:1.8em;"><wbr />==</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />064</span><wbr />         result[<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />][lastab] <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> (gs[<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />])<br><span style="color:#f810b0;line-height:1.8em;"><wbr />065</span><wbr />         <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />True</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />066</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> g <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> gs:<br><span style="color:#808080;line-height:1.8em;"><wbr />067</span><wbr />         new_result <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> (g, {})<br><span style="color:#808080;line-height:1.8em;"><wbr />068</span><wbr />         result[<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />][lastab] <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> new_result<br><span style="color:#808080;line-height:1.8em;"><wbr />069</span><wbr />         ab_map <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> split_set(gs, g)<br><span style="color:#f810b0;line-height:1.8em;"><wbr />070</span><wbr />         bAllTrue <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />True</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />071</span><wbr />         <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> ab <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> ab_map:<br><span style="color:#808080;line-height:1.8em;"><wbr />072</span><wbr />             s <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> ab_map[ab]<br><span style="color:#808080;line-height:1.8em;"><wbr />073</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> s <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />and</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />not</span><wbr /></span><wbr /> guess_set(s, level<span style="color:#303030;line-height:1.8em;"><wbr />+</span><wbr /><span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />, new_result, ab):<br><span style="color:#808080;line-height:1.8em;"><wbr />074</span><wbr />                 bAllTrue <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />False</span><wbr /><br><span style="color:#f810b0;line-height:1.8em;"><wbr />075</span><wbr />                 <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />break</span><wbr /></span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />076</span><wbr />         <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> bAllTrue:<br><span style="color:#808080;line-height:1.8em;"><wbr />077</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />True</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />078</span><wbr />     <span style="color:#808080;line-height:1.8em;"><wbr />#当前level找不到一个MAX_LEVEL以内的方案，退出</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />079</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />return</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />False</span><wbr /><br><span style="color:#f810b0;line-height:1.8em;"><wbr />080</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />081</span><wbr /> max_level <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />082</span><wbr /> level6_plus_tups <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> []<br><span style="color:#808080;line-height:1.8em;"><wbr />083</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />def</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#0060b0;line-height:1.8em;"><wbr />pprint_result</span><wbr /></span><wbr />(result, level <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />):<br><span style="color:#808080;line-height:1.8em;"><wbr />084</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />global</span><wbr /></span><wbr /> max_level, max_level_tup<br><span style="color:#f810b0;line-height:1.8em;"><wbr />085</span><wbr />     (tup, mapping) <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> result<br><span style="color:#808080;line-height:1.8em;"><wbr />086</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /> tup<br><span style="color:#808080;line-height:1.8em;"><wbr />087</span><wbr />     level <span style="color:#303030;line-height:1.8em;"><wbr />+=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />088</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> level <span style="color:#303030;line-height:1.8em;"><wbr />&gt;</span><wbr /> max_level:<br><span style="color:#808080;line-height:1.8em;"><wbr />089</span><wbr />         max_level <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> level<br><span style="color:#f810b0;line-height:1.8em;"><wbr />090</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />len</span><wbr />(mapping) <span style="color:#303030;line-height:1.8em;"><wbr />==</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />091</span><wbr />         <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />092</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />else</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />093</span><wbr />         <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> key <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> mapping:<br><span style="color:#808080;line-height:1.8em;"><wbr />094</span><wbr />             val <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> mapping[key]<br><span style="color:#f810b0;line-height:1.8em;"><wbr />095</span><wbr />             <span style="color:#808080;line-height:1.8em;"><wbr />#打印前缀</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />096</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />u&quot;</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr />|<span style="font-weight:bold"><wbr /><span style="color:#606060;line-height:1.8em;"><wbr />\t</span><wbr /></span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />&quot;</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />*</span><wbr /> level <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />tuple</span><wbr />(<span style="color:#007020;line-height:1.8em;"><wbr />range</span><wbr />(<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />, level <span style="color:#303030;line-height:1.8em;"><wbr />+</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />)),<br><span style="color:#808080;line-height:1.8em;"><wbr />097</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />u&quot;</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />:&quot;</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> (level <span style="color:#303030;line-height:1.8em;"><wbr />+</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />),<br><span style="color:#808080;line-height:1.8em;"><wbr />098</span><wbr />             <span style="color:#808080;line-height:1.8em;"><wbr />#打印xAyB</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />099</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /> <span style="color:#000000;line-height:1.8em;"><wbr />u&quot;</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />A</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />%d</span><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />B&quot;</span><wbr /> <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> (key <span style="color:#303030;line-height:1.8em;"><wbr />/</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />10</span><wbr /></span><wbr />, key <span style="color:#303030;line-height:1.8em;"><wbr />%</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />10</span><wbr /></span><wbr />),<br><span style="color:#f810b0;line-height:1.8em;"><wbr />100</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />len</span><wbr />(val) <span style="color:#303030;line-height:1.8em;"><wbr />==</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />4</span><wbr /></span><wbr />: <span style="color:#808080;line-height:1.8em;"><wbr />#direct result</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />101</span><wbr />                 <span style="color:#808080;line-height:1.8em;"><wbr />#打印结果</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />102</span><wbr />                 <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /> val<br><span style="color:#808080;line-height:1.8em;"><wbr />103</span><wbr />                 <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> level <span style="color:#303030;line-height:1.8em;"><wbr />&gt;=</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />7</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />104</span><wbr />                     level7_plus_tups<span style="color:#303030;line-height:1.8em;"><wbr />.</span><wbr />append((level, val))<br><span style="color:#f810b0;line-height:1.8em;"><wbr />105</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />else</span><wbr /></span><wbr />:<br><span style="color:#808080;line-height:1.8em;"><wbr />106</span><wbr />                 pprint_result(val, level)<br><span style="color:#808080;line-height:1.8em;"><wbr />107</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />108</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#1. 生成所有的四位0-9数字组合，用0123做初始选择，对于所有的xAyB可能性，生成组合</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />109</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#2. 对每一个组合，调用guess_set，看看能否成功解决</span><wbr /><br><span style="color:#f810b0;line-height:1.8em;"><wbr />110</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#3. 如果所有的都能够解决，佩服佩服，打出来吧</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />111</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#4. 怎么记录解决方案组合呢？把猜测过程传入递归函数，就像guessall里面一样</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />112</span><wbr /> <span style="color:#808080;line-height:1.8em;"><wbr />#   result: (当前选择, {21:(下一个选择, {})}, 13:abcd&lt;最终结果值&gt;, ...})</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />113</span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />def</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#0060b0;line-height:1.8em;"><wbr />solve_all</span><wbr /></span><wbr />():<br><span style="color:#808080;line-height:1.8em;"><wbr />114</span><wbr />     allnums <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> init_set()<br><span style="color:#f810b0;line-height:1.8em;"><wbr />115</span><wbr />     ab_map <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> split_set(allnums, (<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />2</span><wbr /></span><wbr />,<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />3</span><wbr /></span><wbr />))<br><span style="color:#808080;line-height:1.8em;"><wbr />116</span><wbr />     solvable <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />True</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />117</span><wbr />     result <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> ((<span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />0</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />1</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />2</span><wbr /></span><wbr />, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />3</span><wbr /></span><wbr />), {})<br><span style="color:#808080;line-height:1.8em;"><wbr />118</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />for</span><wbr /></span><wbr /> ab <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />in</span><wbr /></span><wbr /> ab_map:<br><span style="color:#808080;line-height:1.8em;"><wbr />119</span><wbr />         s <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> ab_map[ab]<br><span style="color:#f810b0;line-height:1.8em;"><wbr />120</span><wbr />         <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />if</span><wbr /></span><wbr /> s <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />and</span><wbr /></span><wbr /> <span style="font-weight:bold"><wbr /><span style="color:#000000;line-height:1.8em;"><wbr />not</span><wbr /></span><wbr /> guess_set(s, <span style="font-weight:bold"><wbr /><span style="color:#6000e0;line-height:1.8em;"><wbr />2</span><wbr /></span><wbr />, result, ab): <span style="color:#808080;line-height:1.8em;"><wbr />#第一次猜测是0123，所以这已经是第二次了</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />121</span><wbr />             solvable <span style="color:#303030;line-height:1.8em;"><wbr />=</span><wbr /> <span style="color:#007020;line-height:1.8em;"><wbr />False</span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />122</span><wbr />             <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />break</span><wbr /></span><wbr /><br><span style="color:#808080;line-height:1.8em;"><wbr />123</span><wbr />     <span style="font-weight:bold"><wbr /><span style="color:#008000;line-height:1.8em;"><wbr />print</span><wbr /></span><wbr /> solvable, <span style="color:#000000;line-height:1.8em;"><wbr />&quot; for limit step @&quot;</span><wbr />, MAX_LEVEL<br><span style="color:#808080;line-height:1.8em;"><wbr />124</span><wbr />     pprint_result(result)<br><span style="color:#f810b0;line-height:1.8em;"><wbr />125</span><wbr /> <br><span style="color:#808080;line-height:1.8em;"><wbr />126</span><wbr /> solve_all()<br></span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[4907722@qq.com(任中方)]]></author>
<comments>http://4907722.qzone.qq.com/blog/1233448846#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Sun, 01 Feb 2009 00:40:46 GMT</pubDate>
<guid>http://4907722.qzone.qq.com/blog/1233448846</guid>
</item>

<item>
<title><![CDATA[asdf]]></title>
<link>http://4907722.qzone.qq.com/blog/1223618992</link>
<description><![CDATA[按时<span style="font-weight:bold"><wbr /><span style="color:#00CC00;line-height:1.8em;"><wbr />打发</span><wbr /></span><wbr />士大夫 <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[4907722@qq.com(任中方)]]></author>
<comments>http://4907722.qzone.qq.com/blog/1223618992#comment</comments>
<qz:effect>512</qz:effect>
<pubDate>Fri, 10 Oct 2008 06:09:52 GMT</pubDate>
<guid>http://4907722.qzone.qq.com/blog/1223618992</guid>
</item>

<item>
<title><![CDATA[刚刚开通了空间，希望大家常来转转:)]]></title>
<link>http://4907722.qzone.qq.com/blog/1214919895</link>
<description><![CDATA[　　QQ空间很有趣，而且我渐渐发现周围越来越多的朋友都开通了QQ空间。我今天开通了自己的空间，这样，以后看看朋友们都在做什么，也能让朋友们知道自己在做什么，很方便。经常来我的空间转转吧！<br><br>　　最近新电影不少，你有没有什么电影想推荐给我？给我留言吧。除了电影，生活也是很丰富的。如果我有一个假期，我希望找朋友们聚聚，能好好的旅游一次，最好再有时间好好的休息一下。你打算怎么度过你的假期的？告诉我吧！<br><br>　　现在我的空间还有一点冷清，给我<a href="http://user.qzone.qq.com/4907722/msgboard_new" target="_blank">留言</a><wbr />吧，支持我一下！最重要的，不要忘了<a href="http://user.qzone.qq.com/4907722/interact_new" target="_blank">加我好友</a><wbr />，这样下次你来的时候就方便多了。<br><br>另外，如果你在其他博客上有日记或者照片，可以用QQ空间搬家工具(<a href="http://n.qzone.qq.com/move/move_login.htm" target="_blank">http://n.qzone.qq.com/move/move_login.htm</a><wbr />)把它们备份到QQ空间。让我们一起享受QQ空间的网络生活新体验！:) <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[4907722@qq.com(任中方)]]></author>
<comments>http://4907722.qzone.qq.com/blog/1214919895#comment</comments>
<qz:effect>0</qz:effect>
<pubDate>Tue, 01 Jul 2008 13:44:55 GMT</pubDate>
<guid>http://4907722.qzone.qq.com/blog/1214919895</guid>
</item>

</channel>
</rss>

