[null, {"document_url": "http://reportingdesign.blogspot.com/2014/09/program-24-point-calculation-with-esproc.html", "unformatted_src": "http://4.bp.blogspot.com/-LjALg9V40Yk/VBpMAuJIR4I/AAAAAAAAB4E/6bIfgKRI4pU/s1600/2014-09-18_110416.jpg", "src": "http://4.bp.blogspot.com/-LjALg9V40Yk/VBpMAuJIR4I/AAAAAAAAB4E/6bIfgKRI4pU/s1600/2014-09-18_110416.jpg"}, null, {"document_url": "http://reportingdesign.blogspot.com/2014/09/program-24-point-calculation-with-esproc.html", "unformatted_src": "http://2.bp.blogspot.com/-2uPGgJTW8Fc/VBpMAIN-FsI/AAAAAAAAB4A/yA-VvLzj_WE/s1600/2014-09-18_110427.jpg", "src": "http://2.bp.blogspot.com/-2uPGgJTW8Fc/VBpMAIN-FsI/AAAAAAAAB4A/yA-VvLzj_WE/s1600/2014-09-18_110427.jpg"}, null, {"document_url": "http://reportingdesign.blogspot.com/2014/09/program-24-point-calculation-with-esproc.html", "unformatted_src": "http://4.bp.blogspot.com/-EoIIZBkMP6Y/VBpMAR-HEhI/AAAAAAAAB48/av0eYnCiQbY/s1600/2014-09-18_110435.jpg", "src": "http://4.bp.blogspot.com/-EoIIZBkMP6Y/VBpMAR-HEhI/AAAAAAAAB48/av0eYnCiQbY/s1600/2014-09-18_110435.jpg"}, null, {"document_url": "http://reportingdesign.blogspot.com/2014/09/program-24-point-calculation-with-esproc.html", "unformatted_src": "http://1.bp.blogspot.com/-W-8tuatmRYk/VBpMBHS5JmI/AAAAAAAAB4M/ghT_Fg34fKg/s1600/2014-09-18_110444.jpg", "src": "http://1.bp.blogspot.com/-W-8tuatmRYk/VBpMBHS5JmI/AAAAAAAAB4M/ghT_Fg34fKg/s1600/2014-09-18_110444.jpg"}, null, {"document_url": "http://reportingdesign.blogspot.com/2014/09/program-24-point-calculation-with-esproc.html", "unformatted_src": "http://1.bp.blogspot.com/-0ImAY04aQwE/VBpMBg0LwmI/AAAAAAAAB4Q/-xzkLkK60Ow/s1600/2014-09-18_110452.jpg", "src": "http://1.bp.blogspot.com/-0ImAY04aQwE/VBpMBg0LwmI/AAAAAAAAB4Q/-xzkLkK60Ow/s1600/2014-09-18_110452.jpg"}, null, {"document_url": "http://reportingdesign.blogspot.com/2014/09/program-24-point-calculation-with-esproc.html", "unformatted_src": "http://2.bp.blogspot.com/-7DSttvLzkbM/VBpMCDRenII/AAAAAAAAB4Y/0b0X8JsLAcA/s1600/2014-09-18_110500.jpg", "src": "http://2.bp.blogspot.com/-7DSttvLzkbM/VBpMCDRenII/AAAAAAAAB4Y/0b0X8JsLAcA/s1600/2014-09-18_110500.jpg"}, null, {"document_url": "http://reportingdesign.blogspot.com/2014/09/program-24-point-calculation-with-esproc.html", "unformatted_src": "http://3.bp.blogspot.com/-6e7o1-xbgQE/VBpMCZShwgI/AAAAAAAAB4c/kBn6P9Hjtb4/s1600/2014-09-18_110508.jpg", "src": "http://3.bp.blogspot.com/-6e7o1-xbgQE/VBpMCZShwgI/AAAAAAAAB4c/kBn6P9Hjtb4/s1600/2014-09-18_110508.jpg", "rendered_width": 320, "rendered_height": 31}, null, {"document_url": "http://reportingdesign.blogspot.com/2014/09/program-24-point-calculation-with-esproc.html", "unformatted_src": "http://1.bp.blogspot.com/-dwb5PKmDLbg/VBpMDWZdzbI/AAAAAAAAB4w/102QX6hyryw/s1600/2014-09-18_110516.jpg", "src": "http://1.bp.blogspot.com/-dwb5PKmDLbg/VBpMDWZdzbI/AAAAAAAAB4w/102QX6hyryw/s1600/2014-09-18_110516.jpg", "rendered_width": 320, "rendered_height": 240}, null, null, null, null]
Program 24-Point Calculation with esProc

24-point calculation is a common intellectual game, which can be played with poker without jokers. Draw four cards randomly, use the four numbers to work out 24 points with four arithmetic operations: addition, subtraction, multiplication and division. In playing poker, JQK usually correspond numbers 11, 12 and 13.

With esProc, we could program the game more conveniently. Working out a solution with four random numbers becomes easier: Let's analyzes the piece of code in detail.

Four numbers for computation are given in A1. First, we try all possible permutations of the four random cards. To do this, we list the repeatable cases in A2 with the help of a four-digit base-4 number. In B2, we only select those cases which are not repeated. See figure below: Any three symbols of four arithmetic operations need to be inserted in
computation. Each symbol is selected arbitrarily among plus, minus, times and division. Execute in A3 the loop of a three-digit base-4 number, and list all possible combinations: Different computation orders have different computed results. The computing order can be changed by adding brackets. Three operational symbols show that the computation can be divided into three steps, and brackets adding decides the execution order of the three steps. Combinations in B3, selected from the results in A3,contain all three elements 1,2,3, and represent all possible execution orders. See figure below: Since there could be repeated numbers among the four randomly selected cards, all permutations of cards will be listed in A4 and remove those repeated ones in B4 in order to avoid redundant loop. Let's look at [8,3,8,3] in A1, its eligible combinations are as follow: For each permutation, the programming in line 5 and line 6 executes loop of every symbol selection and every computation order. Then computes by calling subprogram in A8 and with the copied parameters to avoid interfering the subsequent computation.

When the subprogram in A8 is called, numerical sequence, symbol sequence, and sequence of computation order should be filled respectively into A8, B8 and C8; at the same time, expression for computation should be prepared in D8. B9 executes the loop of sequence of computation order until the result is gradually obtained. C9 gets the result of a single step by calling subprogram in A13. The subprogram, which is quite simple, achieves computed results of four arithmetic operations based on two given numbers and one of the symbols. D9 aims at the expression used for single step computing, after which the original two numbers will become one, and expression sequence, symbol sequence and numerical sequence will be modified in E9, C10 and D10. Having done the single step computing, the original total computing steps will be reduced by one, so another modification of sequence of computation order will be required in E10. In line 11, unless it is the last step, brackets will be added to newly-created expression to ensure an appropriate computing order.

When the loop in B9 is over, subprogram in A8 completes its computation of expression for this case. B18 is programmed to decide whether the result is 24. The result will be calculated to three decimal places in consideration of computational error of double-precision number. If the result equals to 24, the current permutation is eligible. The corresponding expression will be put in B1 in C12.

If the loop of all conditions is finished, yet no expression is found in B1 when checking A7, no solution has been obtained.

After all the computation, result can be found in B1. See below: Or cellset parameter will take the place of combination of numerical value entered in A1: Set cellset parameter before doing computation: The result displayed in B1 after computation is as follow: 发帖者 Li David 时间： 下午8:08 标签： 24-point, calculation, esProc



subjects on reporting