{"id":1844,"date":"2012-04-08T13:35:00","date_gmt":"2012-04-08T05:35:00","guid":{"rendered":""},"modified":"2012-04-08T13:35:00","modified_gmt":"2012-04-08T05:35:00","slug":"","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/1844.html","title":{"rendered":"\u7528Python\u89e3\u5c0f\u5b66\u4e09\u5e74\u7ea7\u9898"},"content":{"rendered":"<p><html><head><meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/><title>\u7528Python\u89e3\u5c0f\u5b66\u4e09\u5e74\u7ea7\u9898<\/title><\/head><body><\/p>\n<h1 style=\"display:none\">\u7528Python\u89e3\u5c0f\u5b66\u4e09\u5e74\u7ea7\u9898<\/h1>\n<div>\n<p><span style=\"font-size: 14px;\">\u539f\u9898\u662f\u8fd9\u6837\u7684\uff1a<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u67092,3,4,5,6,7,8\u4e03\u4e2a\u6570\u5b57\uff0c\u8981\u628a\u4ed6\u4eec\u653e\u5230\u4e0b\u9762\u7684\u7b97\u5f0f\u7684X\u4e2d\uff0c\u4f7f\u4e4b\u6210\u7acb<\/span><br \/><span style=\"font-size: 14px;\">&nbsp; X X X<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp;&nbsp; * X<\/span><br \/><span style=\"font-size: 14px;\">&#8212;&#8212;&#8212;<\/span><br \/><span style=\"font-size: 14px;\">X X X X<\/span><br \/><span style=\"font-size: 14px;\">\u6bcf\u4e2a\u6570\u5b57\u81f3\u5c11\u51fa\u73b0\u4e00\u6b21\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u7b97\u5f0f\u9700\u8981\u516b\u4e2a\u6570\u5b57\uff0c\u800c\u73b0\u53ea\u6709\u4e03\u4e2a\uff0c\u6545\u5fc5\u7136\u6709\u4e00\u4e2a\u6570\u8981\u7528\u5230\u4e24\u6b21\u3002<\/span><br \/><span style=\"font-size: 14px;\">\u53ef\u4ee5\u7528\u66b4\u529b\u731c\u89e3\uff0c\u627e\u51fa2-8\u8fd9\u4e03\u4e2a\u6570\u5b57\u7684\u6240\u6709\u6392\u5217\u7ec4\u5408\uff0c\u7136\u540e\u5206\u522b\u53d62-8\u4e2d\u4e00\u4e2a\u6570\u5b57\uff0c\u63d2\u5165\u5230\u6240\u6709\u7684\u7ec4\u5408\u4e2d\u53bb\uff0c\u4f5c\u4e3a\u51fa\u73b0\u4e24\u6b21\u7684\u90a3\u4e2a\u6570\u5b57\u3002<\/span><br \/><span style=\"font-size: 14px;\">\u8fd9\u65f6\uff0c\u6240\u6709 ABC * D \uff1d EFGH \u7684\u7ec4\u5408\u90fd\u6709\u4e86\uff0c\u6211\u4eec\u9700\u8981\u505a\u7684\uff0c\u5c31\u662f\u9a8c\u8bc1\u7b49\u53f7\uff0c\u5982\u679c\u7b49\u53f7\u80fd\u6210\u7acb\uff0c\u5c31\u662f\u6211\u4eec\u9700\u8981\u7684\u89e3\u4e86\u3002<\/span><br \/><span style=\"font-size: 14px;\">\u4f8b\u5982\uff0c2-8\u7684\u5176\u4e2d\u4e00\u4e2a\u7ec4\u5408\u4e3a [3,2,4,5,6,7,8]\uff0c\u628a2\u63d2\u5165\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u53d8\u6210 [2,3,2,4,5,6,7,8] ,\u53d6\u51fa\u7b97\u5f0f\uff0c\u5c31\u662f 232 * 4 = 5678\uff0c\u4e0d\u662f\u4e00\u4e2a\u89e3\u3002<\/span><br \/><span style=\"font-size: 14px;\">\u518d\u628a2\u63d2\u5165\u7b2c\u4e8c\u3001\u4e09&#8230;\u4e2a\u4f4d\u7f6e\uff0c\u518d\u9a8c\u8bc1\u3002\u518d\u628a2\u6362\u6210\u5176\u5b83\u6570\u5b57\uff0c\u518d\u9a8c\u8bc1&#8230;&#8230;.<\/span><\/p>\n<p><span style=\"color: #ff0000; font-size: 14px;\">Python\u5b9e\u73b0\u7684\u4ee3\u7801\uff1a<\/span><\/p>\n<p><span style=\"font-size: 14px;\">import itertools<\/span><\/p>\n<p><span style=\"font-size: 14px;\">results = set()<\/span><br \/><span style=\"font-size: 14px;\">solutions = itertools.permutations(range(2,9))<\/span><br \/><span style=\"font-size: 14px;\">for solution in solutions:<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;sotmp = list(solution)<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;for i in range(2,9):<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for j in range(len(solution)):<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;so = sotmp[:]<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;so.insert(j, i)<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;A = int(&#8221;.join([str(s) for s in so[0:3]]))<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;B = so[3]<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;C = so[4]*1000 + so[5]*100 +so[6]*10 + so[7]<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if A * B == C:<\/span><br \/><span style=\"font-size: 14px;\">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;results.add(&#8216;%d * %d = %d&#8217; % (A,B,C))<\/span><br \/><span style=\"font-size: 14px;\">print &#8216;\\n&#8217;.join(results)<\/span><\/p>\n<p><span style=\"font-size: 14px;\"><span><img decoding=\"async\" small=\"0\" src=\".\/wp-content\/uploads\/hibaidu\/628944ec2e738bd46313fb91a18b87d6277ff91b.jpg\" \/><\/span><br \/><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 14px;\">\u7b97\u51fa\u6765\u7684\u7ed3\u679c\u4e3a\uff1a<\/span><\/p>\n<p><span style=\"font-size: 14px;\">547 * 6 = 3282<\/span><br \/><span style=\"font-size: 14px;\">552 * 7 = 3864<\/span><br \/><span style=\"font-size: 14px;\">637 * 4 = 2548<\/span><br \/><span style=\"font-size: 14px;\">748 * 7 = 5236<\/span><br \/><span style=\"font-size: 14px;\">524 * 7 = 3668<\/span><br \/><span style=\"font-size: 14px;\">364 * 7 = 2548<\/span><br \/><span style=\"font-size: 14px;\">546 * 7 = 3822<\/span><\/p>\n<\/div>\n<p><\/body><\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7528Python\u89e3\u5c0f\u5b66\u4e09\u5e74\u7ea7\u9898 \u7528Python\u89e3\u5c0f\u5b66\u4e09\u5e74\u7ea7\u9898 \u539f\u9898\u662f\u8fd9\u6837\u7684\uff1a \u67092,3,4,5,6,7,8\u4e03\u4e2a\u6570 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1844","post","type-post","status-publish","format-standard","hentry","category-diary"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1844","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=1844"}],"version-history":[{"count":0,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1844\/revisions"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=1844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=1844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=1844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}