正剧开始:
星历2016年02月06日 11:36:22, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起研究小数的除法。
但是在开始之前,[工程师阿伟]想起了上一节时[人叫板老师]给的国际象棋,突然有了要再仔细研究下的冲动。
这张图里的王和后,都只有一种状态,也就是他们站的格子都只有一种颜色,怎么办呢?
于是小伟进行了颜色变换:
虽然效果并不好,但王和后总算有了双份了。
好,现在把他们集中到一起吧,咱们来检阅一下这两只部队:
好诡异的场景,竟然国有二王,他们在举行仪式吗?
来,两军对阵,全体冲锋!
阿伟感受到了墨家[兼爱非攻]的气息,这几天看了点《秦时明月》,竟然能一下子就想起墨家来了。
好,就先研究到这里。以上进行的操作有:
<span style="font-size:18px;">function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); //config.setSector(1,1,1,1); //config.axis2D(0, 0, 180); //棋盘 var r = 50; for (var i = 0; i < 8; i++) { //行 for (var j = 0; j < 8; j++) {//列 if ((i+j)%2==1) { plot.setFillStyle('#888888'); } else { plot.setFillStyle('white'); } shape.fillRect((j+0.5)*r, (i+0.5)*r, r, r); } } plot.setLineWidth(5) .strokeRect(0, 0, r*8, r*8); } function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); //config.setSector(1,1,1,1); //config.axis2D(0, 0, 180); var r = 50; //黑棋 王,后,相,马,车,兵 //图片 var image = new Image(); image.src = "./1.jpg"; image.onload = function() { plot.drawImage(image); var imagedata = plot.getImageData(0, 0, 400, 400); var size = imagedata.data.length; var tmp; for (var i = 0; i < size; i+=4) { tmp = imagedata.data[i]; if (tmp > 80 && tmp < 150) { //灰色 --> 白色 imagedata.data[i+2] = imagedata.data[i+1] = imagedata.data[i] = 255; } else if (tmp >= 150) { //白色 --> 灰色 imagedata.data[i+2] = imagedata.data[i+1] = imagedata.data[i] = 128; } } plot.translate(600, 0); plot.putImageData(imagedata, 0, 0); plot.drawImage(image); } } function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); //config.setSector(1,1,1,1); //config.axis2D(0, 0, 180); var r = 50; //图片 var image = new Image(); image.src = "./1.jpg"; image.onload = function() { for (var i = 0; i < 8; i++) { //行 for (var j = 0; j < 8; j++) {//列 if ((i+j)%2==1) { plot.setFillStyle('#888888'); } else { plot.setFillStyle('white'); } shape.fillRect((j+0.5)*r, (i+0.5)*r, r, r); } } //黑棋前进两行 for (var i = 0; i < 2; i++) { for (var j = 0; j < 8; j++) { plot.drawImage(image, j*r, i*r, r, r, j*r, (i+2)*r, r, r); } } //白棋横移一列,前进两行 for (var i = 6; i < 8; i++) { for (var j = 0; j < 8; j++) { plot.drawImage(image, j*r, i*r, r, r, (8-j)%8*r, (i-2)*r, r, r); } } plot.setLineWidth(5) .strokeRect(0, 0, r*8, r*8); } }</span>
来看看小数除法竖式怎么摆的:
<span style="font-size:18px;">/** * @usage 小数除法 * @author mw * @date 2016年02月06日 星期六 10:28:47 * @param * @return * */ this.floatDiv = function(dividend, divisor, xOffset, yOffset, r) { plot.save(); /* 被除数 dividend 除数 divisor 商数 quotient 余数 remainder */ var a = [divisor, dividend, dividend/divisor]; var s = (Math.abs(dividend)).toString(); var index1 = s.indexOf('.'); var numScale = 0; var scale1 = 0; if (index1 !=-1) { scale1 = s.length-index1-1; numScale = scale1; } s = (Math.abs(divisor)).toString(); var index2 = s.indexOf('.'); var scale2 = 0; if (index2 !=-1) { scale2 = s.length-index2-1; //按照最大小数位数乘比例 if (numScale < scale2) numScale = scale2; } if (numScale > 0) { dividend *= Math.pow(10, numScale); dividend = Math.floor(dividend); divisor *= Math.pow(10, numScale); divisor = Math.floor(divisor); } var lenOfDividend =dividend.toFixed(0).length; var lenOfDivisor = divisor.toFixed(0).length; var quotient = Math.floor(dividend/divisor); var lenOfQuotient = quotient.toFixed(0).length; var remainder = dividend - quotient * divisor; a.push(remainder); //除数位置 var x0 = xOffset+r+lenOfDivisor * r, y0= yOffset + 2 * r; //被除数位置 var x1 = x0 + lenOfDividend * r, y1 = y0; //商位置 var x2 = x1, y2 = yOffset; plot.beginPath() .bezierCurveTo(x0-r, y0+r, x0-0.5*r, y0+0.5*r, x0-0.2*r, y0-0.5*r, x0, y0-r) /* .moveTo(x0-r, y0+r) .lineTo(x0, y0-1*r)*/ .closePath() .stroke(); plot.beginPath() .moveTo(x0, y0-1*r) .lineTo(x2+r, y0-1*r) .closePath() .stroke(); x0-=r; this.rightAlign(a[0], x0, y0, r); var indent = scale1 >= scale2 ? scale1 : scale2; this.rightAlign(a[1].toFixed(numScale), x1, y1, r); if (scale1 >= scale2) { this.rightAlign(a[2].toFixed(scale1-scale2), x2, y2, r); } else { this.rightAlign(a[2].toFixed(0), x2, y2, r); } var tmp1, tmp2, tmp3, x, y; //x, y的初始位置 x = x1 - (lenOfQuotient-1) *r, y = y1 + 1.5 * r; if (lenOfQuotient > 1) { for (var i = 0; i < lenOfQuotient; i++) { if (i == 0) { //待减 tmp1 = (quotient.toFixed(0)[i] - '0')*divisor; //被减 tmp2 = Math.floor(dividend / Math.pow(10, lenOfQuotient-i-2)); //减得的差进入下一轮 tmp3 = tmp2 - tmp1 * 10; this.rightAlign(tmp1, x, y, r); y += r; plot.beginPath() .moveTo(x0, y) .lineTo(x1 +r, y) .closePath() .stroke(); y += r; if (tmp3 != 0 && quotient.toFixed(0)[i+1] - '0' > 0) { this.rightAlign(tmp3,x+r, y, r); y += 1.5 * r; } //位置递增 x += r; } else if (i < lenOfQuotient-1 ) { //中间轮数 tmp1 = (quotient.toFixed(0)[i] - '0')*divisor; tmp3 = tmp3*10 + (dividend.toFixed(0)[i+lenOfDividend-lenOfQuotient+1]-'0')-tmp1*10; if (tmp1 != 0) { this.rightAlign(tmp1, x, y, r); y += r; plot.beginPath() .moveTo(x0, y) .lineTo(x1 +r, y) .closePath() .stroke(); y += 1.5 * r; } if (tmp3 != 0 && quotient.toFixed(0)[i+1] - '0' > 0) { this.rightAlign(tmp3,x+r, y, r); y += 1.5 * r; } x += r; } else { //最后一轮 tmp1 = (quotient.toFixed(0)[i] - '0')*divisor; if (tmp1 != 0) { this.rightAlign(tmp1, x, y, r); y += r; plot.beginPath() .moveTo(x0, y) .lineTo(x1 +r, y) .closePath() .stroke(); y += r; } else { y -= 0.5 * r; } this.rightAlign(a[3],x, y, r); } } } else { //最后一轮 tmp1 = quotient*divisor; this.rightAlign(tmp1, x, y, r); plot.moveTo(x0, y+r) .lineTo(x1 +r, y+r) .stroke(); plot.beginPath() .moveTo(x0, y+r) .lineTo(x1 +r, y+r) .closePath() .stroke(); this.rightAlign(a[3],x, y+2*r, r); } } }</span>
<span style="font-size:18px;">function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); //config.setSector(1,1,1,1); //config.axis2D(0, 0, 180); var vertExp = new VerticalExpression(); var x = 20, y = 50, r = 20; vertExp.floatDiv(22.4, 4 , x, y, r); x += 200; vertExp.floatDiv(5.6, 7 , x, y, r); x += 200; vertExp.floatDiv(7.65, 0.85 , x, y, r); x = 20, y+=150; vertExp.floatDiv(12.6, 0.28 , x, y, r); x += 200; vertExp.floatDiv(19.4, 1.2 , x, y, r); x += 200; vertExp.floatDiv(400, 75 , x, y, r); }</span>
<span style="font-size:18px;">>>> 0.0 0.0909 0.1818 0.2727 0.3636 0.4545 0.5455 0.6364 0.7273 0.8182 def tmp(): for i in range(10): print(round(i/11, 4)); return;</span>
<span style="font-size:18px;">>>> 3 * 0.7 = 2.1 3.3 * 6.7 = 22.11 3.33 * 66.7 = 222.111 3.333 * 666.7 = 2222.1111 3.3333 * 6666.7 = 22222.11111 3.33333 * 66666.7 = 222222.111111 3.333333 * 666666.7 = 2222222.111111 3.3333333 * 6666666.7 = 22222222.111111 3.33333333 * 66666666.7 = 222222222.111111 3.333333333 * 666666666.7 = 2222222222.111111 def tmp(): for i in range(10): rate = 0.1; rate2 = 1; total1 = 3; total2 = 0.7; result = 0; for j in range(i): total1+=3*rate; rate /= 10; total2 += 6*rate2; rate2 *= 10; result = round(total1 * total2, 6); print('{0} * {1} = {2}'.format(round(total1,i), round(total2, i+1), result)); return;</span>
<span style="font-size:18px;">>>> 0.0 11111.1111 22222.2222 33333.3333 44444.4444 55555.5555 66666.6666 77777.7777 88888.8888 99999.9999 def tmp(): for i in range(10): print(round(1234.5679*i*9,4)); return;</span>
好吧,来试一试:
<span style="font-size:18px;">>>> [0, 1, 2, 3] --> [0, 3, 7, 8], 数字是:3087, [0, 1, 2, 4] --> [0, 4, 6, 8], 数字是:4086, [0, 1, 2, 5] --> [0, 5, 5, 8], 数字是:5085, [0, 1, 2, 6] --> [0, 4, 6, 8], 数字是:6084, [0, 1, 2, 7] --> [0, 3, 7, 8], 数字是:7083, [0, 1, 2, 8] --> [0, 2, 8, 8], 数字是:8082, [0, 1, 2, 9] --> [0, 1, 8, 9], 数字是:9081, [0, 1, 3, 4] --> [1, 4, 6, 7], 数字是:4176, [0, 1, 3, 5] --> [1, 5, 5, 7], 数字是:5175, [0, 1, 3, 6] --> [1, 4, 6, 7], 数字是:6174, ======= [0, 1, 3, 7] --> [1, 3, 7, 7], 数字是:7173, [0, 1, 3, 8] --> [1, 2, 7, 8], 数字是:8172, [0, 1, 3, 9] --> [1, 1, 7, 9], 数字是:9171, [0, 1, 4, 5] --> [2, 5, 5, 6], 数字是:5265, [0, 1, 4, 6] --> [2, 4, 6, 6], 数字是:6264, [0, 1, 4, 7] --> [2, 3, 6, 7], 数字是:7263, [0, 1, 4, 8] --> [2, 2, 6, 8], 数字是:8262, [0, 1, 4, 9] --> [1, 2, 6, 9], 数字是:9261, [0, 1, 5, 6] --> [3, 4, 5, 6], 数字是:6354, [0, 1, 5, 7] --> [3, 3, 5, 7], 数字是:7353, [0, 1, 5, 8] --> [2, 3, 5, 8], 数字是:8352, [0, 1, 5, 9] --> [1, 3, 5, 9], 数字是:9351, [0, 1, 6, 7] --> [3, 4, 4, 7], 数字是:7443, [0, 1, 6, 8] --> [2, 4, 4, 8], 数字是:8442, [0, 1, 6, 9] --> [1, 4, 4, 9], 数字是:9441, [0, 1, 7, 8] --> [2, 3, 5, 8], 数字是:8532, [0, 1, 7, 9] --> [1, 3, 5, 9], 数字是:9531, [0, 1, 8, 9] --> [1, 2, 6, 9], 数字是:9621, [0, 2, 3, 4] --> [0, 4, 6, 8], 数字是:4086, [0, 2, 3, 5] --> [0, 5, 5, 8], 数字是:5085, [0, 2, 3, 6] --> [0, 4, 6, 8], 数字是:6084, [0, 2, 3, 7] --> [0, 3, 7, 8], 数字是:7083, [0, 2, 3, 8] --> [0, 2, 8, 8], 数字是:8082, [0, 2, 3, 9] --> [0, 1, 8, 9], 数字是:9081, [0, 2, 4, 5] --> [1, 5, 5, 7], 数字是:5175, [0, 2, 4, 6] --> [1, 4, 6, 7], 数字是:6174, ======= [0, 2, 4, 7] --> [1, 3, 7, 7], 数字是:7173, [0, 2, 4, 8] --> [1, 2, 7, 8], 数字是:8172, [0, 2, 4, 9] --> [1, 1, 7, 9], 数字是:9171, [0, 2, 5, 6] --> [2, 4, 6, 6], 数字是:6264, [0, 2, 5, 7] --> [2, 3, 6, 7], 数字是:7263, [0, 2, 5, 8] --> [2, 2, 6, 8], 数字是:8262, [0, 2, 5, 9] --> [1, 2, 6, 9], 数字是:9261, [0, 2, 6, 7] --> [3, 3, 5, 7], 数字是:7353, [0, 2, 6, 8] --> [2, 3, 5, 8], 数字是:8352, [0, 2, 6, 9] --> [1, 3, 5, 9], 数字是:9351, [0, 2, 7, 8] --> [2, 4, 4, 8], 数字是:8442, [0, 2, 7, 9] --> [1, 4, 4, 9], 数字是:9441, [0, 2, 8, 9] --> [1, 3, 5, 9], 数字是:9531, [0, 3, 4, 5] --> [0, 5, 5, 8], 数字是:5085, [0, 3, 4, 6] --> [0, 4, 6, 8], 数字是:6084, [0, 3, 4, 7] --> [0, 3, 7, 8], 数字是:7083, [0, 3, 4, 8] --> [0, 2, 8, 8], 数字是:8082, [0, 3, 4, 9] --> [0, 1, 8, 9], 数字是:9081, [0, 3, 5, 6] --> [1, 4, 6, 7], 数字是:6174, ======= [0, 3, 5, 7] --> [1, 3, 7, 7], 数字是:7173, [0, 3, 5, 8] --> [1, 2, 7, 8], 数字是:8172, [0, 3, 5, 9] --> [1, 1, 7, 9], 数字是:9171, [0, 3, 6, 7] --> [2, 3, 6, 7], 数字是:7263, [0, 3, 6, 8] --> [2, 2, 6, 8], 数字是:8262, [0, 3, 6, 9] --> [1, 2, 6, 9], 数字是:9261, [0, 3, 7, 8] --> [2, 3, 5, 8], 数字是:8352, [0, 3, 7, 9] --> [1, 3, 5, 9], 数字是:9351, [0, 3, 8, 9] --> [1, 4, 4, 9], 数字是:9441, [0, 4, 5, 6] --> [0, 4, 6, 8], 数字是:6084, [0, 4, 5, 7] --> [0, 3, 7, 8], 数字是:7083, [0, 4, 5, 8] --> [0, 2, 8, 8], 数字是:8082, [0, 4, 5, 9] --> [0, 1, 8, 9], 数字是:9081, [0, 4, 6, 7] --> [1, 3, 7, 7], 数字是:7173, [0, 4, 6, 8] --> [1, 2, 7, 8], 数字是:8172, [0, 4, 6, 9] --> [1, 1, 7, 9], 数字是:9171, [0, 4, 7, 8] --> [2, 2, 6, 8], 数字是:8262, [0, 4, 7, 9] --> [1, 2, 6, 9], 数字是:9261, [0, 4, 8, 9] --> [1, 3, 5, 9], 数字是:9351, [0, 5, 6, 7] --> [0, 3, 7, 8], 数字是:7083, [0, 5, 6, 8] --> [0, 2, 8, 8], 数字是:8082, [0, 5, 6, 9] --> [0, 1, 8, 9], 数字是:9081, [0, 5, 7, 8] --> [1, 2, 7, 8], 数字是:8172, [0, 5, 7, 9] --> [1, 1, 7, 9], 数字是:9171, [0, 5, 8, 9] --> [1, 2, 6, 9], 数字是:9261, [0, 6, 7, 8] --> [0, 2, 8, 8], 数字是:8082, [0, 6, 7, 9] --> [0, 1, 8, 9], 数字是:9081, [0, 6, 8, 9] --> [1, 1, 7, 9], 数字是:9171, [0, 7, 8, 9] --> [0, 1, 8, 9], 数字是:9081, [1, 2, 3, 4] --> [0, 3, 7, 8], 数字是:3087, [1, 2, 3, 5] --> [0, 4, 6, 8], 数字是:4086, [1, 2, 3, 6] --> [0, 5, 5, 8], 数字是:5085, [1, 2, 3, 7] --> [0, 4, 6, 8], 数字是:6084, [1, 2, 3, 8] --> [0, 3, 7, 8], 数字是:7083, [1, 2, 3, 9] --> [0, 2, 8, 8], 数字是:8082, [1, 2, 4, 5] --> [1, 4, 6, 7], 数字是:4176, [1, 2, 4, 6] --> [1, 5, 5, 7], 数字是:5175, [1, 2, 4, 7] --> [1, 4, 6, 7], 数字是:6174, ======= [1, 2, 4, 8] --> [1, 3, 7, 7], 数字是:7173, [1, 2, 4, 9] --> [1, 2, 7, 8], 数字是:8172, [1, 2, 5, 6] --> [2, 5, 5, 6], 数字是:5265, [1, 2, 5, 7] --> [2, 4, 6, 6], 数字是:6264, [1, 2, 5, 8] --> [2, 3, 6, 7], 数字是:7263, [1, 2, 5, 9] --> [2, 2, 6, 8], 数字是:8262, [1, 2, 6, 7] --> [3, 4, 5, 6], 数字是:6354, [1, 2, 6, 8] --> [3, 3, 5, 7], 数字是:7353, [1, 2, 6, 9] --> [2, 3, 5, 8], 数字是:8352, [1, 2, 7, 8] --> [3, 4, 4, 7], 数字是:7443, [1, 2, 7, 9] --> [2, 4, 4, 8], 数字是:8442, [1, 2, 8, 9] --> [2, 3, 5, 8], 数字是:8532, [1, 3, 4, 5] --> [0, 4, 6, 8], 数字是:4086, [1, 3, 4, 6] --> [0, 5, 5, 8], 数字是:5085, [1, 3, 4, 7] --> [0, 4, 6, 8], 数字是:6084, [1, 3, 4, 8] --> [0, 3, 7, 8], 数字是:7083, [1, 3, 4, 9] --> [0, 2, 8, 8], 数字是:8082, [1, 3, 5, 6] --> [1, 5, 5, 7], 数字是:5175, [1, 3, 5, 7] --> [1, 4, 6, 7], 数字是:6174, ======= [1, 3, 5, 8] --> [1, 3, 7, 7], 数字是:7173, [1, 3, 5, 9] --> [1, 2, 7, 8], 数字是:8172, [1, 3, 6, 7] --> [2, 4, 6, 6], 数字是:6264, [1, 3, 6, 8] --> [2, 3, 6, 7], 数字是:7263, [1, 3, 6, 9] --> [2, 2, 6, 8], 数字是:8262, [1, 3, 7, 8] --> [3, 3, 5, 7], 数字是:7353, [1, 3, 7, 9] --> [2, 3, 5, 8], 数字是:8352, [1, 3, 8, 9] --> [2, 4, 4, 8], 数字是:8442, [1, 4, 5, 6] --> [0, 5, 5, 8], 数字是:5085, [1, 4, 5, 7] --> [0, 4, 6, 8], 数字是:6084, [1, 4, 5, 8] --> [0, 3, 7, 8], 数字是:7083, [1, 4, 5, 9] --> [0, 2, 8, 8], 数字是:8082, [1, 4, 6, 7] --> [1, 4, 6, 7], 数字是:6174, ======= [1, 4, 6, 8] --> [1, 3, 7, 7], 数字是:7173, [1, 4, 6, 9] --> [1, 2, 7, 8], 数字是:8172, [1, 4, 7, 8] --> [2, 3, 6, 7], 数字是:7263, [1, 4, 7, 9] --> [2, 2, 6, 8], 数字是:8262, [1, 4, 8, 9] --> [2, 3, 5, 8], 数字是:8352, [1, 5, 6, 7] --> [0, 4, 6, 8], 数字是:6084, [1, 5, 6, 8] --> [0, 3, 7, 8], 数字是:7083, [1, 5, 6, 9] --> [0, 2, 8, 8], 数字是:8082, [1, 5, 7, 8] --> [1, 3, 7, 7], 数字是:7173, [1, 5, 7, 9] --> [1, 2, 7, 8], 数字是:8172, [1, 5, 8, 9] --> [2, 2, 6, 8], 数字是:8262, [1, 6, 7, 8] --> [0, 3, 7, 8], 数字是:7083, [1, 6, 7, 9] --> [0, 2, 8, 8], 数字是:8082, [1, 6, 8, 9] --> [1, 2, 7, 8], 数字是:8172, [1, 7, 8, 9] --> [0, 2, 8, 8], 数字是:8082, [2, 3, 4, 5] --> [0, 3, 7, 8], 数字是:3087, [2, 3, 4, 6] --> [0, 4, 6, 8], 数字是:4086, [2, 3, 4, 7] --> [0, 5, 5, 8], 数字是:5085, [2, 3, 4, 8] --> [0, 4, 6, 8], 数字是:6084, [2, 3, 4, 9] --> [0, 3, 7, 8], 数字是:7083, [2, 3, 5, 6] --> [1, 4, 6, 7], 数字是:4176, [2, 3, 5, 7] --> [1, 5, 5, 7], 数字是:5175, [2, 3, 5, 8] --> [1, 4, 6, 7], 数字是:6174, ======= [2, 3, 5, 9] --> [1, 3, 7, 7], 数字是:7173, [2, 3, 6, 7] --> [2, 5, 5, 6], 数字是:5265, [2, 3, 6, 8] --> [2, 4, 6, 6], 数字是:6264, [2, 3, 6, 9] --> [2, 3, 6, 7], 数字是:7263, [2, 3, 7, 8] --> [3, 4, 5, 6], 数字是:6354, [2, 3, 7, 9] --> [3, 3, 5, 7], 数字是:7353, [2, 3, 8, 9] --> [3, 4, 4, 7], 数字是:7443, [2, 4, 5, 6] --> [0, 4, 6, 8], 数字是:4086, [2, 4, 5, 7] --> [0, 5, 5, 8], 数字是:5085, [2, 4, 5, 8] --> [0, 4, 6, 8], 数字是:6084, [2, 4, 5, 9] --> [0, 3, 7, 8], 数字是:7083, [2, 4, 6, 7] --> [1, 5, 5, 7], 数字是:5175, [2, 4, 6, 8] --> [1, 4, 6, 7], 数字是:6174, ======= [2, 4, 6, 9] --> [1, 3, 7, 7], 数字是:7173, [2, 4, 7, 8] --> [2, 4, 6, 6], 数字是:6264, [2, 4, 7, 9] --> [2, 3, 6, 7], 数字是:7263, [2, 4, 8, 9] --> [3, 3, 5, 7], 数字是:7353, [2, 5, 6, 7] --> [0, 5, 5, 8], 数字是:5085, [2, 5, 6, 8] --> [0, 4, 6, 8], 数字是:6084, [2, 5, 6, 9] --> [0, 3, 7, 8], 数字是:7083, [2, 5, 7, 8] --> [1, 4, 6, 7], 数字是:6174, ======= [2, 5, 7, 9] --> [1, 3, 7, 7], 数字是:7173, [2, 5, 8, 9] --> [2, 3, 6, 7], 数字是:7263, [2, 6, 7, 8] --> [0, 4, 6, 8], 数字是:6084, [2, 6, 7, 9] --> [0, 3, 7, 8], 数字是:7083, [2, 6, 8, 9] --> [1, 3, 7, 7], 数字是:7173, [2, 7, 8, 9] --> [0, 3, 7, 8], 数字是:7083, [3, 4, 5, 6] --> [0, 3, 7, 8], 数字是:3087, [3, 4, 5, 7] --> [0, 4, 6, 8], 数字是:4086, [3, 4, 5, 8] --> [0, 5, 5, 8], 数字是:5085, [3, 4, 5, 9] --> [0, 4, 6, 8], 数字是:6084, [3, 4, 6, 7] --> [1, 4, 6, 7], 数字是:4176, [3, 4, 6, 8] --> [1, 5, 5, 7], 数字是:5175, [3, 4, 6, 9] --> [1, 4, 6, 7], 数字是:6174, ======= [3, 4, 7, 8] --> [2, 5, 5, 6], 数字是:5265, [3, 4, 7, 9] --> [2, 4, 6, 6], 数字是:6264, [3, 4, 8, 9] --> [3, 4, 5, 6], 数字是:6354, [3, 5, 6, 7] --> [0, 4, 6, 8], 数字是:4086, [3, 5, 6, 8] --> [0, 5, 5, 8], 数字是:5085, [3, 5, 6, 9] --> [0, 4, 6, 8], 数字是:6084, [3, 5, 7, 8] --> [1, 5, 5, 7], 数字是:5175, [3, 5, 7, 9] --> [1, 4, 6, 7], 数字是:6174, ======= [3, 5, 8, 9] --> [2, 4, 6, 6], 数字是:6264, [3, 6, 7, 8] --> [0, 5, 5, 8], 数字是:5085, [3, 6, 7, 9] --> [0, 4, 6, 8], 数字是:6084, [3, 6, 8, 9] --> [1, 4, 6, 7], 数字是:6174, ======= [3, 7, 8, 9] --> [0, 4, 6, 8], 数字是:6084, [4, 5, 6, 7] --> [0, 3, 7, 8], 数字是:3087, [4, 5, 6, 8] --> [0, 4, 6, 8], 数字是:4086, [4, 5, 6, 9] --> [0, 5, 5, 8], 数字是:5085, [4, 5, 7, 8] --> [1, 4, 6, 7], 数字是:4176, [4, 5, 7, 9] --> [1, 5, 5, 7], 数字是:5175, [4, 5, 8, 9] --> [2, 5, 5, 6], 数字是:5265, [4, 6, 7, 8] --> [0, 4, 6, 8], 数字是:4086, [4, 6, 7, 9] --> [0, 5, 5, 8], 数字是:5085, [4, 6, 8, 9] --> [1, 5, 5, 7], 数字是:5175, [4, 7, 8, 9] --> [0, 5, 5, 8], 数字是:5085, [5, 6, 7, 8] --> [0, 3, 7, 8], 数字是:3087, [5, 6, 7, 9] --> [0, 4, 6, 8], 数字是:4086, [5, 6, 8, 9] --> [1, 4, 6, 7], 数字是:4176, [5, 7, 8, 9] --> [0, 4, 6, 8], 数字是:4086, [6, 7, 8, 9] --> [0, 3, 7, 8], 数字是:3087, #求组合数的选择集 def choice2(ceil, chance): a = []; result = []; end = 0; bit = 0; #次数 #chance = 2; #最终封顶数 #ceil = 6; chance -= 1; for i in range(ceil+1): a.append([i]); while (bit <= chance): bit = len(a[0]); if (bit <= chance): if (len(a)>0): b = a.pop(0); end = b[-1]; if (end + chance - bit < ceil+1): for i in range(end+1, ceil+1): a.append(b+[i]); else: break; return a; def tmp(): result = choice2(9, 4); size = len(result); for i in range(size): num = (result[i][3]-result[i][0])*999 + (result[i][2]-result[i][1])*90; a = [num//1000, num%1000//100,num%100//10,num%10]; list1 = list(a); list1.sort(); s = ''; if (num == 6174): s = '======='; print('{0} --> {1}, 数字是:{2}, {3}'.format(result[i], list1, num, s)); return;</span>