|
KixGolf Results/Code
|
|
Is it time to post the code?
|
|
Re: KixGolf Results/Code
|
|
Man, you're quick. I was just grabbing the code Jack/Richard submitted to me. So, yes, folks, go ahead and post your code!
Here are the results from the first round:
Howard Bullock receives the First Scorer Award for his solution with a KiXtart Golf Score of 632.
A total of four score have been submitted with two people apparently dropping out.
414 = Richard Howarth 438 = Howard Bullock 541 = AJH 900 = Jack Lothian [ 21. September 2002, 21:47: Message edited by: sealeopard ]
|
|
Re: KixGolf Results/Code
|
|
Game24 KiXtart Golf running under KiXtart v4.11
Numbers = 1, 2, 3, 4 Please doublecheck your solution to guarantee a correct result (1.0+2.0+3.0)*4.0 = 24
Numbers = 2, 2, 6, 8 Please doublecheck your solution to guarantee a correct result (2.0+6.0)+(8.0*2.0) = 24
Numbers = 4, 4, 6, 6 Correct answer answer, there is no solution to this combination
Numbers = 3, 3, 8, 8 Please doublecheck your solution to guarantee a correct result 8.0/(3.0-8.0/3.0) = 24
Numbers = 0, 0, 8, 4 No solution found <> 24
Numbers = 3, 4, 7, 7 Please doublecheck your solution to guarantee a correct result (3.0+4.0*7.0)-7.0 = 24
Numbers = 1, 2, 8, 9 Please doublecheck your solution to guarantee a correct result (8.0*9.0)/(2.0+1.0) = 24
Time: 4546 ticks
KixGolf v3.0.3 score = 434, running under KiXtart v4.10 code:
function game24($a,$b,$c,$d)
Dim $h, $j, $l, $p, $q, $r, $s, $t, $v, $, $x, $y
$h = "+","-","/","*" for $y=1 to 4 for $x=1 to 4 for each $p in $h for each $q in $h for each $r in $h for each $j in split("0,8,10,18~0,12~4,16","~") $ = ".0" $s = ""+$a+$+$p+$b+$+$q+$c+$+$r+$d+$ for each $ in split($j,",") $l = chr(40 + ($l="(")) $s = "" + left($s,$) + $l + substr($s,1+$) next $t = execute("$$v=$s") if abs($v-24)< 1E-9 goto E endif next next next next $ = $b $b = $c $c = $d $d = $ next $ = $a $a = $b $b = $ next $s = ""
:E $game24 = $s endfunction
[ 22. September 2002, 01:06: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
This script is from Richard Howarth who asked me to post it for him. So, the credits go to Richard. please note that he implemented a recursive function with a KiXtart Golf Score of 404.
quote:
Game24 KiXtart Golf running under KiXtart v4.12 Beta 1 Computer = Pentium III 1000 and 511 RAM
Numbers = 1, 2, 3, 4 4.0*(3.0*(2.0/1)) = 24 The formula validated correctly
Numbers = 2, 2, 6, 8 8.0+(2.0*(6.0+2)) = 24 The formula validated correctly
Numbers = 4, 4, 6, 6 Correct answer answer, there is no solution to this combination
Numbers = 3, 3, 8, 8 8.0/(3.0-(8.0/3)) = 24 The formula validated correctly
Numbers = 0, 8, 2, 7 No solution found
Numbers = 3, 4, 7, 7 7.0-(4.0-(7.0*3)) = 24 The formula validated correctly
Numbers = 1, 2, 8, 9 9.0*(8.0/(2.0+1)) = 24 The formula validated correctly
Time = 2594 ticks
And the function is:
code:
;! Function game24($,$b,$c,$d) $game24=f(""+$+$b+$c+$d,"") EndFunction Function f($,$b) Dim $e,$x,$y,$z,$a If($) For $x=1 to Len($) $e=f(Left($,$x-1)+SubStr($,$x+1),$b+SubStr($,$x,1)) If $e $f=$e EndIf Next Else $e=Split("+ - * /") For Each $x In $e For Each $y In $e For Each $z In $e $=Left($b,1)+".0"+$x+"("+SubStr($b,2,1)+".0"+$y+"("+SubStr($b,3,1)+".0"+$z+Right($b,1)+"))" $z=Execute("$$a="+$) If "24"=$a $f=$ EndIf Next Next Next EndIf EndFunction
|
|
Re: KixGolf Results/Code
|
|
If Richard's double set of "()"'s holds up, then I re-submit my code:
Game24 KiXtart Golf running under KiXtart v4.11
Numbers = 1, 2, 3, 4 Please doublecheck your solution to guarantee a correct result 1.0*(2.0*(3.0*4.0)) = 24
Numbers = 2, 2, 6, 8 Please doublecheck your solution to guarantee a correct result 2.0+(6.0+(8.0*2.0)) = 24
Numbers = 4, 4, 6, 6 Correct answer answer, there is no solution to this combination
Numbers = 3, 3, 8, 8 Please doublecheck your solution to guarantee a correct result 8.0/(3.0-(8.0/3.0)) = 24
Numbers = 0, 4, 6, 8 Please doublecheck your solution to guarantee a correct result 0.0+(6.0*(8.0-4.0)) = 24
Numbers = 3, 4, 7, 7 Please doublecheck your solution to guarantee a correct result 3.0+(7.0*(7.0-4.0)) = 24
Numbers = 1, 2, 8, 9 Please doublecheck your solution to guarantee a correct result 8.0*(9.0/(2.0+1.0)) = 24
Time: 421 ticks
{edit} Thanks Erik, Removed "exit" reduced score by four. KixGolf v3.0.3 score = 314, running under KiXtart v4.10
code:
function game24($a,$b,$c,$d)
Dim $h, $p, $q, $r, $s, $t, $v, $, $x, $y
$h = "+","-","/","*" for $y=1 to 4 for $x=1 to 4 for each $p in $h for each $q in $h for each $r in $h $ = ".0" $s = ""+$a+$+$p+"("+$b+$+$q+"("+$c+$+$r+$d+$+"))" $t = execute("$$v=$s") if abs($v-24)< 1E-9 goto E endif next next next $ = $b $b = $c $c = $d $d = $ next $ = $a $a = $b $b = $ next $s = ""
:E $game24 = $s endfunction
[ 21. September 2002, 23:28: Message edited by: Howard Bullock ]
|
kholm
|
(Korg Regular)
|
2002-09-21 11:22 PM
|
|
|
|
|
Re: KixGolf Results/Code
|
|
Howard,
You can shawe of 4 by omitting the last Exit
As usual, a golfmatch uncovers new possibilitys, i would never have dreamt of using a line like this: if abs($v-24)< 1E-9
Cheers -Erik
|
|
Re: KixGolf Results/Code
|
|
I kinda liked my parentheses toggle from my first:
$l = chr(40 + ($l="("))
|
|
Re: KixGolf Results/Code
|
|
For what it's worth Golf Score 541
code:
FUNCTION Game24($n,$e,$r,$) IF Ubound($n) < 0 $n = $n,$e,$r,$ $e='' $r='' ENDIF IF Len($e) < 4 FOR EACH $ in Split('0 1 2 3') IF NOT Instr($e,$) $ = Game24($n,$e+$,$r+' '+$n[$]+'. ',0) IF $ $Game24 =$ RETURN ENDIF ENDIF NEXT ELSE DIM $a,$s,$e,$z,$y $ = Split($r) $s = Split('+ - * /') FOR EACH $[3] IN $s FOR EACH $[7] IN $s FOR EACH $[11] IN $s FOR EACH $a IN Split('/0 6/0 10/0 6 8 14/4 14','/') $a = Split($a) $e = $ FOR $z = 1 TO Ubound($a) STEP 2 $y=$a[$z-1] $e[$y] ='(' ; kixtart bug (?) '$e[$a[$z]] = ")"' is taken $y=$a[$z] $e[$y] =')' ; as a comparison not as an assignment. NEXT $e = Join($e,'') $z = Execute('$$y=ABS(24.-('+$e+'))<0.01') IF $y $Game24 =$e RETURN ENDIF NEXT NEXT NEXT NEXT ENDIF $Game24='' ENDFUNCTION
{edit} add in another set of parentheses (0 6) and remove 4 spaces Golf score unchanged! {/edit} [ 24. September 2002, 19:12: Message edited by: AJH ]
|
|
Re: KixGolf Results/Code
|
|
AJH, it's worth a great deal. Your post shows the effort you put forth to solve the problem. You found an issue with nested arrays. Other people may not have been aware this issue existed. Your score is secondary. You are one a few that took the time and completed the task. Good work.
{edit} AJH, You can reduce your score score by four by compacting your execute string: '$$y=ABS(24.-('+$e+'))<0.01'. Remember spaces within quotes are counted for the next KixGolf outing. [ 22. September 2002, 15:43: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
I am a bit late since my home machine still isn't up to snuff. I actually lowered my score to 653. I might have tried to go lower but I couldn't seem to generate any method that worked consistently. I especially had trouble with Jooel's suggestion of testing the script with a large number of random selection. This code passes Jens test & seems to works properly for a large number of random selections but if I change the order of the permutations (i.e. use '+ - / *' instead of '+ - * /') it still fails.
code:
Function Game24($i,$j,$k,$l) dim $a, $b, $c, $d, $e, $f, $g, $h, $m, $s, $t, $u, $v, $n[3], $[14], $o[3] $n=$i,$j,$k,$l $o = split('+ - * /') $s='cdbl(' $u=')' for $a=0 to 3 for $b=0 to 3 for $c=0 to 3 for $d=0 to 3 if $a<>$b&$a<>$c&$a<>$d&$b<>$c&$b<>$d&$c<>$d $[1]=$s+$n[$a]+$u $[5]=$s+$n[$b]+$u $[9]=$s+$n[$c]+$u $[13]=$s+$n[$d]+$u for each $e in $o for each $f in $o for each $g in $o $[3]= $e $[7]= $f $[11]= $g for $h=0 to 6 for $m=0 to 7 $[2*$m]='' next if $h=1 or $h=3 or $h=6 $[0]='(' endif if $h=2 or $h=4 $[4]='(' endif if $h=3 or $h=6 $[6]=')' endif if $h=5 or $h=6 $[8]='(' endif if $h=1 or $h=4 $[10]=')' endif if $h=2 or $h=5 or $h=6 $[14]=')' endif $t=Join($) $m=execute('$$v=$t') if 24=$v $Game24=Join($) return endif
next next next next endif next next next EndFunction
PS: Did you all verify that your code actually generates all the combinations & did you compare your results with Madruga's analysis? Richard's code is a thing of beauty but it doesn't generate all the possible combinations. Richard assumes the nested brackts "a (b(c d))" can be morphed into all possible solutions but it cannot be morphed into several of the unique solutions found by Madruga.
I think validating our results is a serious challange in this competition.
|
|
Re: KixGolf Results/Code
|
|
My first post, checked (ab)(cd), (abc)d, and a(bcd) which I think covers the required combinations as long as the numbers and operator all rotate through all combinations.
If Jens did not include the random input check then I think that if the other checks pass the script is good. But since the random numbers are part of the test, all possible combination of 1-9 would need to be checked. Since we currently have no good method of independently varifying a given set of random numbers at test time we can not be sure if the test scripts correctly found no solution or simply did not find the solution do to short comings of the code.
I applaud Jens for the time he spends setting this up and do not believe that absolute perfection is a requirement for this level of competition. The discussions so far have been quite interesting. [ 22. September 2002, 16:00: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
For certain division by zero doesn't work in my script & this was one of the reasons I had to experiment with solution order.
We are off for Brunch with some friends now but I hope to get back to this tonight. [ 22. September 2002, 16:12: Message edited by: Jack Lothian ]
|
|
Re: KixGolf Results/Code
|
|
Now that you mention division by zero... I just executed my code using all 0's. No 'division by zero' failure occurred. I guess the floating point equivalent of zero is 'near zero' not zero.
|
|
Re: KixGolf Results/Code
|
|
Kixtart seems to evaluate 3/0 as zero.
|
|
Re: KixGolf Results/Code
|
|
That is strange. Until now I have avoided division by zero. It is nice that the script does not ABEND, but this behavior is a disconcerting.
{edit} Checking for and avoiding division by zero sure would have added some strokes. [ 22. September 2002, 16:21: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
I just ran Richards code through all combinations by having four FOR loops looping from 0-9. Howver, at around the numbera 8,1,0,0 the script exitied with an 'Out of menory' message. I also noticed that the script consumed an ever increasing amount of memory while looping.
I was running it under KiXtart 4.12 beta 1 and it looks like there's some kind of memory leak. [ 23. September 2002, 15:39: Message edited by: sealeopard ]
|
|
Re: KixGolf Results/Code
|
|
Jens,
I saw your comment in the beta forum & I wonder about another issue - the "Join" function. It appears that Join strips all zeros & the decimal from numbers if that is at all possible. Thus if you declare a variable to be double precision but put an integer value into the variable then Join will convert it to an integer during the join. Currently, to force retention of floating point or double types you must work in pure strings. All the solutions posted seem to work in a pure string type right up to the evaluate. There are no mixture of types.
The question is if this is an appropriate strategy for the Join function. Maybe if the variable type is floating point or double then Join should append a decimal & a zero to the number to retain the original type.
For me sorting out all the problems was a major headache because I didn't realize at first that there was at least 3 problems & not 1. They were the problems of zero divide, the Join & rounding. I think this project really put Kixtart to the test in the domaine of real math. I know that this is the first time that I have looked at real math so closely in kixtart.
I agree with Howard, it was an interesting project. I learned a lot.
|
|
Re: KixGolf Results/Code
|
|
Howard: my compliments! You did an excelent job! I knew that, in order to have a winner, I'd have to let go of the obvious "tons" of nested FORs; and I knew there had to be some way to rotate the whole shebang, but I failed to see what you did... Also, the parentheses swap was a nice trick! BTW: If I'm not mistaken, you can change the 1E-9 for a bigger 0.1 (or can we use just .1 in KiXtart?) and it takes 1 (or 2) bytes out. It "should" be accurate enough, as the results that get closest to 24 and are not good answers are 23.8(8) and 24.1(6), if memory serves me...
|
|
Re: KixGolf Results/Code
|
|
On second though, Howard, are you sure your code is ok? I mean, you work with only 16 permutations of the possible 24!! Try runing under my improved test script (streamlined the output, and fixed some bugs). Also, and since one of the solutions that your code fails to find is one that has nothing to do with the permutations, there's bound to be some major error in there other than the missing permutations... Try your code with the 5555 set and check it out...
code:
BREAK ON Global $Target, $Valid $Target = 24 $ErrorMargin = 0.0001 $Valid = "003800460128013601370138013901450146014701480155015602260234" + "023602380239024402460248025702580266026802690288033403350337" + "033803390344034603480349035803590366036703680378038803890445" + "044604470448045604660467046804690478048805660569058806890699" + "078908881118112611271128112911341135113611371138113911441145" + "114611471148114911551156115711581166116811691188122412251226" + "122712281229123312341235123612371238123912441245124612471248" + "124912551256125712581259126612671268126912771278127912881289" + "133313341335133613371338133913441345134613471348134913561357" + "135813591366136713681369137713781379138813891399144414451446" + "144714481449145514561457145814591466146714681469147714781479" + "148814891555155615591566156715681569157815791588158915991666" + "166816691679168816891699177917881789179918881889222322242225" + "222722282229223322342235223622372238223922442245224622472248" + "224922552256225722582259226622672268226922772278228822892333" + "233523362337233823392344234523462347234823492355235623572358" + "235923662367236823692377237823792388238923992444244524462447" + "244824492455245624572458245924662467246824692477247824792488" + "248924992557255825592566256725682569257725782579258825892666" + "266726682669267826792688268926992778278827892888288928993333" + "333433353336333733383339334433453346334733483349335533563357" + "335933663367336833693377337833793389339934443445344634473448" + "344934553456345734583459346634683469347734783479348934993556" + "355735583559356635673568356935783579358835893599366636673668" + "366936773678367936883689369937773778377937883789379938883889" + "389939994444444544464447444844494455445644574458446844694477" + "447844794488448945554556455745584559456645674568456945774578" + "457945884589459946664667466846694677467846794688468946994777" + "477847884789479948884889489955555556555955665567556855775578" + "558855895599566656675668566956775678567956885689569957795788" + "578958885889666666686669667966886689678967996888688968997889" + "3388" $rc=SETOPTION('Explicit','ON') $rc=SETOPTION('NoVarsInString','ON') $rc=SRND(@MSECS) ? 'Game24 v 1.1 KiXtart Golf running under KiXtart v'@KIX ? '' Dim $i test24(1,2,3,4,1) test24(2,2,6,8,1) test24(4,4,6,6,2) test24(3,3,8,8,1) for $i = 1 to 20 test24(RND(9),RND(9),RND(9),RND(9),3) next test24(3,4,7,7,1) test24(1,2,8,9,1) test24(3,3,7,7,1) ? "" ; Inputs: $i1..$i4 => 4 numbers to pass to game24 ; $behaviour = 1 -> Expected result ; $behaviour = 2 -> Expected to fail ; $behaviour = 3 -> Don't know (random) function test24($i1,$i2,$i3,$i4,$behaviour) DIM $rc, $out, $result, $error, $str, $i, $found, $temp, $nums[4], $numbers $str = 'In: '+$i1+$i2+$i3+$i4+'; Out: ' $out=Game24($i1,$i2,$i3,$i4) if instr($out,".") == 0 $i = 1 while $i <= Len($out) if ( SubStr($out,$i,1) >= '0' ) and ( SubStr($out,$i,1) <= '9' ) $out = Left($out,$i) + '.0' + SubStr($out,$i+1) $i = $i + 2; endif; $i = $i + 1; loop endif $error=Execute("$$result=("+$out+")") $result=Trim($result) Dim $tmpStr $tmpStr = $out while (len($tmpStr)<22) $tmpStr = $tmpStr + " " loop $str = $str + left($tmpStr, 22) + " = " + $result if (len($result)<2) $str = $str+" " endif if ( $behaviour = 3 ) ; sort numbers used, so as to check array of possible solutions $nums[0] = $i1 $nums[1] = $i2 $nums[2] = $i3 $nums[3] = $i4 do $found = 0 for $i = 0 to 2 if $nums[$i] > $nums[$i+1] $found = 1 $temp = $nums[$i+1] $nums[$i+1] = $nums[$i] $nums[$i] = $temp endif next until $found == 0 $numbers = "" + $nums[0] + $nums[1] + $nums[2] + $nums[3] ; check for presence in array $found = 0 $i = 1 while ( $found == 0 ) and ( $i < Len($Valid) ) if ( SubStr( $Valid, $i, 4 ) == $numbers ) $found = 1 endif $i = $i + 4 loop if $found and ( ($result>=$Target-$ErrorMargin) and ($result<=$Target+$ErrorMargin) ) $str = $str + " => Correct!!" else if not $found and $result="" $str = $str + " => Correct!!" else $str = $str + " => WRONG!!" endif endif else if ( ($behaviour=1) and ($result>=$Target-$ErrorMargin) and ($result<=$Target+$ErrorMargin) ) or ( ($behaviour=2) and ($result='') ) $str = $str + " => Correct!!" else $str = $str + " => WRONG!!" endif endif ? $str endfunction Dim $shellcommand $shellcommand='kix32 Kixgolf3.kix $f='+@scriptname ? $shellcommand Shell $shellcommand ; Operators: 64 combinations ; +++ ++- ++* ++/ +-+ +-- +-* +-/ +*+ +*- +** +*/ +/+ +/- +/* +// ; -++ -+- -+* -+/ --+ --- --* --/ -*+ -*- -** -*/ -/+ -/- -/* -// ; *++ *+- *+* *+/ *-+ *-- *-* *-/ **+ **- *** **/ */+ */- */* *// ; /++ /+- /+* /+/ /-+ /-- /-* /-/ /*+ /*- /** /*/ //+ //- //* /// ; Digits: 24 permutations ; abcd abdc acbd acdb adbc adcb ; bacd badc bcad bcda bdac bdca ; cabd cadb cbad cbda cdab cdba ; dabc dacb dbac dbca dcab dcba ; Parentheses: 4 combinations ; 123456789 12345 (15 chars) ; a. b . c .d ; (a. b).(c .d) ; a.(b . c .d) ; (a. b . c).d ; 0 need (ab)cd ; 0 need a(bc)d ; 0 need ab(cd) ; ------------------ ; 1 need (abc)d ; ------------------ ; 3 need a(bcd) ; 13 need (ab)(cd) ; ------------------ ; 131 need at least one '+' ; 174 need at least one '-' ; 306 need at least one '*' ; 36 need at least one '/' ;! function game24($a,$b,$c,$d) endfunction ;! ;!
{edit} Added an if to only add (.0)s if there's no '.' in the returned string. {/edit} [ 23. September 2002, 20:40: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
It's me again... If someone want's to find out what expression satisfies a given condition, and since I already precalculated them all, just let me know. Alternatively, I can post the whole shebang, that is, 1 solution for each of the 466 possible solutions. Maybe in a diferent thread, so as not to bloat this one... BTW: The only solution to the aforementioned 5555 set is: 5*5-5/5, with or without parentheses around each pair of 5's... [ 23. September 2002, 20:43: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
My first code posting resolves the 5's correctly. That would seem to indicate the Richard's code using a(b(cd)) does not work either. My second posting was qualified on the case that the parentheses used in Richard's code held up. This case seems to indicate that his code would fail if the random test selected four 5's.
That being said, my second posting with a score of 314 would not be acceptable, Richard's code would not be acceptable, and my first code with a score of 434 is the current valid working code.
Jens, can we have a ruling? [ 23. September 2002, 21:20: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
I will test all codes with the 5555 combination tonight at home. I've tried to run each code through all permutations but that doesn't seem to be possible since I'm always getting 'out-of-memory' errors.
|
|
Re: KixGolf Results/Code
|
|
I believe that Richard's nested parenthesis of "a (b (c d))" can be morphed into all possible versions of "a b c d", "a (b c d)", and "a b (c d)" but not into all the possible permutations of 2 other variations found necessary by Madruga i.e "(a b c) d" and "(a b)(c d)". Interestingly, Richard identified 1 generalized type of parenthesis that covers about 80% cases for the 5 variants. Thus he gets most of the solutions.
A quick & dirty test by me seems to show Howard's first set of code works correctly. [ 23. September 2002, 21:55: Message edited by: Jack Lothian ]
|
|
Re: KixGolf Results/Code
|
|
Fernando, my code produces a valid output for 3,3,8,8 -> 8.0/(3.0-8.0/3.0) = 24 but your test script says that it fails: quote: In: 3388; Out: = => WRONG!!
I think you may need to recheck you code. Or am I using it incorrectly?
|
|
Re: KixGolf Results/Code
|
|
That's odd! I added a ? $out right after calling your game24 function (I assume you're talking about the 1st one posted with 434 score?) and it prints nothing...
code:
(1.0*2.0)*(3.0*4.0) In: 1234; Out: (1.0*2.0)*(3.0*4.0) = 24 => Correct!! 2.0*(6.0+8.0-2.0) In: 2268; Out: 2.0*(6.0+8.0-2.0) = 24 => Correct!! In: 4466; Out: = => Correct!! In: 3388; Out: = => WRONG!!
Are you sure it is returning the value? If it's some bug in my test program, you guys will have to help here... [ 23. September 2002, 22:43: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
I've tried to do some additional testing, and I must say: all you guys that develop anything more complex than 1 line of KiXtart should be given a medal! Honestly! Check the following script: it's my test script with Howard's 1st code: if I run it with the last get $h commented out, it prints this:
code:
[d:\work\admin\kixtart\kixgolf4]kix32 test2.kix
Game24 v 1.1 KiXtart Golf running under KiXtart v4.11
8.0/(3.0-8.0/3.0) 8.0/(3.0-8.0/3.0) 8.0/(3.0-8.0/3.0)
In: 3388; Out: = => WRONG!!
If I run it with the get $h working, and after pressing any key twice, it prints this:
code:
[d:\work\admin\kixtart\kixgolf4]kix32 test2.kix
Game24 v 1.1 KiXtart Golf running under KiXtart v4.11
8.0/(3.0-8.0/3.0)
In: 3388; Out: = => WRONG!!
Can someone tell me why? How can you guys debug code in this thing?
Here's the test code mentioned:
code:
BREAK ON Global $Target, $Valid $Target = 24 $ErrorMargin = 0.0001 $Valid = "003800460128013601370138013901450146014701480155015602260234" + "023602380239024402460248025702580266026802690288033403350337" + "033803390344034603480349035803590366036703680378038803890445" + "044604470448045604660467046804690478048805660569058806890699" + "078908881118112611271128112911341135113611371138113911441145" + "114611471148114911551156115711581166116811691188122412251226" + "122712281229123312341235123612371238123912441245124612471248" + "124912551256125712581259126612671268126912771278127912881289" + "133313341335133613371338133913441345134613471348134913561357" + "135813591366136713681369137713781379138813891399144414451446" + "144714481449145514561457145814591466146714681469147714781479" + "148814891555155615591566156715681569157815791588158915991666" + "166816691679168816891699177917881789179918881889222322242225" + "222722282229223322342235223622372238223922442245224622472248" + "224922552256225722582259226622672268226922772278228822892333" + "233523362337233823392344234523462347234823492355235623572358" + "235923662367236823692377237823792388238923992444244524462447" + "244824492455245624572458245924662467246824692477247824792488" + "248924992557255825592566256725682569257725782579258825892666" + "266726682669267826792688268926992778278827892888288928993333" + "333433353336333733383339334433453346334733483349335533563357" + "335933663367336833693377337833793389339934443445344634473448" + "344934553456345734583459346634683469347734783479348934993556" + "355735583559356635673568356935783579358835893599366636673668" + "366936773678367936883689369937773778377937883789379938883889" + "389939994444444544464447444844494455445644574458446844694477" + "447844794488448945554556455745584559456645674568456945774578" + "457945884589459946664667466846694677467846794688468946994777" + "477847884789479948884889489955555556555955665567556855775578" + "558855895599566656675668566956775678567956885689569957795788" + "578958885889666666686669667966886689678967996888688968997889" + "3388" $rc=SETOPTION('Explicit','ON') $rc=SETOPTION('NoVarsInString','ON') $rc=SRND(@MSECS) ? 'Game24 v 1.1 KiXtart Golf running under KiXtart v'@KIX ? '' Dim $i test24(3,3,8,8,1) quit ;test24(1,2,3,4,1) ;test24(2,2,6,8,1) ;test24(4,4,6,6,2) ;for $i = 1 to 20 ; test24(RND(9),RND(9),RND(9),RND(9),3) ;next ;test24(3,4,7,7,1) ;test24(1,2,8,9,1) ;test24(3,3,7,7,1) ? "" ; Inputs: $i1..$i4 => 4 numbers to pass to game24 ; $behaviour = 1 -> Expected result ; $behaviour = 2 -> Expected to fail ; $behaviour = 3 -> Don't know (random) function test24($i1,$i2,$i3,$i4,$behaviour) DIM $rc, $out, $result, $error, $str, $i, $found, $temp, $nums[4], $numbers $str = 'In: '+$i1+$i2+$i3+$i4+'; Out: ' $out=Game24($i1,$i2,$i3,$i4) ; ? $out if instr($out,".") == 0 $i = 1 while $i <= Len($out) if ( SubStr($out,$i,1) >= '0' ) and ( SubStr($out,$i,1) <= '9' ) $out = Left($out,$i) + '.0' + SubStr($out,$i+1) $i = $i + 2; endif; $i = $i + 1; loop endif $error=Execute("$$result=("+$out+")") $result=Trim($result) Dim $tmpStr $tmpStr = $out while (len($tmpStr)<22) $tmpStr = $tmpStr + " " loop $str = $str + left($tmpStr, 22) + " = " + $result if (len($result)<2) $str = $str+" " endif if ( $behaviour = 3 ) ; sort numbers used, so as to check array of possible solutions $nums[0] = $i1 $nums[1] = $i2 $nums[2] = $i3 $nums[3] = $i4 do $found = 0 for $i = 0 to 2 if $nums[$i] > $nums[$i+1] $found = 1 $temp = $nums[$i+1] $nums[$i+1] = $nums[$i] $nums[$i] = $temp endif next until $found == 0 $numbers = "" + $nums[0] + $nums[1] + $nums[2] + $nums[3] ; check for presence in array $found = 0 $i = 1 while ( $found == 0 ) and ( $i < Len($Valid) ) if ( SubStr( $Valid, $i, 4 ) == $numbers ) $found = 1 endif $i = $i + 4 loop if $found and ( ($result>=$Target-$ErrorMargin) and ($result<=$Target+$ErrorMargin) ) $str = $str + " => Correct!!" else if not $found and $result="" $str = $str + " => Correct!!" else $str = $str + " => WRONG!!" endif endif else if ( ($behaviour=1) and ($result>=$Target-$ErrorMargin) and ($result<=$Target+$ErrorMargin) ) or ( ($behaviour=2) and ($result='') ) $str = $str + " => Correct!!" else $str = $str + " => WRONG!!" endif endif ? $str endfunction Dim $shellcommand $shellcommand='kix32 Kixgolf3.kix $f='+@scriptname ? $shellcommand Shell $shellcommand ; Operators: 64 combinations ; +++ ++- ++* ++/ +-+ +-- +-* +-/ +*+ +*- +** +*/ +/+ +/- +/* +// ; -++ -+- -+* -+/ --+ --- --* --/ -*+ -*- -** -*/ -/+ -/- -/* -// ; *++ *+- *+* *+/ *-+ *-- *-* *-/ **+ **- *** **/ */+ */- */* *// ; /++ /+- /+* /+/ /-+ /-- /-* /-/ /*+ /*- /** /*/ //+ //- //* /// ; Digits: 24 permutations ; abcd abdc acbd acdb adbc adcb ; bacd badc bcad bcda bdac bdca ; cabd cadb cbad cbda cdab cdba ; dabc dacb dbac dbca dcab dcba ; Parentheses: 4 combinations ; 123456789 12345 (15 chars) ; a. b . c .d ; (a. b).(c .d) ; a.(b . c .d) ; (a. b . c).d ; 0 need (ab)cd ; 0 need a(bc)d ; 0 need ab(cd) ; ------------------ ; 1 need (abc)d ; ------------------ ; 3 need a(bcd) ; 13 need (ab)(cd) ; ------------------ ; 131 need at least one '+' ; 174 need at least one '-' ; 306 need at least one '*' ; 36 need at least one '/' ;! function game24($a,$b,$c,$d)
Dim $h, $j, $l, $p, $q, $r, $s, $t, $v, $, $x, $y
$h = "+","-","/","*" for $y=1 to 4 for $x=1 to 4 for each $p in $h for each $q in $h for each $r in $h for each $j in split("0,8,10,18~0,12~4,16","~") $ = ".0" $s = ""+$a+$+$p+$b+$+$q+$c+$+$r+$d+$ for each $ in split($j,",") $l = chr(40 + ($l="(")) $s = "" + left($s,$) + $l + substr($s,1+$) next $t = execute("$$v=$s") if abs($v-24)< 1E-9 goto E endif next next next next $ = $b $b = $c $c = $d $d = $ next $ = $a $a = $b $b = $ next $s = ""
:E $game24 = $s ? $s ;get $h endfunction ;! ;!
[ 23. September 2002, 23:06: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
Working on it.
|
|
Re: KixGolf Results/Code
|
|
BTW, Howard, I've been through your permutation code, and found something's missing! I extracted all but the code to generate the permutations and turned it into this independent script:
code:
BREAK ON Dim $a, $b, $c, $d, $, $x, $y $a = 'a' $b = 'b' $c = 'c' $d = 'd' for $y=1 to 4 for $x=1 to 4 ? ""+$a+$b+$c+$d $ = $b $b = $c $c = $d $d = $ next $ = $a $a = $b $b = $ next
I thought it would only do 16 of the 24 permutations, but it does even less!! It only does 12 "diferent" permutations, as 4 are repeated!! This means that you test only HALF the valid permutations!!!
code:
It. Permutation 01 abcd 02 acdb 03 adbc 04 abcd 05 cadb 06 cdba 07 cbad 08 cadb 09 dcba 10 dbac 11 dacb 12 dcba 13 bdac 14 bacd 15 bcda 16 bdac
Putting it another way, where the number(s) in front are the iteration number(s) where that sequence is visited:
code:
abcd 01 04 abdc acbd acdb 02 adbc 03 adcb bacd 14 badc bcad bcda 15 bdac 13 16 bdca cabd cadb 05 08 cbad 07 cbda cdab cdba 06 dabc dacb 11 dbac 10 dbca dcab dcba 09 12
This means, or so I think, that you never test the following permutations: abdc acbd adcb badc bcad bdca cabd cbda cdab dabc dbca dcab So, it's very likely that your code would fail on things like: 6143 and 6451. [ 24. September 2002, 00:41: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
To answer the question about printing the output three times from within my function. I think we found a KiXtart bug.
Kholm, suggested that I remove the exit at the end of the function to save four strokes. I did that without testing because he and I thought when the execution hit the ENDFUNCTION statement the function would exit automatically. WRONG! I think that using the GOTO (Yuk!) inside the nested loops causes a problem. The GOTO seems to behaving like a "GOSUB" statement and the ENDFUNCTION like a "RETURN". Without the exist statement in the code, execution returns to the GOTO and the FOR loops continue processing. When the loops were finished processing the value of $Game24 is set to "".
So your program was correct in the strange output since it received strange output. code:
Game24 v 1.1 KiXtart Golf running under KiXtart v4.11
In: 3388; Out: 8.0/(3.0-8.0/3.0) = 24 => Correct!! In: 1234; Out: (1.0+2.0+3.0)*4.0 = 24 => Correct!! In: 2268; Out: (2.0+6.0)+(8.0*2.0) = 24 => Correct!! In: 4466; Out: = => Correct!! In: 0965; Out: (0.0-6.0)*(5.0-9.0) = 24 => Correct!! In: 3164; Out: 6.0/(1.0-3.0/4.0) = 24 => Correct!! In: 7395; Out: (7.0+3.0)+(9.0+5.0) = 24 => Correct!! In: 1955; Out: (1.0+5.0)*(9.0-5.0) = 24 => Correct!! In: 6396; Out: (6.0+3.0)+(9.0+6.0) = 24 => Correct!! In: 4736; Out: = => Correct!! In: 9439; Out: (9.0*4.0)-(3.0+9.0) = 24 => Correct!! In: 4478; Out: (4.0+4.0*7.0)-8.0 = 24 => Correct!! In: 1254; Out: (5.0-1.0)*(4.0+2.0) = 24 => Correct!! In: 0714; Out: (0.0+7.0-1.0)*4.0 = 24 => Correct!! In: 2000; Out: = => Correct!! In: 9196; Out: (9.0+1.0*9.0)+6.0 = 24 => Correct!! In: 0200; Out: = => Correct!! In: 7547; Out: (7.0*5.0)-(4.0+7.0) = 24 => Correct!! In: 4270; Out: = => Correct!! In: 4362; Out: (4.0+3.0*6.0)+2.0 = 24 => Correct!! In: 3778; Out: (3.0+7.0-7.0)*8.0 = 24 => Correct!! In: 2476; Out: (2.0+4.0*7.0)-6.0 = 24 => Correct!! In: 8624; Out: (8.0+6.0*2.0)+4.0 = 24 => Correct!! In: 7564; Out: (7.0+5.0-6.0)*4.0 = 24 => Correct!! In: 3477; Out: (3.0+4.0*7.0)-7.0 = 24 => Correct!! In: 1289; Out: (8.0*9.0)/(2.0+1.0) = 24 => Correct!! In: 3377; Out: (3.0+3.0/7.0)*7.0 = 24 => Correct!!
kix32 Kixgolf3.kix $f=junk.kix
KixGolf score = 438
[ 24. September 2002, 12:24: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
You're right! Unfortunately for you, so am I in my previous post... Another one that your program fails is 4429... Just add one of those with a '1' at the end of the call to test24 and you'll see for yourself... Sorry...
|
|
Re: KixGolf Results/Code
|
|
Updated KixText.kix
code:
BREAK ON Global $Target, $Valid $Target = 24 $ErrorMargin = 0.0001 $Valid = "003800460128013601370138013901450146014701480155015602260234" + "023602380239024402460248025702580266026802690288033403350337" + "033803390344034603480349035803590366036703680378038803890445" + "044604470448045604660467046804690478048805660569058806890699" + "078908881118112611271128112911341135113611371138113911441145" + "114611471148114911551156115711581166116811691188122412251226" + "122712281229123312341235123612371238123912441245124612471248" + "124912551256125712581259126612671268126912771278127912881289" + "133313341335133613371338133913441345134613471348134913561357" + "135813591366136713681369137713781379138813891399144414451446" + "144714481449145514561457145814591466146714681469147714781479" + "148814891555155615591566156715681569157815791588158915991666" + "166816691679168816891699177917881789179918881889222322242225" + "222722282229223322342235223622372238223922442245224622472248" + "224922552256225722582259226622672268226922772278228822892333" + "233523362337233823392344234523462347234823492355235623572358" + "235923662367236823692377237823792388238923992444244524462447" + "244824492455245624572458245924662467246824692477247824792488" + "248924992557255825592566256725682569257725782579258825892666" + "266726682669267826792688268926992778278827892888288928993333" + "333433353336333733383339334433453346334733483349335533563357" + "335933663367336833693377337833793389339934443445344634473448" + "344934553456345734583459346634683469347734783479348934993556" + "355735583559356635673568356935783579358835893599366636673668" + "366936773678367936883689369937773778377937883789379938883889" + "389939994444444544464447444844494455445644574458446844694477" + "447844794488448945554556455745584559456645674568456945774578" + "457945884589459946664667466846694677467846794688468946994777" + "477847884789479948884889489955555556555955665567556855775578" + "558855895599566656675668566956775678567956885689569957795788" + "578958885889666666686669667966886689678967996888688968997889" + "3388" $rc=SETOPTION('Explicit','ON') $rc=SETOPTION('NoVarsInString','ON') $rc=SRND(@MSECS) ? 'Game24 v 1.4 KiXtart Golf running under KiXtart v'@KIX ? '' Dim $i test24(6,1,4,3,1) test24(5,5,5,5,1) test24(6,4,5,1,1) test24(3,3,8,8,1) test24(1,2,3,4,1) test24(2,2,6,8,1) test24(4,4,6,6,2) for $i = 1 to 20 test24(RND(9),RND(9),RND(9),RND(9),3) next test24(3,4,7,7,1) test24(1,2,8,9,1) test24(3,3,7,7,1) ? "" ; Inputs: $i1..$i4 => 4 numbers to pass to game24 ; $behaviour = 1 -> Expected result ; $behaviour = 2 -> Expected to fail ; $behaviour = 3 -> Don't know (random) function test24($i1,$i2,$i3,$i4,$behaviour) DIM $rc, $out, $result, $error, $str, $i, $found, $temp, $nums[4], $numbers $str = 'In: '+$i1+$i2+$i3+$i4+'; Out: ' $out="" $out=Game24($i1,$i2,$i3,$i4) if instr($out,".") == 0 $i = 1 while $i <= Len($out) if ( SubStr($out,$i,1) >= '0' ) and ( SubStr($out,$i,1) <= '9' ) $out = Left($out,$i) + '.0' + SubStr($out,$i+1) $i = $i + 2; endif; $i = $i + 1; loop endif $error=Execute("$$result=("+$out+")") $result=Trim($result) Dim $tmpStr $tmpStr = $out while (len($tmpStr)<22) $tmpStr = $tmpStr + " " loop $str = $str + left($tmpStr, 22) + " = " + $result if (len($result)<2) $str = $str+" " endif if ( $behaviour = 3 ) ; sort numbers used, so as to check array of possible solutions $nums[0] = $i1 $nums[1] = $i2 $nums[2] = $i3 $nums[3] = $i4 do $found = 0 for $i = 0 to 2 if $nums[$i] > $nums[$i+1] $found = 1 $temp = $nums[$i+1] $nums[$i+1] = $nums[$i] $nums[$i] = $temp endif next until $found == 0 $numbers = "" + $nums[0] + $nums[1] + $nums[2] + $nums[3] ; check for presence in array $found = 0 $i = 1 while ( $found == 0 ) and ( $i < Len($Valid) ) if ( SubStr( $Valid, $i, 4 ) == $numbers ) $found = 1 endif $i = $i + 4 loop if $found and ( ($result>=$Target-$ErrorMargin) and ($result<=$Target+$ErrorMargin) ) $str = $str + " => Correct!!" else if not $found and $result="" $str = $str + " => Correct!!" else $str = $str + " => WRONG!!" endif endif else if ( ($behaviour=1) and ($result>=$Target-$ErrorMargin) and ($result<=$Target+$ErrorMargin) ) or ( ($behaviour=2) and ($result='') ) $str = $str + " => Correct!!" else $str = $str + " => WRONG!!" endif endif ? $str endfunction Dim $shellcommand $shellcommand='kix32 Kixgolf3.kix $f='+@scriptname ? $shellcommand Shell $shellcommand ; Operators: 64 combinations ; +++ ++- ++* ++/ +-+ +-- +-* +-/ +*+ +*- +** +*/ +/+ +/- +/* +// ; -++ -+- -+* -+/ --+ --- --* --/ -*+ -*- -** -*/ -/+ -/- -/* -// ; *++ *+- *+* *+/ *-+ *-- *-* *-/ **+ **- *** **/ */+ */- */* *// ; /++ /+- /+* /+/ /-+ /-- /-* /-/ /*+ /*- /** /*/ //+ //- //* /// ; Digits: 24 permutations ; abcd abdc acbd acdb adbc adcb ; bacd badc bcad bcda bdac bdca ; cabd cadb cbad cbda cdab cdba ; dabc dacb dbac dbca dcab dcba ; Parentheses: 4 combinations ; 123456789 12345 (15 chars) ; a. b . c .d ; (a. b).(c .d) ; a.(b . c .d) ; (a. b . c).d ; 0 need (ab)cd ; 0 need a(bc)d ; 0 need ab(cd) ; ------------------ ; 1 need (abc)d ; ------------------ ; 3 need a(bcd) ; 13 need (ab)(cd) ; ------------------ ; 131 need at least one '+' ; 174 need at least one '-' ; 306 need at least one '*' ; 36 need at least one '/' ;! Function game24($,$b,$c,$d) $game24=f(""+$+$b+$c+$d,"") EndFunction Function f($,$b) Dim $e,$x,$y,$z,$a If($) For $x=1 to Len($) $e=f(Left($,$x-1)+SubStr($,$x+1),$b+SubStr($,$x,1)) If $e $f=$e EndIf Next Else $e=Split("+ - * /") For Each $x In $e For Each $y In $e For Each $z In $e $=Left($b,1)+".0"+$x+"("+SubStr($b,2,1)+".0"+$y+"("+SubStr($b,3,1)+".0"+$z+Right($b,1)+"))" $z=Execute("$$a="+$) If "24"=$a $f=$ EndIf Next Next Next EndIf EndFunction ;! ;!
|
|
Re: KixGolf Results/Code
|
|
Running the updated KixTest 1.4 on Richard Howarth's code yields the following:
code:
[d:\work\admin\kixtart\kixgolf4]kix32 testRH.kix Game24 v 1.4 KiXtart Golf running under KiXtart v4.11 In: 6143; Out: 6.0/(1.0-(3.0/4)) = 24 => Correct!! In: 5555; Out: = => WRONG!! In: 6451; Out: 4.0/(1.0-(5.0/6)) = 24 => Correct!! In: 3388; Out: 8.0/(3.0-(8.0/3)) = 24 => Correct!! In: 1234; Out: 4.0*(3.0*(2.0/1)) = 24 => Correct!! In: 2268; Out: 8.0+(2.0*(6.0+2)) = 24 => Correct!! In: 4466; Out: = => Correct!! In: 0106; Out: = => Correct!! In: 8755; Out: 7.0-(8.0-(5.0*5)) = 24 => Correct!! In: 0262; Out: 2.0*(6.0*(2.0-0)) = 24 => Correct!! In: 3145; Out: 4.0+(5.0*(1.0+3)) = 24 => Correct!! In: 5746; Out: 4.0*(7.0-(6.0-5)) = 24 => Correct!! In: 2442; Out: 2.0*(4.0+(4.0*2)) = 24 => Correct!! In: 1084; Out: 8.0*(4.0-(0.0+1)) = 24 => Correct!! In: 6622; Out: 6.0/(2.0/(2.0+6)) = 24 => Correct!! In: 8753; Out: 3.0-(7.0*(5.0-8)) = 24 => Correct!! In: 3736; Out: 6.0-(3.0-(7.0*3)) = 24 => Correct!! In: 5295; Out: 5.0+(9.0+(2.0*5)) = 24 => Correct!! In: 1770; Out: = => Correct!! In: 8112; Out: 1.0*(8.0*(2.0+1)) = 24 => Correct!! In: 0705; Out: = => Correct!! In: 1909; Out: = => Correct!! In: 2924; Out: 4.0+(2.0+(9.0*2)) = 24 => Correct!! In: 1119; Out: = => Correct!! In: 3447; Out: 4.0*(7.0-(4.0-3)) = 24 => Correct!! In: 6395; Out: 9.0-(5.0*(3.0-6)) = 24 => Correct!! In: 1294; Out: 4.0*(9.0-(2.0+1)) = 24 => Correct!! In: 3477; Out: 7.0-(4.0-(7.0*3)) = 24 => Correct!! In: 1289; Out: 9.0*(8.0/(2.0+1)) = 24 => Correct!! In: 3377; Out: 7.0*(3.0+(3.0/7)) = 24 => Correct!! kix32 Kixgolf3.kix $f=testRH.kix KixGolf v3.0.3 score = 404, running under KiXtart v4.11
{edit} Running it a few more times, uncovered some more failing combos:
code:
In: 1655; Out: = => WRONG!! In: 6917; Out: = => WRONG!! In: 4524; Out: = => WRONG!! In: 1573; Out: = => WRONG!!
{/edit} {edit} As for the other ones, here are the valid solutions for the misses:
code:
1573 : (1+5)*(7-3) 1573 : (3-1)*(5+7) 1573 : (3-1)*(7+5) 1573 : (5+1)*(7-3) 1573 : (5+7)*(3-1) 1573 : (7+5)*(3-1) 1573 : (7-3)*(1+5) 1573 : (7-3)*(5+1) 1655 : (1+5)*5-6 1655 : (5*6)-(1+5) 1655 : (5*6)-(5+1) 1655 : (5*6)-1-5 1655 : (5*6)-5-1 1655 : (5*6-1)-5 1655 : (5*6-5)-1 1655 : (5+1)*5-6 1655 : (6*5)-(1+5) 1655 : (6*5)-(5+1) 1655 : (6*5)-1-5 1655 : (6*5)-5-1 1655 : (6*5-1)-5 1655 : (6*5-5)-1 1655 : 5*(1+5)-6 1655 : 5*(5+1)-6 1655 : 5*6-(1+5) 1655 : 5*6-(5+1) 1655 : 5*6-1-5 1655 : 5*6-5-1 1655 : 6*5-(1+5) 1655 : 6*5-(5+1) 1655 : 6*5-1-5 1655 : 6*5-5-1 4524 : (2*5-4)*4 4524 : (2+5)*4-4 4524 : (4+4)*(5-2) 4524 : (5*2-4)*4 4524 : (5+2)*4-4 4524 : (5-2)*(4+4) 4524 : 4*(2*5-4) 4524 : 4*(2+5)-4 4524 : 4*(5*2-4) 4524 : 4*(5+2)-4 5555 : (5*5)-(5/5) 5555 : (5*5)-5/5 5555 : 5*5-(5/5) 5555 : 5*5-5/5 6917 : (1+7)*(9-6) 6917 : (7+1)*(9-6) 6917 : (9-6)*(1+7) 6917 : (9-6)*(7+1)
{/edit} [ 24. September 2002, 01:46: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
I have to add four strokes to cover those numbers (4,4,2,9).
code:
Game24 v 1.1 KiXtart Golf running under KiXtart v4.11
In: 3388; Out: 8.0/(3.0-8.0/3.0) = 24 => Correct!! In: 4429; Out: (9.0-2.0)*4.0-4.0 = 24 => Correct!! In: 1234; Out: (1.0+2.0+3.0)*4.0 = 24 => Correct!! In: 2268; Out: (2.0+6.0)+8.0*2.0 = 24 => Correct!! In: 4466; Out: = => Correct!! In: 0380; Out: (0.0+3.0)*8.0+0.0 = 24 => Correct!! In: 7443; Out: (7.0+4.0/4.0)*3.0 = 24 => Correct!! In: 4459; Out: = => Correct!! In: 8978; Out: (9.0-7.0)*8.0+8.0 = 24 => Correct!! In: 6782; Out: 8.0*(2.0+7.0-6.0) = 24 => Correct!! In: 0814; Out: (0.0-8.0)*(1.0-4.0) = 24 => Correct!! In: 9743; Out: (9.0-7.0)*4.0*3.0 = 24 => Correct!! In: 8953; Out: (5.0-8.0)+3.0*9.0 = 24 => Correct!! In: 9042; Out: = => Correct!! In: 0249; Out: = => Correct!! In: 6671; Out: = => Correct!! In: 1902; Out: = => Correct!! In: 2978; Out: (7.0+9.0)*2.0-8.0 = 24 => Correct!! In: 2529; Out: 2.0*(5.0-2.0+9.0) = 24 => Correct!! In: 1071; Out: = => Correct!! In: 8781; Out: (8.0+7.0)+8.0+1.0 = 24 => Correct!! In: 7439; Out: (7.0+4.0)*3.0-9.0 = 24 => Correct!! In: 6716; Out: = => Correct!! In: 4349; Out: (4.0+4.0)*9.0/3.0 = 24 => Correct!! In: 1027; Out: = => Correct!! In: 3477; Out: (3.0+4.0*7.0)-7.0 = 24 => Correct!! In: 1289; Out: (8.0*9.0)/(2.0+1.0) = 24 => Correct!! In: 3377; Out: (3.0+3.0/7.0)*7.0 = 24 => Correct!!
kix32 Kixgolf3.kix $f=junk.kix
KixGolf score = 442
code:
function game24($a,$b,$c,$d)
Dim $h, $j, $l, $p, $q, $r, $s, $t, $v, $, $x, $y $h = "+","-","/","*" for $y=1 to 4 for $x=1 to 4 for each $p in $h for each $q in $h for each $r in $h for each $j in split("0,8~0,8,10,18~0,12~4,16","~") $ = ".0" $s = ""+$a+$+$p+$b+$+$q+$c+$+$r+$d+$ for each $ in split($j,",") $l = chr(40 + ($l="(")) $s = "" + left($s,$) + $l + substr($s,1+$) next $t = execute("$$v=$s") if abs($v-24)< 1E-9 goto E endif next next next next $ = $b $b = $c $c = $d $d = $ next $ = $a $a = $b $b = $ next $s = ""
:E $game24 = $s exit endfunction
|
|
Re: KixGolf Results/Code
|
|
More work for you, Howard... Using the above v1.4 tester with latest Howard's code:
code:
[d:\work\admin\kixtart\kixgolf4]kix32 testHB.kix Game24 v 1.4 KiXtart Golf running under KiXtart v4.11 In: 6143; Out: = => WRONG!! In: 5555; Out: (5.0*5.0)-5.0/5.0 = 24 => Correct!! In: 6451; Out: = => WRONG!! In: 3388; Out: 8.0/(3.0-8.0/3.0) = 24 => Correct!! In: 1234; Out: (1.0+2.0+3.0)*4.0 = 24 => Correct!! In: 2268; Out: (2.0+6.0)+8.0*2.0 = 24 => Correct!! In: 4466; Out: = => Correct!! In: 0028; Out: = => Correct!! In: 2263; Out: 2.0*(6.0+3.0*2.0) = 24 => Correct!! In: 4717; Out: (1.0+7.0)*(7.0-4.0) = 24 => Correct!! In: 6834; Out: (6.0/3.0)*(4.0+8.0) = 24 => Correct!! In: 1832; Out: (1.0+8.0+3.0)*2.0 = 24 => Correct!! In: 0025; Out: = => Correct!! In: 8164; Out: 8.0*(1.0+6.0-4.0) = 24 => Correct!! In: 7912; Out: (7.0-1.0)+2.0*9.0 = 24 => Correct!! In: 5046; Out: (5.0/0.0)+4.0*6.0 = 24 => Correct!! In: 5857; Out: (5.0+5.0-7.0)*8.0 = 24 => Correct!! In: 0899; Out: = => Correct!! In: 5506; Out: = => Correct!! In: 0990; Out: = => Correct!! In: 2219; Out: 2.0*(2.0+1.0+9.0) = 24 => Correct!! In: 9492; Out: (9.0+4.0)+9.0+2.0 = 24 => Correct!! In: 2430; Out: (2.0*4.0)*3.0+0.0 = 24 => Correct!! In: 7038; Out: (7.0/0.0)+3.0*8.0 = 24 => Correct!! In: 3519; Out: (3.0*5.0)+1.0*9.0 = 24 => Correct!! In: 2494; Out: (9.0-2.0)*4.0-4.0 = 24 => Correct!! In: 6672; Out: (6.0+6.0*7.0)/2.0 = 24 => Correct!! In: 3477; Out: (3.0+4.0*7.0)-7.0 = 24 => Correct!! In: 1289; Out: (8.0*9.0)/(2.0+1.0) = 24 => Correct!! In: 3377; Out: (3.0+3.0/7.0)*7.0 = 24 => Correct!! kix32 Kixgolf3.kix $f=testHB.kix KixGolf v3.0.3 score = 442, running under KiXtart v4.11
{edit} I'm now adding the valid solutions for the "misses", so as to help you guys sort your codes...
code:
6143 => 6/(1-3/4) 6451 => 4/(1-5/6) 6451 => 6/(5/4-1)
{/edit} [ 24. September 2002, 01:34: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
More sad news, this time it's for AJH:
code:
[d:\work\admin\kixtart\kixgolf4]kix32 testAJH.kix Game24 v 1.4 KiXtart Golf running under KiXtart v4.11 In: 6143; Out: 6./(1.-3./4.) = 24 => Correct!! In: 5555; Out: 5.*5.-5./5. = 24 => Correct!! In: 6451; Out: 6./(5./4.-1.) = 24 => Correct!! In: 3388; Out: 8./(3.-8./3.) = 24 => Correct!! In: 1234; Out: (1.+2.+3.)*4. = 24 => Correct!! In: 2268; Out: 2.+2.*8.+6. = 24 => Correct!! In: 4466; Out: = => Correct!! In: 0729; Out: = => Correct!! In: 8114; Out: (8.-1.-1.)*4. = 24 => Correct!! In: 1546; Out: 4./(1.-5./6.) = 24 => Correct!! In: 7434; Out: (7.-4.+3.)*4. = 24 => Correct!! In: 5654; Out: (5.+6.-5.)*4. = 24 => Correct!! In: 3910; Out: 3.*(9.-1.+0.) = 24 => Correct!! In: 5142; Out: (5.-1.)*(4.+2.) = 24 => Correct!! In: 9693; Out: (9./9.+3.)*6. = 24 => Correct!! In: 6764; Out: (6.*4.)*(7.-6.) = 24 => Correct!! In: 2400; Out: = => Correct!! In: 7750; Out: = => Correct!! In: 4691; Out: 6.*(9.-4.-1.) = 24 => Correct!! In: 1177; Out: = => Correct!! In: 9324; Out: (9.+3.)/(2./4.) = 24 => Correct!! In: 4166; Out: = => WRONG!! In: 5425; Out: = => WRONG!! In: 1911; Out: = => Correct!! In: 9940; Out: = => Correct!! In: 0106; Out: = => Correct!! In: 1902; Out: = => Correct!! In: 3477; Out: 3.+4.*7.-7. = 24 => Correct!! In: 1289; Out: 2.*8.-1.+9. = 24 => Correct!! In: 3377; Out: (3.+3./7.)*7. = 24 => Correct!! kix32 Kixgolf3.kix $f=testAJH.kix KixGolf v3.0.3 score = 541, running under KiXtart v4.11
{edit} Valid solutions for the missed ones:
code:
4166 : (1+4)*6-6 4166 : (4+1)*6-6 4166 : (4-1)*6+6 4166 : 6*(1+4)-6 4166 : 6*(4+1)-6 4166 : 6*(4-1)+6 4166 : 6+(4-1)*6 4166 : 6+6*(4-1) 4166 : 6-(1-4)*6 4166 : 6-6*(1-4) 5425 : (5+5)*2+4 5425 : 2*(5+5)+4 5425 : 4+(5+5)*2 5425 : 4+2*(5+5)
{/edit} [ 24. September 2002, 01:38: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
And this time it's for Jack Lothian... Sorry...
code:
[d:\work\admin\kixtart\kixgolf4]kix32 testJL.kix Game24 v 1.4 KiXtart Golf running under KiXtart v4.11 In: 6143; Out: cdbl(6.0) / ( cdbl(1 = 24 => Correct!! In: 5555; Out: cdbl(5.0) * cdbl(5. = 24 => Correct!! In: 6451; Out: cdbl(6.0) * cdbl(4. = 24,2 => WRONG!! In: 3388; Out: cdbl(3.0) + cdbl(8. = 24,3333333333333 => WRONG!! In: 1234; Out: ( cdbl(1.0) + cdbl(2 = 24 => Correct!! In: 2268; Out: cdbl(2.0) * ( cdbl(2 = 24 => Correct!! In: 4466; Out: = => Correct!! In: 0453; Out: = => Correct!! In: 4930; Out: cdbl(4.0) * ( cdbl(9 = 24 => Correct!! In: 8900; Out: = => Correct!! In: 1428; Out: ( cdbl(1.0) + cdbl(4 = 24 => Correct!! In: 7278; Out: cdbl(7.0) + cdbl(2. = 24 => Correct!! In: 2087; Out: = => Correct!! In: 3806; Out: cdbl(3.0) * cdbl(8. = 24 => Correct!! In: 5604; Out: cdbl(5.0) * cdbl(0. = 24 => Correct!! In: 2670; Out: = => Correct!! In: 5696; Out: cdbl(6.0) * cdbl(9. = 24 => Correct!! In: 9356; Out: ( cdbl(9.0) - cdbl(3 = 24 => Correct!! In: 9439; Out: ( cdbl(9.0) - cdbl(4 = 24 => Correct!! In: 8562; Out: ( cdbl(8.0) - cdbl(5 = 24 => Correct!! In: 9648; Out: cdbl(9.0) * ( cdbl(4 = 24 => Correct!! In: 6174; Out: cdbl(6.0) * ( cdbl(1 = 24 => Correct!! In: 7484; Out: cdbl(7.0) * cdbl(4. = 24 => Correct!! In: 9289; Out: cdbl(9.0) - cdbl(2. = 24 => Correct!! In: 0052; Out: = => Correct!! In: 0731; Out: ( cdbl(0.0) + cdbl(7 = 24 => Correct!! In: 0808; Out: = => Correct!! In: 3477; Out: cdbl(3.0) + cdbl(4. = 24 => Correct!! In: 1289; Out: cdbl(2.0) * cdbl(8. = 24 => Correct!! In: 3377; Out: ( cdbl(3.0) + cdbl(3 = 24 => Correct!! kix32 Kixgolf3.kix $f=testJL.kix KixGolf v3.0.3 score = 653, running under KiXtart v4.11
I'm lucky I'm not in ancient Rome... {edit} Another one for JL:
code:
In: 2747; Out: cdbl(2.0) * cdbl(7. = 24,5 => WRONG!!
{/edit} {edit} Valid solutions for the missed ones:
code:
2747 : (7+7)*2-4 2747 : 2*(7+7)-4 3388 : 8/(3-8/3) 6451 : 4/(1-5/6) 6451 : 6/(5/4-1)
{/edit} [ 24. September 2002, 01:41: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
there
I hate it when the KixGolf score keeps increasining.
code:
Game24 v 1.1 KiXtart Golf running under KiXtart v4.11
In: 3388; Out: 8.0/(3.0-8.0/3.0) = 24 => Correct!! In: 6143; Out: 6.0/(1.0-3.0/4.0) = 24 => Correct!! In: 6451; Out: 6.0/(5.0/4.0-1.0) = 24 => Correct!! In: 4429; Out: (9.0-2.0)*4.0-4.0 = 24 => Correct!! In: 1234; Out: (1.0+2.0+3.0)*4.0 = 24 => Correct!! In: 2268; Out: (2.0+6.0)+8.0*2.0 = 24 => Correct!! In: 4466; Out: = => Correct!! In: 1212; Out: = => Correct!! In: 1899; Out: = => Correct!! In: 7861; Out: = => Correct!! In: 6480; Out: (6.0*4.0)+8.0/0.0 = 24 => Correct!! In: 2472; Out: (2.0*7.0)*2.0-4.0 = 24 => Correct!! In: 9952; Out: = => Correct!! In: 8523; Out: (8.0*2.0)+3.0+5.0 = 24 => Correct!! In: 3231; Out: (3.0*2.0)*(3.0+1.0) = 24 => Correct!! In: 8093; Out: (8.0+0.0/9.0)*3.0 = 24 => Correct!! In: 2676; Out: (7.0-2.0)*6.0-6.0 = 24 => Correct!! In: 6412; Out: (6.0+2.0)*(4.0-1.0) = 24 => Correct!! In: 3259; Out: (3.0+5.0*9.0)/2.0 = 24 => Correct!! In: 2243; Out: (2.0+2.0+4.0)*3.0 = 24 => Correct!! In: 5131; Out: (5.0+1.0)*(3.0+1.0) = 24 => Correct!! In: 6271; Out: (6.0-2.0)*(7.0-1.0) = 24 => Correct!! In: 5665; Out: 5.0*(6.0-6.0/5.0) = 24 => Correct!! In: 6533; Out: (6.0+5.0-3.0)*3.0 = 24 => Correct!! In: 9156; Out: (9.0-1.0*5.0)*6.0 = 24 => Correct!! In: 1064; Out: (1.0+0.0)*6.0*4.0 = 24 => Correct!! In: 0167; Out: = => Correct!! In: 3477; Out: (3.0+4.0*7.0)-7.0 = 24 => Correct!! In: 1289; Out: (8.0*9.0)/(2.0+1.0) = 24 => Correct!! In: 3377; Out: (3.0+3.0/7.0)*7.0 = 24 => Correct!!
kix32 Kixgolf3.kix $f=junk.kix
KixGolf score = 472
code:
function game24($a,$b,$c,$d)
Dim $h, $j, $l, $p, $q, $r, $s, $t, $v, $, $x, $y, $z $h = "+","-","/","*" for $z=1 to 4 for $y=1 to 4 for $x=1 to 4 for each $p in $h for each $q in $h for each $r in $h for each $j in split("0,8~0,8,10,18~0,12~4,16","~") $ = ".0" $s = ""+$a+$+$p+$b+$+$q+$c+$+$r+$d+$ for each $ in split($j,",") $l = chr(40 + ($l="(")) $s = "" + left($s,$) + $l + substr($s,1+$) next $t = execute("$$v=$s") if abs($v-24)< 1E-9 goto E endif next next next next $ = $b $b = $c $c = $d $d = $ next $ = $a $a = $b $b = $ next $ = $c $c = $d $d = $ next $s = ""
:E $game24 = $s exit endfunction
|
|
Re: KixGolf Results/Code
|
|
Nice work, Howard! However... You're only generating 18 unique permutations... What does that mean? It means that there are some unique combos out there that will byte you!! Coming up with an example soon... You're only generating half the "c"'s and half the "d"'s, that is:
code:
abcd abdc acbd acdb adbc adcb bacd badc bcad bcda bdac bdca cadb cbad cdba dacb dbac dcba
An example that will byte you: 1346... [ 24. September 2002, 02:26: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
Man! This Madruga guy is a real pain! Sorry about that folks...
|
|
Re: KixGolf Results/Code
|
|
Beat you - 24 permutations (if my Perl hash can count right.)
code:
use strict; my %d;
&a(1,2,3,4); print scalar (keys %d) ."\n"; foreach my $x (sort keys %d) { print "$x\n"; }
sub a($a,$b,$c,$d) { my ($a,$b,$c,$d)=@_; my $z; for (my $i = 1; $i <=4; $i++) { for (my $j = 1; $j <=6; $j++) { for (my $k = 1; $k <=4; $k++) { $d{"$a,$b,$c,$d"}=1; $z = $b; $b = $c; $c = $d; $d = $z; } $z = $a; $a = $b; $b = $z; } $z = $c; $c = $d; $d = $z; } }
c:\data\scripts>junk.pl 24 1,2,3,4 1,2,4,3 1,3,2,4 1,3,4,2 1,4,2,3 1,4,3,2 2,1,3,4 2,1,4,3 2,3,1,4 2,3,4,1 2,4,1,3 2,4,3,1 3,1,2,4 3,1,4,2 3,2,1,4 3,2,4,1 3,4,1,2 3,4,2,1 4,1,2,3 4,1,3,2 4,2,1,3 4,2,3,1 4,3,1,2 4,3,2,1
code:
function game24($a,$b,$c,$d)
Dim $h, $j, $l, $p, $q, $r, $s, $t, $v, $, $x, $y, $z $h = "+","-","/","*" for $z=1 to 4 for $y=1 to 6 for $x=1 to 4 for each $p in $h for each $q in $h for each $r in $h for each $j in split("0,8~0,8,10,18~0,12~4,16","~") $ = ".0" $s = ""+$a+$+$p+$b+$+$q+$c+$+$r+$d+$ for each $ in split($j,",") $l = chr(40 + ($l="(")) $s = "" + left($s,$) + $l + substr($s,1+$) next $t = execute("$$v=$s") if abs($v-24)< 1E-9 goto E endif next next next next $ = $b $b = $c $c = $d $d = $ next $ = $a $a = $b $b = $ next $ = $c $c = $d $d = $ next $s = ""
:E $game24 = $s exit endfunction
[ 24. September 2002, 02:53: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
HURRA! You did it! (Even if it was at the cost of processor muscle: you're wasting loads of cycles, going through 4 times as much (96 vs 24) permutations as needed, but it DOES work! And it does comply with the requirements! ) {edit} I did some timing: 30 calculations in 3'2" equals aprox. 10 calculations per minute... If we consider 10.000 possible 4 digit numbers, we'd need (on my PIII@1.1GHz) aprox. 1.000 minutes to go through all the combinations! That amounts to almost 17 hours!!! So, figuring this one out is out of the question!!! {/edit} [ 24. September 2002, 03:09: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
BTW, Howard: you can save one byte by changing this: code:
if abs($v-24)< 1E-9
into this:
code:
if abs($v-24)< 0.1
|
|
Re: KixGolf Results/Code
|
|
I am looking to save a little more than that.
|
|
Re: KixGolf Results/Code
|
|
Tripled performance. 33 number sets in 52 seconds. on PIII 850 Mhz.
code:
Game24 v 1.1 KiXtart Golf running under KiXtart v4.11
In: 1346; Out: 6.0/(1.0-3.0/4.0) = 24 => Correct!! In: 3388; Out: 8.0/(3.0-8.0/3.0) = 24 => Correct!! In: 5555; Out: (5.0*5.0)-5.0/5.0 = 24 => Correct!! In: 4971; Out: (4.0-7.0)*(1.0-9.0) = 24 => Correct!! In: 6143; Out: 6.0/(1.0-3.0/4.0) = 24 => Correct!! In: 6451; Out: 6.0/(5.0/4.0-1.0) = 24 => Correct!! In: 4429; Out: (9.0-2.0)*4.0-4.0 = 24 => Correct!! In: 1234; Out: (1.0+2.0+3.0)*4.0 = 24 => Correct!! In: 2268; Out: (2.0+2.0*8.0)+6.0 = 24 => Correct!! In: 4466; Out: = => Correct!! In: 0206; Out: = => Correct!! In: 2219; Out: 2.0*(2.0+1.0+9.0) = 24 => Correct!! In: 4707; Out: = => Correct!! In: 4818; Out: (4.0*8.0)-1.0*8.0 = 24 => Correct!! In: 2827; Out: (2.0+8.0)+2.0*7.0 = 24 => Correct!! In: 5669; Out: (6.0*9.0)-5.0*6.0 = 24 => Correct!! In: 9504; Out: = => Correct!! In: 5865; Out: (5.0+8.0)+6.0+5.0 = 24 => Correct!! In: 3600; Out: = => Correct!! In: 5581; Out: = => Correct!! In: 6149; Out: 6.0*(9.0-1.0-4.0) = 24 => Correct!! In: 7742; Out: (7.0+7.0)*2.0-4.0 = 24 => Correct!! In: 1972; Out: (1.0+9.0)+7.0*2.0 = 24 => Correct!! In: 2605; Out: = => Correct!! In: 2622; Out: = => Correct!! In: 4004; Out: = => Correct!! In: 3696; Out: (3.0+6.0)+9.0+6.0 = 24 => Correct!! In: 0461; Out: (0.0+4.0)*6.0/1.0 = 24 => Correct!! In: 7631; Out: (7.0+6.0*3.0)-1.0 = 24 => Correct!! In: 6452; Out: (6.0+4.0*5.0)-2.0 = 24 => Correct!! In: 3477; Out: (3.0+4.0*7.0)-7.0 = 24 => Correct!! In: 1289; Out: (2.0*8.0)+9.0-1.0 = 24 => Correct!! In: 3377; Out: (3.0+3.0/7.0)*7.0 = 24 => Correct!!
Time = 51885 ticks kix32 Kixgolf3.kix $f=junk.kix
KixGolf score = 472
code:
function game24($a,$b,$c,$d)
Dim $h, $j, $l, $p, $q, $r, $s, $t, $v, $, $x, $y, $z $h = "+","-","/","*" for $z=1 to 4 for $y=1 to 4 for $x=1 to 2 for each $p in $h for each $q in $h for each $r in $h for each $j in split("0,8~0,8,10,18~0,12~4,16","~") $ = ".0" $s = ""+$a+$+$p+$b+$+$q+$c+$+$r+$d+$ for each $ in split($j,",") $l = chr(40 + ($l="(")) $s = "" + left($s,$) + $l + substr($s,1+$) next $t = execute("$$v=$s") if abs($v-24)< 1E-9 goto E endif next next next next $ = $c $c = $d $d = $ next $ = $b $b = $c $c = $d $d = $ next $ = $a $a = $d $d = $ next $s = ""
:E $game24 = $s exit endfunction
[ 24. September 2002, 03:50: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
Fernando, cat got your tongue? [ 24. September 2002, 04:16: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
Wow, this has moved on since I've been away.
I knew my code failed quite a few of the combinations, but I asked Jens to post it for me as I didn't have time to fix it and I thought you might be interested in the recursive function call for phase 2 of the game.
To test it I ran it through all 9999 iterations and then eliminated the duplicates to get a count. No out-of-memory errors on 4.11 RC1
|
|
Re: KixGolf Results/Code
|
|
Nope. Neither of my two cats ate my tongue... I just had nothing more to say! Although it was a nice boost! I've been busy working on my own code... BTW: Do you mind if I "borrow" your parenthesis generation code? [ 24. September 2002, 12:09: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
All's fair in phase two. Beg, borrow, and steal. All code is fair game.
|
|
Re: KixGolf Results/Code
|
|
Richard,
I don't think you need 10,000 combos for validation won't this give all the valid combos:
code:
for $a=0 to 9 for $b=$a to 9 for $c=$b to 9 for $d=$c to 9 $m=Test24($a,$b,$c,$d) next next next next
Howard,
If you use a split like richard did for defining the operator array don't you save 2 characters? [ 24. September 2002, 14:57: Message edited by: Jack Lothian ]
|
|
Re: KixGolf Results/Code
|
|
Yes you do: some programs have demonstrated that the permutation logic is not working ok, so feeding them 1234 is not the same as feeding 2134 or any other permutation.
|
|
Re: KixGolf Results/Code
|
|
Jack, no I don't, in fact it adds a character. $e=Split("+ - * /") = 19 spaces inside quotes are counted.
$h = "+","-","/","*" = 18
|
|
Re: KixGolf Results/Code
|
|
Does kixgolf count the spaces inside the quotes?
|
|
Re: KixGolf Results/Code
|
|
Yes. Turn on the KixGolf debug (;~) and look at the log.
|
Lonkero
|
(KiX Master Guru)
|
2002-09-24 04:15 PM
|
|
|
|
|
Re: KixGolf Results/Code
|
|
yes, if not the code has been changed... it should anyway...
test it.
|
|
Re: KixGolf Results/Code
|
|
Thanks - just goes to show assumptions should always be tested.
|
|
Re: KixGolf Results/Code
|
|
As always, these little adventures benefit everyone.
So far this exercise has educated many of us.
It has also asisted in locating 1 KiXtart bug and pointing to another behavior that might prove to be a bug.
|
|
Re: KixGolf Results/Code
|
|
Madruga
quote:
Yes you do: some programs have demonstrated that the permutation logic is not working ok, so feeding them 1234 is not the same as feeding 2134 or any other permutation.
Generating all 10,000 variation of the numbers combos will not in general help if you have logic errors in your script. As an example, generating all 10,000 will not help identify missing parenthesis or operator combos. I am not sure if it will help with the rounding or zero division problems either.
Code validation is a serious challange in this competition. Many of your tests & analysis have been very helpful in this regard.
|
|
Re: KixGolf Results/Code
|
|
Well, if what you're after is some "quick yet exhaustive" test in order to set your code straight, I'd sugest testing for some known unique solutions. That will give you something to start, and when the code is passing all those fixed tests, you can move on to the "larger" validation... I can post a set of such unique solutions, if you guys want...
|
|
Re: KixGolf Results/Code
|
|
Many of your previous analysis have been helpful so why not. For me though it not a big issue since I have accepted that Richard & Howard are way out in front & I have taken on the role of kibitser.
|
|
Re: KixGolf Results/Code
|
|
I have amended my script to add in some parentheses which I removed after Madruger's analysis but, as was shown, at least one of (ab)cd, a(bc)d or ab(cd) is required [ie (1+1)*9+6]. (added 4 strokes, but removed 4 quoted spaces to leave score unchanged!)
Is the second possable kixtart bug to do with using QUIT within a udf? I used RETURN as QUIT quit the entire script, not just the udf.
|
|
Re: KixGolf Results/Code
|
|
The second bug invloves a goto from within a nested "FOR" loop. the bug is discussed in more detail here: GOTO/Endfunction BUG
|
|
Re: KixGolf Results/Code
|
|
The function of Quit isn't an error since the manual states this was the intented purpose of Quit (i.e "Exits Kixtart"). It was intented to have a different function from return.
|
Waltz
|
(Seasoned Scripter)
|
2002-09-24 08:26 PM
|
|
|
|
|
Re: KixGolf Results/Code
|
|
Anyone burned out and needing some Mini Putt relief? Mini Putt
|
|
Re: KixGolf Results/Code
|
|
Waltz,
Cute, but there is something wrong with their physics formulaes. When you hit the ball hard the ball comes off the wall in really weird directions. It can come off the wall in a 90 degree angle even when it hits at a 45 degree angle.
This is done by MIT? Maybe they introduce random spins on the ball. [ 24. September 2002, 20:44: Message edited by: Jack Lothian ]
|
Waltz
|
(Seasoned Scripter)
|
2002-09-24 08:46 PM
|
|
|
|
|
Re: KixGolf Results/Code
|
|
Well, it's been my observation that golf and beer go hand-in-hand more often than not...
|
|
Re: KixGolf Results/Code
|
|
Yes, a beer would help.
|
|
Re: KixGolf Results/Code
|
|
AJH: you're right about the 1169! I don't know how I missed that one! So, that one is DEFINITELY going into the new test program...
|
|
Re: KixGolf Results/Code
|
|
Madruga,
I wrote an algorithm that uses integer math to get the solutions & it get different results from your analysis. I get 466 solution sets not 465 & it seems 6 of the 7 parenthesis types are necessary to derive all the solutions. {The only type not necessary is a (b c) d)}
I made a few modifications & I am rerunning the test. I will let you know the results. My first pass suggests this is the complete solution set.
code:
In => 0, 0, 0, 0; Out => In => 0, 0, 0, 1; Out => In => 0, 0, 0, 2; Out => In => 0, 0, 0, 3; Out => In => 0, 0, 0, 4; Out => In => 0, 0, 0, 5; Out => In => 0, 0, 0, 6; Out => In => 0, 0, 0, 7; Out => In => 0, 0, 0, 8; Out => In => 0, 0, 0, 9; Out => In => 0, 0, 1, 1; Out => In => 0, 0, 1, 2; Out => In => 0, 0, 1, 3; Out => In => 0, 0, 1, 4; Out => In => 0, 0, 1, 5; Out => In => 0, 0, 1, 6; Out => In => 0, 0, 1, 7; Out => In => 0, 0, 1, 8; Out => In => 0, 0, 1, 9; Out => In => 0, 0, 2, 2; Out => In => 0, 0, 2, 3; Out => In => 0, 0, 2, 4; Out => In => 0, 0, 2, 5; Out => In => 0, 0, 2, 6; Out => In => 0, 0, 2, 7; Out => In => 0, 0, 2, 8; Out => In => 0, 0, 2, 9; Out => In => 0, 0, 3, 3; Out => In => 0, 0, 3, 4; Out => In => 0, 0, 3, 5; Out => In => 0, 0, 3, 6; Out => In => 0, 0, 3, 7; Out => In => 0, 0, 3, 8; Out => 0 + 0 + 3 * 8 In => 0, 0, 3, 9; Out => In => 0, 0, 4, 4; Out => In => 0, 0, 4, 5; Out => In => 0, 0, 4, 6; Out => 0 + 0 + 4 * 6 In => 0, 0, 4, 7; Out => In => 0, 0, 4, 8; Out => In => 0, 0, 4, 9; Out => In => 0, 0, 5, 5; Out => In => 0, 0, 5, 6; Out => In => 0, 0, 5, 7; Out => In => 0, 0, 5, 8; Out => In => 0, 0, 5, 9; Out => In => 0, 0, 6, 6; Out => In => 0, 0, 6, 7; Out => In => 0, 0, 6, 8; Out => In => 0, 0, 6, 9; Out => In => 0, 0, 7, 7; Out => In => 0, 0, 7, 8; Out => In => 0, 0, 7, 9; Out => In => 0, 0, 8, 8; Out => In => 0, 0, 8, 9; Out => In => 0, 0, 9, 9; Out => In => 0, 1, 1, 1; Out => In => 0, 1, 1, 2; Out => In => 0, 1, 1, 3; Out => In => 0, 1, 1, 4; Out => In => 0, 1, 1, 5; Out => In => 0, 1, 1, 6; Out => In => 0, 1, 1, 7; Out => In => 0, 1, 1, 8; Out => In => 0, 1, 1, 9; Out => In => 0, 1, 2, 2; Out => In => 0, 1, 2, 3; Out => In => 0, 1, 2, 4; Out => In => 0, 1, 2, 5; Out => In => 0, 1, 2, 6; Out => In => 0, 1, 2, 7; Out => In => 0, 1, 2, 8; Out => ( 0 + 1 + 2 ) * 8 In => 0, 1, 2, 9; Out => In => 0, 1, 3, 3; Out => In => 0, 1, 3, 4; Out => In => 0, 1, 3, 5; Out => In => 0, 1, 3, 6; Out => ( 0 + 1 + 3 ) * 6 In => 0, 1, 3, 7; Out => ( 0 + 1 + 7 ) * 3 In => 0, 1, 3, 8; Out => 0 + 1 * 3 * 8 In => 0, 1, 3, 9; Out => ( 0 - 1 + 9 ) * 3 In => 0, 1, 4, 4; Out => In => 0, 1, 4, 5; Out => ( 0 + 1 + 5 ) * 4 In => 0, 1, 4, 6; Out => 0 + 1 * 4 * 6 In => 0, 1, 4, 7; Out => ( 0 - 1 + 7 ) * 4 In => 0, 1, 4, 8; Out => ( 0 - 1 + 4 ) * 8 In => 0, 1, 4, 9; Out => In => 0, 1, 5, 5; Out => 0 - 1 + 5 * 5 In => 0, 1, 5, 6; Out => ( 0 - 1 + 5 ) * 6 In => 0, 1, 5, 7; Out => In => 0, 1, 5, 8; Out => In => 0, 1, 5, 9; Out => In => 0, 1, 6, 6; Out => In => 0, 1, 6, 7; Out => In => 0, 1, 6, 8; Out => In => 0, 1, 6, 9; Out => In => 0, 1, 7, 7; Out => In => 0, 1, 7, 8; Out => In => 0, 1, 7, 9; Out => In => 0, 1, 8, 8; Out => In => 0, 1, 8, 9; Out => In => 0, 1, 9, 9; Out => In => 0, 2, 2, 2; Out => In => 0, 2, 2, 3; Out => In => 0, 2, 2, 4; Out => In => 0, 2, 2, 5; Out => In => 0, 2, 2, 6; Out => 0 + 2 * 2 * 6 In => 0, 2, 2, 7; Out => In => 0, 2, 2, 8; Out => In => 0, 2, 2, 9; Out => In => 0, 2, 3, 3; Out => In => 0, 2, 3, 4; Out => 0 + 2 * 3 * 4 In => 0, 2, 3, 5; Out => In => 0, 2, 3, 6; Out => ( 0 + 2 + 6 ) * 3 In => 0, 2, 3, 7; Out => In => 0, 2, 3, 8; Out => 0 / 2 + 3 * 8 In => 0, 2, 3, 9; Out => ( 0 + 3 + 9 ) * 2 In => 0, 2, 4, 4; Out => ( 0 + 2 + 4 ) * 4 In => 0, 2, 4, 5; Out => In => 0, 2, 4, 6; Out => 0 / 2 + 4 * 6 In => 0, 2, 4, 7; Out => In => 0, 2, 4, 8; Out => ( 0 - 2 + 8 ) * 4 In => 0, 2, 4, 9; Out => In => 0, 2, 5, 5; Out => In => 0, 2, 5, 6; Out => In => 0, 2, 5, 7; Out => ( 0 + 5 + 7 ) * 2 In => 0, 2, 5, 8; Out => ( 0 - 2 + 5 ) * 8 In => 0, 2, 5, 9; Out => In => 0, 2, 6, 6; Out => ( 0 - 2 + 6 ) * 6 In => 0, 2, 6, 7; Out => In => 0, 2, 6, 8; Out => 0 + 6 * 8 / 2 In => 0, 2, 6, 9; Out => 0 + 2 * 9 + 6 In => 0, 2, 7, 7; Out => In => 0, 2, 7, 8; Out => In => 0, 2, 7, 9; Out => In => 0, 2, 8, 8; Out => 0 + 2 * 8 + 8 In => 0, 2, 8, 9; Out => In => 0, 2, 9, 9; Out => In => 0, 3, 3, 3; Out => In => 0, 3, 3, 4; Out => ( 0 + 3 + 3 ) * 4 In => 0, 3, 3, 5; Out => ( 0 + 3 + 5 ) * 3 In => 0, 3, 3, 6; Out => In => 0, 3, 3, 7; Out => 0 + 3 + 3 * 7 In => 0, 3, 3, 8; Out => 0 / 3 + 3 * 8 In => 0, 3, 3, 9; Out => 0 - 3 + 3 * 9 In => 0, 3, 4, 4; Out => ( 0 + 4 + 4 ) * 3 In => 0, 3, 4, 5; Out => In => 0, 3, 4, 6; Out => 0 / 3 + 4 * 6 In => 0, 3, 4, 7; Out => In => 0, 3, 4, 8; Out => 0 / 4 + 8 * 3 In => 0, 3, 4, 9; Out => ( 0 - 3 + 9 ) * 4 In => 0, 3, 5, 5; Out => In => 0, 3, 5, 6; Out => In => 0, 3, 5, 7; Out => In => 0, 3, 5, 8; Out => 0 / 5 + 8 * 3 In => 0, 3, 5, 9; Out => 0 + 3 * 5 + 9 In => 0, 3, 6, 6; Out => 0 + 3 * 6 + 6 In => 0, 3, 6, 7; Out => ( 0 - 3 + 7 ) * 6 In => 0, 3, 6, 8; Out => 0 / 6 + 8 * 3 In => 0, 3, 6, 9; Out => In => 0, 3, 7, 7; Out => In => 0, 3, 7, 8; Out => 0 / 7 + 8 * 3 In => 0, 3, 7, 9; Out => In => 0, 3, 8, 8; Out => 0 / 8 + 8 * 3 In => 0, 3, 8, 9; Out => 0 + 8 * 9 / 3 In => 0, 3, 9, 9; Out => In => 0, 4, 4, 4; Out => In => 0, 4, 4, 5; Out => 0 + 4 + 4 * 5 In => 0, 4, 4, 6; Out => 0 / 4 + 4 * 6 In => 0, 4, 4, 7; Out => 0 - 4 + 4 * 7 In => 0, 4, 4, 8; Out => 0 + 4 * 4 + 8 In => 0, 4, 4, 9; Out => In => 0, 4, 5, 5; Out => In => 0, 4, 5, 6; Out => 0 / 5 + 6 * 4 In => 0, 4, 5, 7; Out => In => 0, 4, 5, 8; Out => In => 0, 4, 5, 9; Out => In => 0, 4, 6, 6; Out => 0 / 6 + 6 * 4 In => 0, 4, 6, 7; Out => 0 / 7 + 4 * 6 In => 0, 4, 6, 8; Out => 0 / 8 + 4 * 6 In => 0, 4, 6, 9; Out => 0 / 9 + 4 * 6 In => 0, 4, 7, 7; Out => In => 0, 4, 7, 8; Out => ( 0 - 4 + 7 ) * 8 In => 0, 4, 7, 9; Out => In => 0, 4, 8, 8; Out => 0 + 4 * 8 - 8 In => 0, 4, 8, 9; Out => In => 0, 4, 9, 9; Out => In => 0, 5, 5, 5; Out => In => 0, 5, 5, 6; Out => In => 0, 5, 5, 7; Out => In => 0, 5, 5, 8; Out => In => 0, 5, 5, 9; Out => In => 0, 5, 6, 6; Out => 0 + 5 * 6 - 6 In => 0, 5, 6, 7; Out => In => 0, 5, 6, 8; Out => In => 0, 5, 6, 9; Out => ( 0 - 5 + 9 ) * 6 In => 0, 5, 7, 7; Out => In => 0, 5, 7, 8; Out => In => 0, 5, 7, 9; Out => In => 0, 5, 8, 8; Out => ( 0 - 5 + 8 ) * 8 In => 0, 5, 8, 9; Out => In => 0, 5, 9, 9; Out => In => 0, 6, 6, 6; Out => In => 0, 6, 6, 7; Out => In => 0, 6, 6, 8; Out => In => 0, 6, 6, 9; Out => In => 0, 6, 7, 7; Out => In => 0, 6, 7, 8; Out => In => 0, 6, 7, 9; Out => In => 0, 6, 8, 8; Out => In => 0, 6, 8, 9; Out => ( 0 - 6 + 9 ) * 8 In => 0, 6, 9, 9; Out => 0 + 6 + 9 + 9 In => 0, 7, 7, 7; Out => In => 0, 7, 7, 8; Out => In => 0, 7, 7, 9; Out => In => 0, 7, 8, 8; Out => In => 0, 7, 8, 9; Out => 0 + 7 + 8 + 9 In => 0, 7, 9, 9; Out => In => 0, 8, 8, 8; Out => 0 + 8 + 8 + 8 In => 0, 8, 8, 9; Out => In => 0, 8, 9, 9; Out => In => 0, 9, 9, 9; Out => In => 1, 1, 1, 1; Out => In => 1, 1, 1, 2; Out => In => 1, 1, 1, 3; Out => In => 1, 1, 1, 4; Out => In => 1, 1, 1, 5; Out => In => 1, 1, 1, 6; Out => In => 1, 1, 1, 7; Out => In => 1, 1, 1, 8; Out => ( 1 + 1 + 1 ) * 8 In => 1, 1, 1, 9; Out => In => 1, 1, 2, 2; Out => In => 1, 1, 2, 3; Out => In => 1, 1, 2, 4; Out => In => 1, 1, 2, 5; Out => In => 1, 1, 2, 6; Out => ( 1 + 1 + 2 ) * 6 In => 1, 1, 2, 7; Out => ( 1 + 2 ) * ( 7 + 1 ) In => 1, 1, 2, 8; Out => ( 1 + 1 * 2 ) * 8 In => 1, 1, 2, 9; Out => ( 1 + 2 ) * ( 9 - 1 ) In => 1, 1, 3, 3; Out => In => 1, 1, 3, 4; Out => 3 * 4 * ( 1 + 1 ) In => 1, 1, 3, 5; Out => ( 1 + 3 ) * ( 5 + 1 ) In => 1, 1, 3, 6; Out => ( 1 + 1 * 3 ) * 6 In => 1, 1, 3, 7; Out => ( 1 + 1 * 7 ) * 3 In => 1, 1, 3, 8; Out => 1 - 1 + 3 * 8 In => 1, 1, 3, 9; Out => ( 1 * 9 - 1 ) * 3 In => 1, 1, 4, 4; Out => ( 1 + 1 + 4 ) * 4 In => 1, 1, 4, 5; Out => ( 1 + 1 * 5 ) * 4 In => 1, 1, 4, 6; Out => 1 - 1 + 4 * 6 In => 1, 1, 4, 7; Out => ( 1 * 7 - 1 ) * 4 In => 1, 1, 4, 8; Out => ( 1 * 4 - 1 ) * 8 In => 1, 1, 4, 9; Out => ( 1 - 4 ) * ( 1 - 9 ) In => 1, 1, 5, 5; Out => 1 * 5 * 5 - 1 In => 1, 1, 5, 6; Out => ( 1 * 5 - 1 ) * 6 In => 1, 1, 5, 7; Out => ( 1 + 1 ) * ( 5 + 7 ) In => 1, 1, 5, 8; Out => ( 5 - 1 - 1 ) * 8 In => 1, 1, 5, 9; Out => In => 1, 1, 6, 6; Out => ( 6 - 1 - 1 ) * 6 In => 1, 1, 6, 7; Out => In => 1, 1, 6, 8; Out => 6 * 8 / ( 1 + 1 ) In => 1, 1, 6, 9; Out => 6 + 9 * ( 1 + 1 ) In => 1, 1, 7, 7; Out => In => 1, 1, 7, 8; Out => In => 1, 1, 7, 9; Out => In => 1, 1, 8, 8; Out => 8 + 8 * ( 1 + 1 ) In => 1, 1, 8, 9; Out => In => 1, 1, 9, 9; Out => In => 1, 2, 2, 2; Out => In => 1, 2, 2, 3; Out => In => 1, 2, 2, 4; Out => 2 * 4 * ( 1 + 2 ) In => 1, 2, 2, 5; Out => 2 * 2 * ( 5 + 1 ) In => 1, 2, 2, 6; Out => 1 * 2 * 2 * 6 In => 1, 2, 2, 7; Out => 2 * 2 * ( 7 - 1 ) In => 1, 2, 2, 8; Out => ( 2 + 2 - 1 ) * 8 In => 1, 2, 2, 9; Out => ( 1 + 2 + 9 ) * 2 In => 1, 2, 3, 3; Out => 2 * 3 * ( 3 + 1 ) In => 1, 2, 3, 4; Out => 1 * 2 * 3 * 4 In => 1, 2, 3, 5; Out => ( 1 + 2 + 5 ) * 3 In => 1, 2, 3, 6; Out => ( 1 * 2 + 6 ) * 3 In => 1, 2, 3, 7; Out => 1 + 2 + 3 * 7 In => 1, 2, 3, 8; Out => ( 1 + 3 + 8 ) * 2 In => 1, 2, 3, 9; Out => 3 * 9 - 1 - 2 In => 1, 2, 4, 4; Out => ( 1 * 2 + 4 ) * 4 In => 1, 2, 4, 5; Out => ( 2 + 5 - 1 ) * 4 In => 1, 2, 4, 6; Out => 4 * 6 / ( 2 - 1 ) In => 1, 2, 4, 7; Out => ( 1 - 2 + 7 ) * 4 In => 1, 2, 4, 8; Out => ( 1 - 2 + 4 ) * 8 In => 1, 2, 4, 9; Out => ( 4 + 9 - 1 ) * 2 In => 1, 2, 5, 5; Out => 1 - 2 + 5 * 5 In => 1, 2, 5, 6; Out => ( 1 - 2 + 5 ) * 6 In => 1, 2, 5, 7; Out => ( 1 * 5 + 7 ) * 2 In => 1, 2, 5, 8; Out => ( 1 * 5 - 2 ) * 8 In => 1, 2, 5, 9; Out => 1 + 2 * 9 + 5 In => 1, 2, 6, 6; Out => ( 1 * 6 + 6 ) * 2 In => 1, 2, 6, 7; Out => ( 6 + 7 - 1 ) * 2 In => 1, 2, 6, 8; Out => 1 / 2 * 6 * 8 In => 1, 2, 6, 9; Out => 1 * 2 * 9 + 6 In => 1, 2, 7, 7; Out => ( 7 * 7 - 1 ) / 2 In => 1, 2, 7, 8; Out => 1 + 2 * 8 + 7 In => 1, 2, 7, 9; Out => 1 + 2 * 7 + 9 In => 1, 2, 8, 8; Out => 1 * 2 * 8 + 8 In => 1, 2, 8, 9; Out => 2 * 8 + 9 - 1 In => 1, 2, 9, 9; Out => In => 1, 3, 3, 3; Out => ( 3 * 3 - 1 ) * 3 In => 1, 3, 3, 4; Out => ( 1 * 3 + 3 ) * 4 In => 1, 3, 3, 5; Out => ( 1 * 3 + 5 ) * 3 In => 1, 3, 3, 6; Out => ( 3 + 6 - 1 ) * 3 In => 1, 3, 3, 7; Out => 1 * 3 + 3 * 7 In => 1, 3, 3, 8; Out => 3 + 3 * ( 8 - 1 ) In => 1, 3, 3, 9; Out => 1 * 3 * 9 - 3 In => 1, 3, 4, 4; Out => ( 1 * 4 + 4 ) * 3 In => 1, 3, 4, 5; Out => 1 + 3 + 4 * 5 In => 1, 3, 4, 6; Out => 6 / ( 1 - 3 / 4 ) In => 1, 3, 4, 7; Out => 3 * 7 - 1 + 4 In => 1, 3, 4, 8; Out => ( 1 - 3 + 8 ) * 4 In => 1, 3, 4, 9; Out => 1 + 3 * 9 - 4 In => 1, 3, 5, 5; Out => In => 1, 3, 5, 6; Out => 1 + 3 * 6 + 5 In => 1, 3, 5, 7; Out => ( 1 + 5 ) * ( 7 - 3 ) In => 1, 3, 5, 8; Out => 1 + 3 * 5 + 8 In => 1, 3, 5, 9; Out => 1 * 3 * 5 + 9 In => 1, 3, 6, 6; Out => 1 * 3 * 6 + 6 In => 1, 3, 6, 7; Out => 3 * 6 + 7 - 1 In => 1, 3, 6, 8; Out => ( 1 + 6 / 3 ) * 8 In => 1, 3, 6, 9; Out => ( 1 + 9 / 3 ) * 6 In => 1, 3, 7, 7; Out => ( 1 - 7 ) * ( 3 - 7 ) In => 1, 3, 7, 8; Out => ( 7 - 1 - 3 ) * 8 In => 1, 3, 7, 9; Out => 9 / 3 * ( 1 + 7 ) In => 1, 3, 8, 8; Out => 8 - 8 * ( 1 - 3 ) In => 1, 3, 8, 9; Out => 1 / 3 * 8 * 9 In => 1, 3, 9, 9; Out => 9 / 3 * ( 9 - 1 ) In => 1, 4, 4, 4; Out => 4 + 4 * ( 4 + 1 ) In => 1, 4, 4, 5; Out => 1 * 4 + 4 * 5 In => 1, 4, 4, 6; Out => 4 + 4 * ( 6 - 1 ) In => 1, 4, 4, 7; Out => 1 + 4 * 4 + 7 In => 1, 4, 4, 8; Out => 1 * 4 * 4 + 8 In => 1, 4, 4, 9; Out => 4 * 4 + 9 - 1 In => 1, 4, 5, 5; Out => 4 * 5 + 5 - 1 In => 1, 4, 5, 6; Out => 4 / ( 1 - 5 / 6 ) In => 1, 4, 5, 7; Out => 1 + 4 * 7 - 5 In => 1, 4, 5, 8; Out => 8 - 4 * ( 1 - 5 ) In => 1, 4, 5, 9; Out => 9 - 5 * ( 1 - 4 ) In => 1, 4, 6, 6; Out => 6 - 6 * ( 1 - 4 ) In => 1, 4, 6, 7; Out => ( 1 - 4 + 7 ) * 6 In => 1, 4, 6, 8; Out => ( 1 - 4 + 6 ) * 8 In => 1, 4, 6, 9; Out => ( 9 - 1 - 4 ) * 6 In => 1, 4, 7, 7; Out => ( 1 + 7 ) * ( 7 - 4 ) In => 1, 4, 7, 8; Out => 4 * 8 - 1 - 7 In => 1, 4, 7, 9; Out => ( 1 - 9 ) * ( 4 - 7 ) In => 1, 4, 8, 8; Out => 1 * 4 * 8 - 8 In => 1, 4, 8, 9; Out => 1 + 4 * 8 - 9 In => 1, 4, 9, 9; Out => In => 1, 5, 5, 5; Out => ( 5 - 1 / 5 ) * 5 In => 1, 5, 5, 6; Out => 5 * 6 - 1 - 5 In => 1, 5, 5, 7; Out => In => 1, 5, 5, 8; Out => In => 1, 5, 5, 9; Out => ( 1 + 5 ) * ( 9 - 5 ) In => 1, 5, 6, 6; Out => 1 * 5 * 6 - 6 In => 1, 5, 6, 7; Out => 1 + 5 * 6 - 7 In => 1, 5, 6, 8; Out => ( 1 - 5 + 8 ) * 6 In => 1, 5, 6, 9; Out => ( 1 * 9 - 5 ) * 6 In => 1, 5, 7, 7; Out => In => 1, 5, 7, 8; Out => ( 1 - 5 + 7 ) * 8 In => 1, 5, 7, 9; Out => ( 1 - 7 ) * ( 5 - 9 ) In => 1, 5, 8, 8; Out => ( 1 * 8 - 5 ) * 8 In => 1, 5, 8, 9; Out => ( 9 - 1 - 5 ) * 8 In => 1, 5, 9, 9; Out => 1 + 5 + 9 + 9 In => 1, 6, 6, 6; Out => ( 6 - 1 ) * 6 - 6 In => 1, 6, 6, 7; Out => In => 1, 6, 6, 8; Out => 6 / ( 1 - 6 / 8 ) In => 1, 6, 6, 9; Out => ( 1 - 6 + 9 ) * 6 In => 1, 6, 7, 7; Out => In => 1, 6, 7, 8; Out => In => 1, 6, 7, 9; Out => ( 1 + 7 ) * ( 9 - 6 ) In => 1, 6, 8, 8; Out => ( 1 - 6 + 8 ) * 8 In => 1, 6, 8, 9; Out => 1 + 6 + 8 + 9 In => 1, 6, 9, 9; Out => 1 * 6 + 9 + 9 In => 1, 7, 7, 7; Out => In => 1, 7, 7, 8; Out => In => 1, 7, 7, 9; Out => 1 + 7 + 7 + 9 In => 1, 7, 8, 8; Out => 1 + 7 + 8 + 8 In => 1, 7, 8, 9; Out => 1 * 7 + 8 + 9 In => 1, 7, 9, 9; Out => 7 + 9 + 9 - 1 In => 1, 8, 8, 8; Out => 1 * 8 + 8 + 8 In => 1, 8, 8, 9; Out => 8 + 8 + 9 - 1 In => 1, 8, 9, 9; Out => In => 1, 9, 9, 9; Out => In => 2, 2, 2, 2; Out => In => 2, 2, 2, 3; Out => 2 * 2 * 2 * 3 In => 2, 2, 2, 4; Out => ( 2 + 2 + 2 ) * 4 In => 2, 2, 2, 5; Out => ( 2 + 2 * 5 ) * 2 In => 2, 2, 2, 6; Out => In => 2, 2, 2, 7; Out => ( 2 * 7 - 2 ) * 2 In => 2, 2, 2, 8; Out => ( 2 + 2 / 2 ) * 8 In => 2, 2, 2, 9; Out => 2 + 2 * ( 2 + 9 ) In => 2, 2, 3, 3; Out => ( 2 + 2 * 3 ) * 3 In => 2, 2, 3, 4; Out => ( 2 + 2 + 4 ) * 3 In => 2, 2, 3, 5; Out => ( 2 * 5 - 2 ) * 3 In => 2, 2, 3, 6; Out => ( 2 / 2 + 3 ) * 6 In => 2, 2, 3, 7; Out => ( 2 / 2 + 7 ) * 3 In => 2, 2, 3, 8; Out => 2 - 2 + 3 * 8 In => 2, 2, 3, 9; Out => 2 * 3 + 9 * 2 In => 2, 2, 4, 4; Out => ( 2 * 4 + 4 ) * 2 In => 2, 2, 4, 5; Out => 2 + 2 + 4 * 5 In => 2, 2, 4, 6; Out => 2 - 2 + 4 * 6 In => 2, 2, 4, 7; Out => 2 * 2 * 7 - 4 In => 2, 2, 4, 8; Out => 2 * 2 * 4 + 8 In => 2, 2, 4, 9; Out => 2 + 2 * 9 + 4 In => 2, 2, 5, 5; Out => 5 * 5 - 2 / 2 In => 2, 2, 5, 6; Out => ( 5 - 2 / 2 ) * 6 In => 2, 2, 5, 7; Out => 2 * 5 + 7 * 2 In => 2, 2, 5, 8; Out => ( 5 + 8 ) * 2 - 2 In => 2, 2, 5, 9; Out => ( 5 + 9 - 2 ) * 2 In => 2, 2, 6, 6; Out => 2 * 6 + 6 * 2 In => 2, 2, 6, 7; Out => 6 + 2 * ( 2 + 7 ) In => 2, 2, 6, 8; Out => 2 + 2 * 8 + 6 In => 2, 2, 6, 9; Out => ( 2 * 9 - 6 ) * 2 In => 2, 2, 7, 7; Out => ( 7 + 7 - 2 ) * 2 In => 2, 2, 7, 8; Out => 2 + 2 * 7 + 8 In => 2, 2, 7, 9; Out => In => 2, 2, 8, 8; Out => 2 * 2 * 8 - 8 In => 2, 2, 8, 9; Out => 2 * 9 - 2 + 8 In => 2, 2, 9, 9; Out => In => 2, 3, 3, 3; Out => ( 2 + 3 + 3 ) * 3 In => 2, 3, 3, 4; Out => In => 2, 3, 3, 5; Out => ( 3 * 5 - 3 ) * 2 In => 2, 3, 3, 6; Out => 2 * 3 + 3 * 6 In => 2, 3, 3, 7; Out => ( 3 + 7 - 2 ) * 3 In => 2, 3, 3, 8; Out => ( 2 + 3 / 3 ) * 8 In => 2, 3, 3, 9; Out => 2 * 9 + 3 + 3 In => 2, 3, 4, 4; Out => 3 * 4 * 4 / 2 In => 2, 3, 4, 5; Out => ( 3 + 4 + 5 ) * 2 In => 2, 3, 4, 6; Out => 2 + 3 * 6 + 4 In => 2, 3, 4, 7; Out => ( 2 - 3 + 7 ) * 4 In => 2, 3, 4, 8; Out => ( 2 - 3 + 4 ) * 8 In => 2, 3, 4, 9; Out => 2 / 3 * 4 * 9 In => 2, 3, 5, 5; Out => 2 - 3 + 5 * 5 In => 2, 3, 5, 6; Out => 2 * 3 * 5 - 6 In => 2, 3, 5, 7; Out => 2 + 3 * 5 + 7 In => 2, 3, 5, 8; Out => 2 * 8 + 3 + 5 In => 2, 3, 5, 9; Out => 2 + 3 * 9 - 5 In => 2, 3, 6, 6; Out => 2 / 3 * 6 * 6 In => 2, 3, 6, 7; Out => 3 + 6 * 7 / 2 In => 2, 3, 6, 8; Out => 3 * 6 + 8 - 2 In => 2, 3, 6, 9; Out => 2 * 6 + 9 + 3 In => 2, 3, 7, 7; Out => 2 * 7 + 7 + 3 In => 2, 3, 7, 8; Out => ( 7 + 8 - 3 ) * 2 In => 2, 3, 7, 9; Out => ( 3 * 7 - 9 ) * 2 In => 2, 3, 8, 8; Out => ( 2 * 8 - 8 ) * 3 In => 2, 3, 8, 9; Out => ( 9 - 2 * 3 ) * 8 In => 2, 3, 9, 9; Out => 2 * 3 + 9 + 9 In => 2, 4, 4, 4; Out => 2 * 4 + 4 * 4 In => 2, 4, 4, 5; Out => ( 2 * 5 - 4 ) * 4 In => 2, 4, 4, 6; Out => 2 + 4 * 4 + 6 In => 2, 4, 4, 7; Out => 2 * 4 * ( 7 - 4 ) In => 2, 4, 4, 8; Out => 2 * 4 * 4 - 8 In => 2, 4, 4, 9; Out => ( 9 - 2 ) * 4 - 4 In => 2, 4, 5, 5; Out => 4 + 2 * ( 5 + 5 ) In => 2, 4, 5, 6; Out => 4 * 5 + 6 - 2 In => 2, 4, 5, 7; Out => 4 / 2 * ( 5 + 7 ) In => 2, 4, 5, 8; Out => 4 + 5 * 8 / 2 In => 2, 4, 5, 9; Out => ( 2 - 5 + 9 ) * 4 In => 2, 4, 6, 6; Out => ( 2 - 4 + 6 ) * 6 In => 2, 4, 6, 7; Out => 2 + 4 * 7 - 6 In => 2, 4, 6, 8; Out => 2 / 4 * 6 * 8 In => 2, 4, 6, 9; Out => 4 * 9 - 2 * 6 In => 2, 4, 7, 7; Out => ( 7 + 7 ) * 2 - 4 In => 2, 4, 7, 8; Out => 4 * 7 - 8 / 2 In => 2, 4, 7, 9; Out => 2 * 4 + 7 + 9 In => 2, 4, 8, 8; Out => 2 * 4 + 8 + 8 In => 2, 4, 8, 9; Out => ( 9 - 2 - 4 ) * 8 In => 2, 4, 9, 9; Out => 2 + 4 + 9 + 9 In => 2, 5, 5, 5; Out => In => 2, 5, 5, 6; Out => In => 2, 5, 5, 7; Out => 2 * 7 + 5 + 5 In => 2, 5, 5, 8; Out => ( 2 + 5 / 5 ) * 8 In => 2, 5, 5, 9; Out => 2 * 5 + 5 + 9 In => 2, 5, 6, 6; Out => ( 2 * 5 - 6 ) * 6 In => 2, 5, 6, 7; Out => 2 * 6 + 7 + 5 In => 2, 5, 6, 8; Out => 2 + 5 * 6 - 8 In => 2, 5, 6, 9; Out => 5 * 6 / 2 + 9 In => 2, 5, 7, 7; Out => 2 * 5 + 7 + 7 In => 2, 5, 7, 8; Out => ( 2 * 5 - 7 ) * 8 In => 2, 5, 7, 9; Out => 5 * 7 - 9 - 2 In => 2, 5, 8, 8; Out => 5 * 8 - 8 * 2 In => 2, 5, 8, 9; Out => 2 + 5 + 8 + 9 In => 2, 5, 9, 9; Out => In => 2, 6, 6, 6; Out => 2 * 6 + 6 + 6 In => 2, 6, 6, 7; Out => ( 6 + 6 * 7 ) / 2 In => 2, 6, 6, 8; Out => ( 2 + 6 / 6 ) * 8 In => 2, 6, 6, 9; Out => ( 6 * 9 - 6 ) / 2 In => 2, 6, 7, 7; Out => In => 2, 6, 7, 8; Out => ( 2 - 6 + 7 ) * 8 In => 2, 6, 7, 9; Out => 2 + 6 + 7 + 9 In => 2, 6, 8, 8; Out => 2 + 6 + 8 + 8 In => 2, 6, 8, 9; Out => 2 / 6 * 8 * 9 In => 2, 6, 9, 9; Out => ( 2 + 6 / 9 ) * 9 In => 2, 7, 7, 7; Out => In => 2, 7, 7, 8; Out => 2 + 7 + 7 + 8 In => 2, 7, 7, 9; Out => In => 2, 7, 8, 8; Out => ( 2 - 7 + 8 ) * 8 In => 2, 7, 8, 9; Out => ( 7 + 9 ) * 2 - 8 In => 2, 7, 9, 9; Out => In => 2, 8, 8, 8; Out => 8 * 8 / 2 - 8 In => 2, 8, 8, 9; Out => ( 2 - 8 + 9 ) * 8 In => 2, 8, 9, 9; Out => 8 + 9 + 9 - 2 In => 2, 9, 9, 9; Out => In => 3, 3, 3, 3; Out => 3 * 3 * 3 - 3 In => 3, 3, 3, 4; Out => ( 3 * 3 - 3 ) * 4 In => 3, 3, 3, 5; Out => 3 * 3 + 3 * 5 In => 3, 3, 3, 6; Out => 3 + 3 + 3 * 6 In => 3, 3, 3, 7; Out => ( 3 / 3 + 7 ) * 3 In => 3, 3, 3, 8; Out => 3 - 3 + 3 * 8 In => 3, 3, 3, 9; Out => ( 9 - 3 / 3 ) * 3 In => 3, 3, 4, 4; Out => 3 * 4 + 4 * 3 In => 3, 3, 4, 5; Out => ( 3 / 3 + 5 ) * 4 In => 3, 3, 4, 6; Out => 3 - 3 + 4 * 6 In => 3, 3, 4, 7; Out => ( 4 + 7 - 3 ) * 3 In => 3, 3, 4, 8; Out => ( 4 - 3 / 3 ) * 8 In => 3, 3, 4, 9; Out => 3 + 3 * 4 + 9 In => 3, 3, 5, 5; Out => 5 * 5 - 3 / 3 In => 3, 3, 5, 6; Out => 3 + 3 * 5 + 6 In => 3, 3, 5, 7; Out => ( 3 * 5 - 7 ) * 3 In => 3, 3, 5, 8; Out => In => 3, 3, 5, 9; Out => ( 5 + 9 / 3 ) * 3 In => 3, 3, 6, 6; Out => ( 6 + 6 / 3 ) * 3 In => 3, 3, 6, 7; Out => 3 * 7 - 3 + 6 In => 3, 3, 6, 8; Out => ( 3 * 3 - 6 ) * 8 In => 3, 3, 6, 9; Out => 3 * 3 + 6 + 9 In => 3, 3, 7, 7; Out => ( 3 + 3 / 7 ) * 7 In => 3, 3, 7, 8; Out => 3 * 3 + 7 + 8 In => 3, 3, 7, 9; Out => 3 + 7 * 9 / 3 In => 3, 3, 8, 8; Out => 8 / ( 3 - 8 / 3 ) In => 3, 3, 8, 9; Out => ( 9 - 3 - 3 ) * 8 In => 3, 3, 9, 9; Out => 3 + 3 + 9 + 9 In => 3, 4, 4, 4; Out => ( 3 + 4 ) * 4 - 4 In => 3, 4, 4, 5; Out => 3 + 4 * 4 + 5 In => 3, 4, 4, 6; Out => ( 3 + 4 / 4 ) * 6 In => 3, 4, 4, 7; Out => ( 3 - 4 + 7 ) * 4 In => 3, 4, 4, 8; Out => 3 / 4 * 4 * 8 In => 3, 4, 4, 9; Out => 4 * 9 - 3 * 4 In => 3, 4, 5, 5; Out => 3 - 4 + 5 * 5 In => 3, 4, 5, 6; Out => ( 3 - 4 + 5 ) * 6 In => 3, 4, 5, 7; Out => 3 * 4 + 5 + 7 In => 3, 4, 5, 8; Out => 4 * 8 - 3 - 5 In => 3, 4, 5, 9; Out => ( 3 * 5 - 9 ) * 4 In => 3, 4, 6, 6; Out => 3 * 4 + 6 + 6 In => 3, 4, 6, 7; Out => In => 3, 4, 6, 8; Out => ( 3 * 4 - 8 ) * 6 In => 3, 4, 6, 9; Out => ( 3 - 6 + 9 ) * 4 In => 3, 4, 7, 7; Out => 3 + 4 * 7 - 7 In => 3, 4, 7, 8; Out => 8 - 4 * ( 3 - 7 ) In => 3, 4, 7, 9; Out => 3 * 9 + 4 - 7 In => 3, 4, 8, 8; Out => In => 3, 4, 8, 9; Out => 3 + 4 + 8 + 9 In => 3, 4, 9, 9; Out => 4 * 9 - 9 - 3 In => 3, 5, 5, 5; Out => In => 3, 5, 5, 6; Out => ( 3 + 5 / 5 ) * 6 In => 3, 5, 5, 7; Out => ( 5 / 5 + 7 ) * 3 In => 3, 5, 5, 8; Out => 3 / 5 * 5 * 8 In => 3, 5, 5, 9; Out => ( 3 + 9 / 5 ) * 5 In => 3, 5, 6, 6; Out => ( 3 - 5 + 6 ) * 6 In => 3, 5, 6, 7; Out => ( 6 + 7 - 5 ) * 3 In => 3, 5, 6, 8; Out => ( 5 - 6 / 3 ) * 8 In => 3, 5, 6, 9; Out => 3 + 5 * 6 - 9 In => 3, 5, 7, 7; Out => In => 3, 5, 7, 8; Out => 3 * 7 + 8 - 5 In => 3, 5, 7, 9; Out => 3 + 5 + 7 + 9 In => 3, 5, 8, 8; Out => 3 + 5 + 8 + 8 In => 3, 5, 8, 9; Out => 3 * 9 + 5 - 8 In => 3, 5, 9, 9; Out => 5 * 9 / 3 + 9 In => 3, 6, 6, 6; Out => ( 3 + 6 / 6 ) * 6 In => 3, 6, 6, 7; Out => 6 * 7 - 3 * 6 In => 3, 6, 6, 8; Out => 3 / 6 * 6 * 8 In => 3, 6, 6, 9; Out => 3 + 6 + 6 + 9 In => 3, 6, 7, 7; Out => ( 3 + 7 / 7 ) * 6 In => 3, 6, 7, 8; Out => 3 + 6 + 7 + 8 In => 3, 6, 7, 9; Out => 3 * 7 + 9 - 6 In => 3, 6, 8, 8; Out => 6 * 8 - 8 * 3 In => 3, 6, 8, 9; Out => ( 3 - 8 + 9 ) * 6 In => 3, 6, 9, 9; Out => 3 * 9 - 9 + 6 In => 3, 7, 7, 7; Out => 3 + 7 + 7 + 7 In => 3, 7, 7, 8; Out => 3 / 7 * 7 * 8 In => 3, 7, 7, 9; Out => ( 9 - 7 / 7 ) * 3 In => 3, 7, 8, 8; Out => ( 7 + 8 / 8 ) * 3 In => 3, 7, 8, 9; Out => ( 7 - 8 + 9 ) * 3 In => 3, 7, 9, 9; Out => ( 7 + 9 / 9 ) * 3 In => 3, 8, 8, 8; Out => 3 / 8 * 8 * 8 In => 3, 8, 8, 9; Out => ( 9 - 8 / 8 ) * 3 In => 3, 8, 9, 9; Out => 3 * 8 + 9 - 9 In => 3, 9, 9, 9; Out => 9 + 9 + 9 - 3 In => 4, 4, 4, 4; Out => 4 + 4 + 4 * 4 In => 4, 4, 4, 5; Out => ( 4 / 4 + 5 ) * 4 In => 4, 4, 4, 6; Out => 4 - 4 + 4 * 6 In => 4, 4, 4, 7; Out => ( 7 - 4 / 4 ) * 4 In => 4, 4, 4, 8; Out => 4 * 8 - 4 - 4 In => 4, 4, 4, 9; Out => 4 - 4 * ( 4 - 9 ) In => 4, 4, 5, 5; Out => 5 * 5 - 4 / 4 In => 4, 4, 5, 6; Out => ( 5 - 4 / 4 ) * 6 In => 4, 4, 5, 7; Out => ( 4 - 5 + 7 ) * 4 In => 4, 4, 5, 8; Out => 4 * 5 + 8 - 4 In => 4, 4, 5, 9; Out => In => 4, 4, 6, 6; Out => In => 4, 4, 6, 7; Out => In => 4, 4, 6, 8; Out => ( 4 - 6 + 8 ) * 4 In => 4, 4, 6, 9; Out => 4 * 4 / 6 * 9 In => 4, 4, 7, 7; Out => ( 4 - 4 / 7 ) * 7 In => 4, 4, 7, 8; Out => 4 + 4 * 7 - 8 In => 4, 4, 7, 9; Out => 4 + 4 + 7 + 9 In => 4, 4, 8, 8; Out => 4 + 4 + 8 + 8 In => 4, 4, 8, 9; Out => 4 * 9 - 4 - 8 In => 4, 4, 9, 9; Out => In => 4, 5, 5, 5; Out => 4 + 5 * 5 - 5 In => 4, 5, 5, 6; Out => 4 / 5 * 5 * 6 In => 4, 5, 5, 7; Out => ( 7 - 5 / 5 ) * 4 In => 4, 5, 5, 8; Out => ( 4 - 5 / 5 ) * 8 In => 4, 5, 5, 9; Out => 4 * 5 - 5 + 9 In => 4, 5, 6, 6; Out => ( 5 + 6 / 6 ) * 4 In => 4, 5, 6, 7; Out => ( 5 - 6 + 7 ) * 4 In => 4, 5, 6, 8; Out => ( 4 + 5 - 6 ) * 8 In => 4, 5, 6, 9; Out => 4 + 5 + 6 + 9 In => 4, 5, 7, 7; Out => 5 * 7 - 7 - 4 In => 4, 5, 7, 8; Out => 4 + 5 + 7 + 8 In => 4, 5, 7, 9; Out => 4 * 7 - 9 + 5 In => 4, 5, 8, 8; Out => ( 5 + 8 / 8 ) * 4 In => 4, 5, 8, 9; Out => ( 5 - 8 + 9 ) * 4 In => 4, 5, 9, 9; Out => ( 5 + 9 / 9 ) * 4 In => 4, 6, 6, 6; Out => 4 / 6 * 6 * 6 In => 4, 6, 6, 7; Out => ( 7 - 6 / 6 ) * 4 In => 4, 6, 6, 8; Out => 4 + 6 + 6 + 8 In => 4, 6, 6, 9; Out => 4 * 9 - 6 - 6 In => 4, 6, 7, 7; Out => 4 + 6 + 7 + 7 In => 4, 6, 7, 8; Out => ( 4 + 6 - 7 ) * 8 In => 4, 6, 7, 9; Out => 6 / 4 * ( 7 + 9 ) In => 4, 6, 8, 8; Out => 4 * 6 + 8 - 8 In => 4, 6, 8, 9; Out => 6 + 8 * 9 / 4 In => 4, 6, 9, 9; Out => 4 * 6 + 9 - 9 In => 4, 7, 7, 7; Out => ( 7 - 7 / 7 ) * 4 In => 4, 7, 7, 8; Out => ( 4 - 7 / 7 ) * 8 In => 4, 7, 7, 9; Out => In => 4, 7, 8, 8; Out => 7 * 8 - 8 * 4 In => 4, 7, 8, 9; Out => ( 7 + 8 - 9 ) * 4 In => 4, 7, 9, 9; Out => ( 7 - 9 / 9 ) * 4 In => 4, 8, 8, 8; Out => 8 + 8 * 8 / 4 In => 4, 8, 8, 9; Out => ( 4 + 8 - 9 ) * 8 In => 4, 8, 9, 9; Out => ( 4 - 9 / 9 ) * 8 In => 4, 9, 9, 9; Out => In => 5, 5, 5, 5; Out => 5 * 5 - 5 / 5 In => 5, 5, 5, 6; Out => 5 + 5 * 5 - 6 In => 5, 5, 5, 7; Out => In => 5, 5, 5, 8; Out => In => 5, 5, 5, 9; Out => 5 + 5 + 5 + 9 In => 5, 5, 6, 6; Out => 5 * 5 - 6 / 6 In => 5, 5, 6, 7; Out => 5 * 5 + 6 - 7 In => 5, 5, 6, 8; Out => 5 + 5 + 6 + 8 In => 5, 5, 6, 9; Out => In => 5, 5, 7, 7; Out => 5 + 5 + 7 + 7 In => 5, 5, 7, 8; Out => 5 * 5 + 7 - 8 In => 5, 5, 7, 9; Out => In => 5, 5, 8, 8; Out => 5 * 5 - 8 / 8 In => 5, 5, 8, 9; Out => 5 * 5 + 8 - 9 In => 5, 5, 9, 9; Out => 5 * 5 - 9 / 9 In => 5, 6, 6, 6; Out => ( 5 - 6 / 6 ) * 6 In => 5, 6, 6, 7; Out => 5 + 6 + 6 + 7 In => 5, 6, 6, 8; Out => 6 + 6 * ( 8 - 5 ) In => 5, 6, 6, 9; Out => 6 * 9 - 5 * 6 In => 5, 6, 7, 7; Out => ( 5 - 7 / 7 ) * 6 In => 5, 6, 7, 8; Out => ( 5 + 7 - 8 ) * 6 In => 5, 6, 7, 9; Out => 6 - 9 * ( 5 - 7 ) In => 5, 6, 8, 8; Out => ( 5 + 6 - 8 ) * 8 In => 5, 6, 8, 9; Out => ( 5 + 8 - 9 ) * 6 In => 5, 6, 9, 9; Out => ( 5 - 9 / 9 ) * 6 In => 5, 7, 7, 7; Out => In => 5, 7, 7, 8; Out => In => 5, 7, 7, 9; Out => ( 5 + 7 ) * ( 9 - 7 ) In => 5, 7, 8, 8; Out => 8 - 8 * ( 5 - 7 ) In => 5, 7, 8, 9; Out => 5 * 8 - 9 - 7 In => 5, 7, 9, 9; Out => In => 5, 8, 8, 8; Out => 5 * 8 - 8 - 8 In => 5, 8, 8, 9; Out => 8 * 9 / ( 8 - 5 ) In => 5, 8, 9, 9; Out => In => 5, 9, 9, 9; Out => In => 6, 6, 6, 6; Out => 6 + 6 + 6 + 6 In => 6, 6, 6, 7; Out => In => 6, 6, 6, 8; Out => ( 6 + 6 - 8 ) * 6 In => 6, 6, 6, 9; Out => 6 * 6 * 6 / 9 In => 6, 6, 7, 7; Out => In => 6, 6, 7, 8; Out => In => 6, 6, 7, 9; Out => ( 6 + 7 - 9 ) * 6 In => 6, 6, 8, 8; Out => 6 * 8 / ( 8 - 6 ) In => 6, 6, 8, 9; Out => ( 6 + 6 - 9 ) * 8 In => 6, 6, 9, 9; Out => In => 6, 7, 7, 7; Out => In => 6, 7, 7, 8; Out => In => 6, 7, 7, 9; Out => In => 6, 7, 8, 8; Out => In => 6, 7, 8, 9; Out => 6 * 8 / ( 9 - 7 ) In => 6, 7, 9, 9; Out => 6 * 7 - 9 - 9 In => 6, 8, 8, 8; Out => 8 + 8 * ( 8 - 6 ) In => 6, 8, 8, 9; Out => 8 * 9 - 6 * 8 In => 6, 8, 9, 9; Out => 8 * 9 / ( 9 - 6 ) In => 6, 9, 9, 9; Out => In => 7, 7, 7, 7; Out => In => 7, 7, 7, 8; Out => In => 7, 7, 7, 9; Out => In => 7, 7, 8, 8; Out => In => 7, 7, 8, 9; Out => In => 7, 7, 9, 9; Out => In => 7, 8, 8, 8; Out => In => 7, 8, 8, 9; Out => 8 + 8 * ( 9 - 7 ) In => 7, 8, 9, 9; Out => In => 7, 9, 9, 9; Out => In => 8, 8, 8, 8; Out => In => 8, 8, 8, 9; Out => In => 8, 8, 9, 9; Out => In => 8, 9, 9, 9; Out => In => 9, 9, 9, 9; Out =>
[ 25. September 2002, 00:48: Message edited by: Jack Lothian ]
|
|
Re: KixGolf Results/Code
|
|
Eheh... I guess it was too much to read back, and it was my fault for not updating the info in the proper places, , but I'd already found that... Check my last post on the previous thread. Using python, I found the 466th one that perl "missed" and the python script took only 21 minutes instead of the 6 hours of the perl version... That's why I added the 3388 "out of order" in my test program: didn't feel like inserting it into it's "numerical" place and reformating all the lines... {edit} Also, about the parenthesis, this is the current status (for the floating point version):
code:
; Parentheses: 5 needed combinations ; abcd ; (ab)(cd) ; a(bcd) ; (abc)d ; 0 need (ab)cd \ ; 0 need a(bc)d - 1 solution (1169) needs any one of these! ; 0 need ab(cd) / ; ------------------ ; 1 need (abc)d ; ------------------ ; 3 need a(bcd) ; 13 need (ab)(cd)
{/edit} [ 25. September 2002, 01:08: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
I wrote it in kixtart & the math routine is very messy but it completes in about 2 hours.
The important question is: Is everyone aware that "(a b) c d" and "(a b c) d" are necessary to derive all solutions?
Your analysis implies that you only need brackets for 18 of your 466 solutions. My results suggest that exactly half of the solutions absolutely require brackets. [ 25. September 2002, 01:16: Message edited by: Jack Lothian ]
|
|
Re: KixGolf Results/Code
|
|
I may prove myself wrong anytime! I wrote a small perl one-liner and apparently you may be right, Jack... Going to delve deeper into this. Oddly enough, Howard's code seems to hold pretty well! I'll get back soon...
|
Shawn
|
(KiX Supporter)
|
2002-09-25 01:31 AM
|
|
|
|
|
Re: KixGolf Results/Code
|
|
Hey Madruga ... you still thinking about leaving this board (i mean Kixtart) ... seems to me your having way too much fun ... where else can you find this kind of action ? Kixtart is more than just a reskit utility ... its a way of life !!!
|
|
Re: KixGolf Results/Code
|
|
Well, Shawn, I must admit that I've had much fun these past weeks in this board, but KiXtart won't cut it for me for "real" work: nothing worse than having to solve some misterious problem, and having to fight the language at the same time... Not that this kind of thing won't happen in other languages, but it's just not that bad... I'm learning Python now (not for the same reason I wanted KiXtart, of course!) and having a decent editor/debugger sure makes the tables turn... Plus, it's a much more "challenging" language to learn and I like most of what I found in it (Python). In short, I'm commited to leave KiXtart for any serious work, but I may as well end up visiting you guys here from time to time. I had more fun participating in this game without actually being one of the competitors than if I did compete!
|
|
Re: KixGolf Results/Code
|
|
(ab)cd (ab)(cd) (abc)d a(bcd)
it's in there
|
|
Re: KixGolf Results/Code
|
|
I believe you need:
a b c d (a b c) d a (b c d) a b (c d) (a b) (c d) (a b) c d
to find all solutions. (Sorry, I haven't verified that you absolutely need a b c d. Never thought of that. Howard what made you think of that combo.) [ 25. September 2002, 02:08: Message edited by: Jack Lothian ]
|
|
Re: KixGolf Results/Code
|
|
I know that, Howard... I was commenting on Jack's claim that more parentheses would be needed... Still learning a bit more Python so I can make sort that one out (could have done it sooner in Perl, but hey, I'm learning a new language, so why don't I try and put it to use?! (One of these day's I'll get kicked for speaking so much about languages other than KiXtart... )
|
|
Re: KixGolf Results/Code
|
|
Jack: can you give us one example of each that can only be solved with one of these parenthesis constructs?
|
|
Re: KixGolf Results/Code
|
|
I can add the "()"'s quickly and easily if it is required.
|
|
Re: KixGolf Results/Code
|
|
Howard,
I don't know how you did it either great luck or great logic but you choose a subset of bracket combinations that works. If any one wishes to validate their code use the routine below. If it passes this code it works.
code:
dim $m, $rc $rc=SETOPTION('Explicit','ON') $rc=SETOPTION('NoVarsInString','ON') redirectoutput("game24.txt",1) $m=test24(0,0,0,0,2) $m=test24(0,0,0,1,2) $m=test24(0,0,0,2,2) $m=test24(0,0,0,3,2) $m=test24(0,0,0,4,2) $m=test24(0,0,0,5,2) $m=test24(0,0,0,6,2) $m=test24(0,0,0,7,2) $m=test24(0,0,0,8,2) $m=test24(0,0,0,9,2) $m=test24(0,0,1,1,2) $m=test24(0,0,1,2,2) $m=test24(0,0,1,3,2) $m=test24(0,0,1,4,2) $m=test24(0,0,1,5,2) $m=test24(0,0,1,6,2) $m=test24(0,0,1,7,2) $m=test24(0,0,1,8,2) $m=test24(0,0,1,9,2) $m=test24(0,0,2,2,2) $m=test24(0,0,2,3,2) $m=test24(0,0,2,4,2) $m=test24(0,0,2,5,2) $m=test24(0,0,2,6,2) $m=test24(0,0,2,7,2) $m=test24(0,0,2,8,2) $m=test24(0,0,2,9,2) $m=test24(0,0,3,3,2) $m=test24(0,0,3,4,2) $m=test24(0,0,3,5,2) $m=test24(0,0,3,6,2) $m=test24(0,0,3,7,2) $m=test24(0,0,3,8,1) $m=test24(0,0,3,9,2) $m=test24(0,0,4,4,2) $m=test24(0,0,4,5,2) $m=test24(0,0,4,6,1) $m=test24(0,0,4,7,2) $m=test24(0,0,4,8,2) $m=test24(0,0,4,9,2) $m=test24(0,0,5,5,2) $m=test24(0,0,5,6,2) $m=test24(0,0,5,7,2) $m=test24(0,0,5,8,2) $m=test24(0,0,5,9,2) $m=test24(0,0,6,6,2) $m=test24(0,0,6,7,2) $m=test24(0,0,6,8,2) $m=test24(0,0,6,9,2) $m=test24(0,0,7,7,2) $m=test24(0,0,7,8,2) $m=test24(0,0,7,9,2) $m=test24(0,0,8,8,2) $m=test24(0,0,8,9,2) $m=test24(0,0,9,9,2) $m=test24(0,1,1,1,2) $m=test24(0,1,1,2,2) $m=test24(0,1,1,3,2) $m=test24(0,1,1,4,2) $m=test24(0,1,1,5,2) $m=test24(0,1,1,6,2) $m=test24(0,1,1,7,2) $m=test24(0,1,1,8,2) $m=test24(0,1,1,9,2) $m=test24(0,1,2,2,2) $m=test24(0,1,2,3,2) $m=test24(0,1,2,4,2) $m=test24(0,1,2,5,2) $m=test24(0,1,2,6,2) $m=test24(0,1,2,7,2) $m=test24(0,1,2,8,1) $m=test24(0,1,2,9,2) $m=test24(0,1,3,3,2) $m=test24(0,1,3,4,2) $m=test24(0,1,3,5,2) $m=test24(0,1,3,6,1) $m=test24(0,1,3,7,1) $m=test24(0,1,3,8,1) $m=test24(0,1,3,9,1) $m=test24(0,1,4,4,2) $m=test24(0,1,4,5,1) $m=test24(0,1,4,6,1) $m=test24(0,1,4,7,1) $m=test24(0,1,4,8,1) $m=test24(0,1,4,9,2) $m=test24(0,1,5,5,1) $m=test24(0,1,5,6,1) $m=test24(0,1,5,7,2) $m=test24(0,1,5,8,2) $m=test24(0,1,5,9,2) $m=test24(0,1,6,6,2) $m=test24(0,1,6,7,2) $m=test24(0,1,6,8,2) $m=test24(0,1,6,9,2) $m=test24(0,1,7,7,2) $m=test24(0,1,7,8,2) $m=test24(0,1,7,9,2) $m=test24(0,1,8,8,2) $m=test24(0,1,8,9,2) $m=test24(0,1,9,9,2) $m=test24(0,2,2,2,2) $m=test24(0,2,2,3,2) $m=test24(0,2,2,4,2) $m=test24(0,2,2,5,2) $m=test24(0,2,2,6,1) $m=test24(0,2,2,7,2) $m=test24(0,2,2,8,2) $m=test24(0,2,2,9,2) $m=test24(0,2,3,3,2) $m=test24(0,2,3,4,1) $m=test24(0,2,3,5,2) $m=test24(0,2,3,6,1) $m=test24(0,2,3,7,2) $m=test24(0,2,3,8,1) $m=test24(0,2,3,9,1) $m=test24(0,2,4,4,1) $m=test24(0,2,4,5,2) $m=test24(0,2,4,6,1) $m=test24(0,2,4,7,2) $m=test24(0,2,4,8,1) $m=test24(0,2,4,9,2) $m=test24(0,2,5,5,2) $m=test24(0,2,5,6,2) $m=test24(0,2,5,7,1) $m=test24(0,2,5,8,1) $m=test24(0,2,5,9,2) $m=test24(0,2,6,6,1) $m=test24(0,2,6,7,2) $m=test24(0,2,6,8,1) $m=test24(0,2,6,9,1) $m=test24(0,2,7,7,2) $m=test24(0,2,7,8,2) $m=test24(0,2,7,9,2) $m=test24(0,2,8,8,1) $m=test24(0,2,8,9,2) $m=test24(0,2,9,9,2) $m=test24(0,3,3,3,2) $m=test24(0,3,3,4,1) $m=test24(0,3,3,5,1) $m=test24(0,3,3,6,2) $m=test24(0,3,3,7,1) $m=test24(0,3,3,8,1) $m=test24(0,3,3,9,1) $m=test24(0,3,4,4,1) $m=test24(0,3,4,5,2) $m=test24(0,3,4,6,1) $m=test24(0,3,4,7,2) $m=test24(0,3,4,8,1) $m=test24(0,3,4,9,1) $m=test24(0,3,5,5,2) $m=test24(0,3,5,6,2) $m=test24(0,3,5,7,2) $m=test24(0,3,5,8,1) $m=test24(0,3,5,9,1) $m=test24(0,3,6,6,1) $m=test24(0,3,6,7,1) $m=test24(0,3,6,8,1) $m=test24(0,3,6,9,2) $m=test24(0,3,7,7,2) $m=test24(0,3,7,8,1) $m=test24(0,3,7,9,2) $m=test24(0,3,8,8,1) $m=test24(0,3,8,9,1) $m=test24(0,3,9,9,2) $m=test24(0,4,4,4,2) $m=test24(0,4,4,5,1) $m=test24(0,4,4,6,1) $m=test24(0,4,4,7,1) $m=test24(0,4,4,8,1) $m=test24(0,4,4,9,2) $m=test24(0,4,5,5,2) $m=test24(0,4,5,6,1) $m=test24(0,4,5,7,2) $m=test24(0,4,5,8,2) $m=test24(0,4,5,9,2) $m=test24(0,4,6,6,1) $m=test24(0,4,6,7,1) $m=test24(0,4,6,8,1) $m=test24(0,4,6,9,1) $m=test24(0,4,7,7,2) $m=test24(0,4,7,8,1) $m=test24(0,4,7,9,2) $m=test24(0,4,8,8,1) $m=test24(0,4,8,9,2) $m=test24(0,4,9,9,2) $m=test24(0,5,5,5,2) $m=test24(0,5,5,6,2) $m=test24(0,5,5,7,2) $m=test24(0,5,5,8,2) $m=test24(0,5,5,9,2) $m=test24(0,5,6,6,1) $m=test24(0,5,6,7,2) $m=test24(0,5,6,8,2) $m=test24(0,5,6,9,1) $m=test24(0,5,7,7,2) $m=test24(0,5,7,8,2) $m=test24(0,5,7,9,2) $m=test24(0,5,8,8,1) $m=test24(0,5,8,9,2) $m=test24(0,5,9,9,2) $m=test24(0,6,6,6,2) $m=test24(0,6,6,7,2) $m=test24(0,6,6,8,2) $m=test24(0,6,6,9,2) $m=test24(0,6,7,7,2) $m=test24(0,6,7,8,2) $m=test24(0,6,7,9,2) $m=test24(0,6,8,8,2) $m=test24(0,6,8,9,1) $m=test24(0,6,9,9,1) $m=test24(0,7,7,7,2) $m=test24(0,7,7,8,2) $m=test24(0,7,7,9,2) $m=test24(0,7,8,8,2) $m=test24(0,7,8,9,1) $m=test24(0,7,9,9,2) $m=test24(0,8,8,8,1) $m=test24(0,8,8,9,2) $m=test24(0,8,9,9,2) $m=test24(0,9,9,9,2) $m=test24(1,1,1,1,2) $m=test24(1,1,1,2,2) $m=test24(1,1,1,3,2) $m=test24(1,1,1,4,2) $m=test24(1,1,1,5,2) $m=test24(1,1,1,6,2) $m=test24(1,1,1,7,2) $m=test24(1,1,1,8,1) $m=test24(1,1,1,9,2) $m=test24(1,1,2,2,2) $m=test24(1,1,2,3,2) $m=test24(1,1,2,4,2) $m=test24(1,1,2,5,2) $m=test24(1,1,2,6,1) $m=test24(1,1,2,7,1) $m=test24(1,1,2,8,1) $m=test24(1,1,2,9,1) $m=test24(1,1,3,3,2) $m=test24(1,1,3,4,1) $m=test24(1,1,3,5,1) $m=test24(1,1,3,6,1) $m=test24(1,1,3,7,1) $m=test24(1,1,3,8,1) $m=test24(1,1,3,9,1) $m=test24(1,1,4,4,1) $m=test24(1,1,4,5,1) $m=test24(1,1,4,6,1) $m=test24(1,1,4,7,1) $m=test24(1,1,4,8,1) $m=test24(1,1,4,9,1) $m=test24(1,1,5,5,1) $m=test24(1,1,5,6,1) $m=test24(1,1,5,7,1) $m=test24(1,1,5,8,1) $m=test24(1,1,5,9,2) $m=test24(1,1,6,6,1) $m=test24(1,1,6,7,2) $m=test24(1,1,6,8,1) $m=test24(1,1,6,9,1) $m=test24(1,1,7,7,2) $m=test24(1,1,7,8,2) $m=test24(1,1,7,9,2) $m=test24(1,1,8,8,1) $m=test24(1,1,8,9,2) $m=test24(1,1,9,9,2) $m=test24(1,2,2,2,2) $m=test24(1,2,2,3,2) $m=test24(1,2,2,4,1) $m=test24(1,2,2,5,1) $m=test24(1,2,2,6,1) $m=test24(1,2,2,7,1) $m=test24(1,2,2,8,1) $m=test24(1,2,2,9,1) $m=test24(1,2,3,3,1) $m=test24(1,2,3,4,1) $m=test24(1,2,3,5,1) $m=test24(1,2,3,6,1) $m=test24(1,2,3,7,1) $m=test24(1,2,3,8,1) $m=test24(1,2,3,9,1) $m=test24(1,2,4,4,1) $m=test24(1,2,4,5,1) $m=test24(1,2,4,6,1) $m=test24(1,2,4,7,1) $m=test24(1,2,4,8,1) $m=test24(1,2,4,9,1) $m=test24(1,2,5,5,1) $m=test24(1,2,5,6,1) $m=test24(1,2,5,7,1) $m=test24(1,2,5,8,1) $m=test24(1,2,5,9,1) $m=test24(1,2,6,6,1) $m=test24(1,2,6,7,1) $m=test24(1,2,6,8,1) $m=test24(1,2,6,9,1) $m=test24(1,2,7,7,1) $m=test24(1,2,7,8,1) $m=test24(1,2,7,9,1) $m=test24(1,2,8,8,1) $m=test24(1,2,8,9,1) $m=test24(1,2,9,9,2) $m=test24(1,3,3,3,1) $m=test24(1,3,3,4,1) $m=test24(1,3,3,5,1) $m=test24(1,3,3,6,1) $m=test24(1,3,3,7,1) $m=test24(1,3,3,8,1) $m=test24(1,3,3,9,1) $m=test24(1,3,4,4,1) $m=test24(1,3,4,5,1) $m=test24(1,3,4,6,1) $m=test24(1,3,4,7,1) $m=test24(1,3,4,8,1) $m=test24(1,3,4,9,1) $m=test24(1,3,5,5,2) $m=test24(1,3,5,6,1) $m=test24(1,3,5,7,1) $m=test24(1,3,5,8,1) $m=test24(1,3,5,9,1) $m=test24(1,3,6,6,1) $m=test24(1,3,6,7,1) $m=test24(1,3,6,8,1) $m=test24(1,3,6,9,1) $m=test24(1,3,7,7,1) $m=test24(1,3,7,8,1) $m=test24(1,3,7,9,1) $m=test24(1,3,8,8,1) $m=test24(1,3,8,9,1) $m=test24(1,3,9,9,1) $m=test24(1,4,4,4,1) $m=test24(1,4,4,5,1) $m=test24(1,4,4,6,1) $m=test24(1,4,4,7,1) $m=test24(1,4,4,8,1) $m=test24(1,4,4,9,1) $m=test24(1,4,5,5,1) $m=test24(1,4,5,6,1) $m=test24(1,4,5,7,1) $m=test24(1,4,5,8,1) $m=test24(1,4,5,9,1) $m=test24(1,4,6,6,1) $m=test24(1,4,6,7,1) $m=test24(1,4,6,8,1) $m=test24(1,4,6,9,1) $m=test24(1,4,7,7,1) $m=test24(1,4,7,8,1) $m=test24(1,4,7,9,1) $m=test24(1,4,8,8,1) $m=test24(1,4,8,9,1) $m=test24(1,4,9,9,2) $m=test24(1,5,5,5,1) $m=test24(1,5,5,6,1) $m=test24(1,5,5,7,2) $m=test24(1,5,5,8,2) $m=test24(1,5,5,9,1) $m=test24(1,5,6,6,1) $m=test24(1,5,6,7,1) $m=test24(1,5,6,8,1) $m=test24(1,5,6,9,1) $m=test24(1,5,7,7,2) $m=test24(1,5,7,8,1) $m=test24(1,5,7,9,1) $m=test24(1,5,8,8,1) $m=test24(1,5,8,9,1) $m=test24(1,5,9,9,1) $m=test24(1,6,6,6,1) $m=test24(1,6,6,7,2) $m=test24(1,6,6,8,1) $m=test24(1,6,6,9,1) $m=test24(1,6,7,7,2) $m=test24(1,6,7,8,2) $m=test24(1,6,7,9,1) $m=test24(1,6,8,8,1) $m=test24(1,6,8,9,1) $m=test24(1,6,9,9,1) $m=test24(1,7,7,7,2) $m=test24(1,7,7,8,2) $m=test24(1,7,7,9,1) $m=test24(1,7,8,8,1) $m=test24(1,7,8,9,1) $m=test24(1,7,9,9,1) $m=test24(1,8,8,8,1) $m=test24(1,8,8,9,1) $m=test24(1,8,9,9,2) $m=test24(1,9,9,9,2) $m=test24(2,2,2,2,2) $m=test24(2,2,2,3,1) $m=test24(2,2,2,4,1) $m=test24(2,2,2,5,1) $m=test24(2,2,2,6,2) $m=test24(2,2,2,7,1) $m=test24(2,2,2,8,1) $m=test24(2,2,2,9,1) $m=test24(2,2,3,3,1) $m=test24(2,2,3,4,1) $m=test24(2,2,3,5,1) $m=test24(2,2,3,6,1) $m=test24(2,2,3,7,1) $m=test24(2,2,3,8,1) $m=test24(2,2,3,9,1) $m=test24(2,2,4,4,1) $m=test24(2,2,4,5,1) $m=test24(2,2,4,6,1) $m=test24(2,2,4,7,1) $m=test24(2,2,4,8,1) $m=test24(2,2,4,9,1) $m=test24(2,2,5,5,1) $m=test24(2,2,5,6,1) $m=test24(2,2,5,7,1) $m=test24(2,2,5,8,1) $m=test24(2,2,5,9,1) $m=test24(2,2,6,6,1) $m=test24(2,2,6,7,1) $m=test24(2,2,6,8,1) $m=test24(2,2,6,9,1) $m=test24(2,2,7,7,1) $m=test24(2,2,7,8,1) $m=test24(2,2,7,9,2) $m=test24(2,2,8,8,1) $m=test24(2,2,8,9,1) $m=test24(2,2,9,9,2) $m=test24(2,3,3,3,1) $m=test24(2,3,3,4,2) $m=test24(2,3,3,5,1) $m=test24(2,3,3,6,1) $m=test24(2,3,3,7,1) $m=test24(2,3,3,8,1) $m=test24(2,3,3,9,1) $m=test24(2,3,4,4,1) $m=test24(2,3,4,5,1) $m=test24(2,3,4,6,1) $m=test24(2,3,4,7,1) $m=test24(2,3,4,8,1) $m=test24(2,3,4,9,1) $m=test24(2,3,5,5,1) $m=test24(2,3,5,6,1) $m=test24(2,3,5,7,1) $m=test24(2,3,5,8,1) $m=test24(2,3,5,9,1) $m=test24(2,3,6,6,1) $m=test24(2,3,6,7,1) $m=test24(2,3,6,8,1) $m=test24(2,3,6,9,1) $m=test24(2,3,7,7,1) $m=test24(2,3,7,8,1) $m=test24(2,3,7,9,1) $m=test24(2,3,8,8,1) $m=test24(2,3,8,9,1) $m=test24(2,3,9,9,1) $m=test24(2,4,4,4,1) $m=test24(2,4,4,5,1) $m=test24(2,4,4,6,1) $m=test24(2,4,4,7,1) $m=test24(2,4,4,8,1) $m=test24(2,4,4,9,1) $m=test24(2,4,5,5,1) $m=test24(2,4,5,6,1) $m=test24(2,4,5,7,1) $m=test24(2,4,5,8,1) $m=test24(2,4,5,9,1) $m=test24(2,4,6,6,1) $m=test24(2,4,6,7,1) $m=test24(2,4,6,8,1) $m=test24(2,4,6,9,1) $m=test24(2,4,7,7,1) $m=test24(2,4,7,8,1) $m=test24(2,4,7,9,1) $m=test24(2,4,8,8,1) $m=test24(2,4,8,9,1) $m=test24(2,4,9,9,1) $m=test24(2,5,5,5,2) $m=test24(2,5,5,6,2) $m=test24(2,5,5,7,1) $m=test24(2,5,5,8,1) $m=test24(2,5,5,9,1) $m=test24(2,5,6,6,1) $m=test24(2,5,6,7,1) $m=test24(2,5,6,8,1) $m=test24(2,5,6,9,1) $m=test24(2,5,7,7,1) $m=test24(2,5,7,8,1) $m=test24(2,5,7,9,1) $m=test24(2,5,8,8,1) $m=test24(2,5,8,9,1) $m=test24(2,5,9,9,2) $m=test24(2,6,6,6,1) $m=test24(2,6,6,7,1) $m=test24(2,6,6,8,1) $m=test24(2,6,6,9,1) $m=test24(2,6,7,7,2) $m=test24(2,6,7,8,1) $m=test24(2,6,7,9,1) $m=test24(2,6,8,8,1) $m=test24(2,6,8,9,1) $m=test24(2,6,9,9,1) $m=test24(2,7,7,7,2) $m=test24(2,7,7,8,1) $m=test24(2,7,7,9,2) $m=test24(2,7,8,8,1) $m=test24(2,7,8,9,1) $m=test24(2,7,9,9,2) $m=test24(2,8,8,8,1) $m=test24(2,8,8,9,1) $m=test24(2,8,9,9,1) $m=test24(2,9,9,9,2) $m=test24(3,3,3,3,1) $m=test24(3,3,3,4,1) $m=test24(3,3,3,5,1) $m=test24(3,3,3,6,1) $m=test24(3,3,3,7,1) $m=test24(3,3,3,8,1) $m=test24(3,3,3,9,1) $m=test24(3,3,4,4,1) $m=test24(3,3,4,5,1) $m=test24(3,3,4,6,1) $m=test24(3,3,4,7,1) $m=test24(3,3,4,8,1) $m=test24(3,3,4,9,1) $m=test24(3,3,5,5,1) $m=test24(3,3,5,6,1) $m=test24(3,3,5,7,1) $m=test24(3,3,5,8,2) $m=test24(3,3,5,9,1) $m=test24(3,3,6,6,1) $m=test24(3,3,6,7,1) $m=test24(3,3,6,8,1) $m=test24(3,3,6,9,1) $m=test24(3,3,7,7,1) $m=test24(3,3,7,8,1) $m=test24(3,3,7,9,1) $m=test24(3,3,8,8,1) $m=test24(3,3,8,9,1) $m=test24(3,3,9,9,1) $m=test24(3,4,4,4,1) $m=test24(3,4,4,5,1) $m=test24(3,4,4,6,1) $m=test24(3,4,4,7,1) $m=test24(3,4,4,8,1) $m=test24(3,4,4,9,1) $m=test24(3,4,5,5,1) $m=test24(3,4,5,6,1) $m=test24(3,4,5,7,1) $m=test24(3,4,5,8,1) $m=test24(3,4,5,9,1) $m=test24(3,4,6,6,1) $m=test24(3,4,6,7,2) $m=test24(3,4,6,8,1) $m=test24(3,4,6,9,1) $m=test24(3,4,7,7,1) $m=test24(3,4,7,8,1) $m=test24(3,4,7,9,1) $m=test24(3,4,8,8,2) $m=test24(3,4,8,9,1) $m=test24(3,4,9,9,1) $m=test24(3,5,5,5,2) $m=test24(3,5,5,6,1) $m=test24(3,5,5,7,1) $m=test24(3,5,5,8,1) $m=test24(3,5,5,9,1) $m=test24(3,5,6,6,1) $m=test24(3,5,6,7,1) $m=test24(3,5,6,8,1) $m=test24(3,5,6,9,1) $m=test24(3,5,7,7,2) $m=test24(3,5,7,8,1) $m=test24(3,5,7,9,1) $m=test24(3,5,8,8,1) $m=test24(3,5,8,9,1) $m=test24(3,5,9,9,1) $m=test24(3,6,6,6,1) $m=test24(3,6,6,7,1) $m=test24(3,6,6,8,1) $m=test24(3,6,6,9,1) $m=test24(3,6,7,7,1) $m=test24(3,6,7,8,1) $m=test24(3,6,7,9,1) $m=test24(3,6,8,8,1) $m=test24(3,6,8,9,1) $m=test24(3,6,9,9,1) $m=test24(3,7,7,7,1) $m=test24(3,7,7,8,1) $m=test24(3,7,7,9,1) $m=test24(3,7,8,8,1) $m=test24(3,7,8,9,1) $m=test24(3,7,9,9,1) $m=test24(3,8,8,8,1) $m=test24(3,8,8,9,1) $m=test24(3,8,9,9,1) $m=test24(3,9,9,9,1) $m=test24(4,4,4,4,1) $m=test24(4,4,4,5,1) $m=test24(4,4,4,6,1) $m=test24(4,4,4,7,1) $m=test24(4,4,4,8,1) $m=test24(4,4,4,9,1) $m=test24(4,4,5,5,1) $m=test24(4,4,5,6,1) $m=test24(4,4,5,7,1) $m=test24(4,4,5,8,1) $m=test24(4,4,5,9,2) $m=test24(4,4,6,6,2) $m=test24(4,4,6,7,2) $m=test24(4,4,6,8,1) $m=test24(4,4,6,9,1) $m=test24(4,4,7,7,1) $m=test24(4,4,7,8,1) $m=test24(4,4,7,9,1) $m=test24(4,4,8,8,1) $m=test24(4,4,8,9,1) $m=test24(4,4,9,9,2) $m=test24(4,5,5,5,1) $m=test24(4,5,5,6,1) $m=test24(4,5,5,7,1) $m=test24(4,5,5,8,1) $m=test24(4,5,5,9,1) $m=test24(4,5,6,6,1) $m=test24(4,5,6,7,1) $m=test24(4,5,6,8,1) $m=test24(4,5,6,9,1) $m=test24(4,5,7,7,1) $m=test24(4,5,7,8,1) $m=test24(4,5,7,9,1) $m=test24(4,5,8,8,1) $m=test24(4,5,8,9,1) $m=test24(4,5,9,9,1) $m=test24(4,6,6,6,1) $m=test24(4,6,6,7,1) $m=test24(4,6,6,8,1) $m=test24(4,6,6,9,1) $m=test24(4,6,7,7,1) $m=test24(4,6,7,8,1) $m=test24(4,6,7,9,1) $m=test24(4,6,8,8,1) $m=test24(4,6,8,9,1) $m=test24(4,6,9,9,1) $m=test24(4,7,7,7,1) $m=test24(4,7,7,8,1) $m=test24(4,7,7,9,2) $m=test24(4,7,8,8,1) $m=test24(4,7,8,9,1) $m=test24(4,7,9,9,1) $m=test24(4,8,8,8,1) $m=test24(4,8,8,9,1) $m=test24(4,8,9,9,1) $m=test24(4,9,9,9,2) $m=test24(5,5,5,5,1) $m=test24(5,5,5,6,1) $m=test24(5,5,5,7,2) $m=test24(5,5,5,8,2) $m=test24(5,5,5,9,1) $m=test24(5,5,6,6,1) $m=test24(5,5,6,7,1) $m=test24(5,5,6,8,1) $m=test24(5,5,6,9,2) $m=test24(5,5,7,7,1) $m=test24(5,5,7,8,1) $m=test24(5,5,7,9,2) $m=test24(5,5,8,8,1) $m=test24(5,5,8,9,1) $m=test24(5,5,9,9,1) $m=test24(5,6,6,6,1) $m=test24(5,6,6,7,1) $m=test24(5,6,6,8,1) $m=test24(5,6,6,9,1) $m=test24(5,6,7,7,1) $m=test24(5,6,7,8,1) $m=test24(5,6,7,9,1) $m=test24(5,6,8,8,1) $m=test24(5,6,8,9,1) $m=test24(5,6,9,9,1) $m=test24(5,7,7,7,2) $m=test24(5,7,7,8,2) $m=test24(5,7,7,9,1) $m=test24(5,7,8,8,1) $m=test24(5,7,8,9,1) $m=test24(5,7,9,9,2) $m=test24(5,8,8,8,1) $m=test24(5,8,8,9,1) $m=test24(5,8,9,9,2) $m=test24(5,9,9,9,2) $m=test24(6,6,6,6,1) $m=test24(6,6,6,7,2) $m=test24(6,6,6,8,1) $m=test24(6,6,6,9,1) $m=test24(6,6,7,7,2) $m=test24(6,6,7,8,2) $m=test24(6,6,7,9,1) $m=test24(6,6,8,8,1) $m=test24(6,6,8,9,1) $m=test24(6,6,9,9,2) $m=test24(6,7,7,7,2) $m=test24(6,7,7,8,2) $m=test24(6,7,7,9,2) $m=test24(6,7,8,8,2) $m=test24(6,7,8,9,1) $m=test24(6,7,9,9,1) $m=test24(6,8,8,8,1) $m=test24(6,8,8,9,1) $m=test24(6,8,9,9,1) $m=test24(6,9,9,9,2) $m=test24(7,7,7,7,2) $m=test24(7,7,7,8,2) $m=test24(7,7,7,9,2) $m=test24(7,7,8,8,2) $m=test24(7,7,8,9,2) $m=test24(7,7,9,9,2) $m=test24(7,8,8,8,2) $m=test24(7,8,8,9,1) $m=test24(7,8,9,9,2) $m=test24(7,9,9,9,2) $m=test24(8,8,8,8,2) $m=test24(8,8,8,9,2) $m=test24(8,8,9,9,2) $m=test24(8,9,9,9,2) $m=test24(9,9,9,9,2)
function test24($i1,$i2,$i3,$i4,$behaviour) DIM $out, $str, $found $str = 'In => '+$i1+', '+$i2+', '+$i3+', '+$i4+'; Out => ' $out=Game24($i1,$i2,$i3,$i4) $out=trim($out) $str = $str + $out if $out <> "" $found=1 else $found=0 endif if ( ($behaviour=1) and ($found=1) ) or ( ($behaviour=2) and ($found=0) ) $str = $str + " => Correct!!" else $str = $str + " => WRONG!!" endif ? $str endfunction
|
|
Re: KixGolf Results/Code
|
|
I can't say it was great logic. I started with the what made sense: a lone pair, double pair for all 5's, a(bcd), and (abc)d.
|
|
Re: KixGolf Results/Code
|
|
Madruga,
Finding, something that has only one solution means that I have to rerun the test 5 times because I set the brackets permutations as the outside loop & I then set the priority order for the permutations. I would need to do 1 run with each bracket type at the end of the priority order. Painful - I would rather not since each run takes 2 hours. None of my previous runs are helpful since they all contained the no bracket case as the number 1 priority which is clearly wrong.
In my posted sample output above, I believe all outputs of the form "(a b) c d" & "(a b)(c d)" are unique solutions to that form. Since only 4 cases of "a (b c d)" were found they are also probably unique. As to the other cases?? [ 25. September 2002, 03:22: Message edited by: Jack Lothian ]
|
|
Re: KixGolf Results/Code
|
|
Well... I give up. (BTW: I haven't oficially "given up" on this contest, but I take this opportunity to do so...) I "merged" Jack Lothian's full suite set into my test program. You now have two options:
- $TestSuite = 1 -> runs 50 random tests
- $TestSuite = 2 -> runs Jack Lothian's test suite
(If you don't specify, it will run both...) Also, it logs into "game24.log". This is where the "I give up" comes in!! I think this "should" work, but I'm getting a very weird error. Please someone grab this one (it comes pre-packaged with Howards function) and fix it as I'm going to bed. {edit} Howard has already fixed this and I updated the code here to incorporate his fixes. {/edit} Also, if I have enough spare time later today during my lunch hour, I'll try to find out exactly what are the parenthesis combos that are needed. BTW: I could post here the 457.176 bytes file where I stored all possible solutions, should anyone be interested in parsing through it instead of re-calculating. It's 25.295 lines of stuff like this: code:
7889 : 8-(7-9)*8 7889 : 8-8*(7-9)
(It can be turned into an 89.331 bytes zip file) {edit} Forgot to post the code... {/edit} {edit} Pasted fixed code. Thks Howard! {/edit}
code:
BREAK ON Global $Target, $Valid, $TestSuite, $Lix $Lix = DisplayText( 'Game24 v 2.0 KiXtart Golf running under KiXtart v'+@KIX ) $Lix = DisplayText( '' ) Global $OUTPUTLINE, $LOGGING, $LOGGINGFILE, $OUTPUT, $SCROLLING, $WRAPATEOL $LOGGING = 1 $LOGGINGFILE = "game24.log" $SCROLLING = 1 $Target = 24 $ErrorMargin = 0.0001 $Valid = "003800460128013601370138013901450146014701480155015602260234" + "023602380239024402460248025702580266026802690288033403350337" + "033803390344034603480349035803590366036703680378038803890445" + "044604470448045604660467046804690478048805660569058806890699" + "078908881118112611271128112911341135113611371138113911441145" + "114611471148114911551156115711581166116811691188122412251226" + "122712281229123312341235123612371238123912441245124612471248" + "124912551256125712581259126612671268126912771278127912881289" + "133313341335133613371338133913441345134613471348134913561357" + "135813591366136713681369137713781379138813891399144414451446" + "144714481449145514561457145814591466146714681469147714781479" + "148814891555155615591566156715681569157815791588158915991666" + "166816691679168816891699177917881789179918881889222322242225" + "222722282229223322342235223622372238223922442245224622472248" + "224922552256225722582259226622672268226922772278228822892333" + "233523362337233823392344234523462347234823492355235623572358" + "235923662367236823692377237823792388238923992444244524462447" + "244824492455245624572458245924662467246824692477247824792488" + "248924992557255825592566256725682569257725782579258825892666" + "266726682669267826792688268926992778278827892888288928993333" + "333433353336333733383339334433453346334733483349335533563357" + "335933663367336833693377337833793389339934443445344634473448" + "344934553456345734583459346634683469347734783479348934993556" + "355735583559356635673568356935783579358835893599366636673668" + "366936773678367936883689369937773778377937883789379938883889" + "389939994444444544464447444844494455445644574458446844694477" + "447844794488448945554556455745584559456645674568456945774578" + "457945884589459946664667466846694677467846794688468946994777" + "477847884789479948884889489955555556555955665567556855775578" + "558855895599566656675668566956775678567956885689569957795788" + "578958885889666666686669667966886689678967996888688968997889" + "3388" $GOOD = "0038004601280136013701380139014501460147" + "0148015501560226023402360238023902440246" + "0248025702580266026802690288033403350337" + "0338033903440346034803490358035903660367" + "0368037803880389044504460447044804560466" + "0467046804690478048805660569058806890699" + "0789088811181126112711281129113411351136" + "1137113811391144114511461147114811491155" + "1156115711581166116811691188122412251226" + "1227122812291233123412351236123712381239" + "1244124512461247124812491255125612571258" + "1259126612671268126912771278127912881289" + "1333133413351336133713381339134413451346" + "1347134813491356135713581359136613671368" + "1369137713781379138813891399144414451446" + "1447144814491455145614571458145914661467" + "1468146914771478147914881489155515561559" + "1566156715681569157815791588158915991666" + "1668166916791688168916991779178817891799" + "1888188922232224222522272228222922332234" + "2235223622372238223922442245224622472248" + "2249225522562257225822592266226722682269" + "2277227822882289233323352336233723382339" + "2344234523462347234823492355235623572358" + "2359236623672368236923772378237923882389" + "2399244424452446244724482449245524562457" + "2458245924662467246824692477247824792488" + "2489249925572558255925662567256825692577" + "2578257925882589266626672668266926782679" + "2688268926992778278827892888288928993333" + "3334333533363337333833393344334533463347" + "3348334933553356335733593366336733683369" + "3377337833793388338933993444344534463447" + "3448344934553456345734583459346634683469" + "3477347834793489349935563557355835593566" + "3567356835693578357935883589359936663667" + "3668366936773678367936883689369937773778" + "3779378837893799388838893899399944444445" + "4446444744484449445544564457445844684469" + "4477447844794488448945554556455745584559" + "4566456745684569457745784579458845894599" + "4666466746684669467746784679468846894699" + "4777477847884789479948884889489955555556" + "5559556655675568557755785588558955995666" + "5667566856695677567856795688568956995779" + "5788578958885889666666686669667966886689" + "678967996888688968997889" $BAD = "0000000100020003000400050006000700080009" + "0011001200130014001500160017001800190022" + "0023002400250026002700280029003300340035" + "0036003700390044004500470048004900550056" + "0057005800590066006700680069007700780079" + "0088008900990111011201130114011501160117" + "0118011901220123012401250126012701290133" + "0134013501440149015701580159016601670168" + "0169017701780179018801890199022202230224" + "0225022702280229023302350237024502470249" + "0255025602590267027702780279028902990333" + "0336034503470355035603570369037703790399" + "0444044904550457045804590477047904890499" + "0555055605570558055905670568057705780579" + "0589059906660667066806690677067806790688" + "0777077807790788079908890899099911111112" + "1113111411151116111711191122112311241125" + "1133115911671177117811791189119912221223" + "1299135514991557155815771667167716781777" + "1778189919992222222622792299233425552556" + "2599267727772779279929993358346734883555" + "3577445944664467449947794999555755585569" + "5579577757785799589959996667667766786699" + "6777677867796788699977777778777977887789" + "779978887899799988888889889989999999" $rc=SETOPTION('Explicit','ON') $rc=SETOPTION('NoVarsInString','ON') $rc=SRND(@MSECS) Dim $i if ( $TestSuite == 0 ) or ( $TestSuite == 1 ) $Lix = DisplayText( "Running Test Suite #1: fifty random combos" ) ; Random tests for $i = 1 to 50 test24(RND(9),RND(9),RND(9),RND(9),3) next endif if ( $TestSuite == 0 ) or ( $TestSuite == 2 ) $Lix = DisplayText( "Running Test Suite #2: Jack Lothian's Validation Suite" ) ; 1st let's run tests WITH solutions for $i = 1 to len($GOOD) step 4 test24(Int(SubStr($GOOD,$i,1)),Int(SubStr($GOOD,$i+1,1)),Int(SubStr($GOOD,$i+2,1)),Int(SubStr($GOOD,$i+3,1)),1) next ; Now let's run tests WITHOUT solutions for $i = 1 to len($BAD) step 4 test24(Int(SubStr($BAD,$i,1)),Int(SubStr($BAD,$i+1,1)),Int(SubStr($BAD,$i+2,1)),Int(SubStr($BAD,$i+3,1)),2) next endif $Lix = DisplayText( '' ) ; Inputs: $i1..$i4 => 4 numbers to pass to game24 ; $behaviour = 1 -> Expected result ; $behaviour = 2 -> Expected to fail ; $behaviour = 3 -> Don't know (random) function test24($i1,$i2,$i3,$i4,$behaviour) DIM $rc, $out, $result, $error, $str, $i, $found, $temp, $nums[4], $numbers $str = 'In: '+$i1+$i2+$i3+$i4+'; Out: ' $out="" $out=Game24($i1,$i2,$i3,$i4) if instr($out,".") == 0 $i = 1 while $i <= Len($out) if ( SubStr($out,$i,1) >= '0' ) and ( SubStr($out,$i,1) <= '9' ) $out = Left($out,$i) + '.0' + SubStr($out,$i+1) $i = $i + 2; endif; $i = $i + 1; loop endif $error=Execute("$$result=("+$out+")") $result=Trim($result) Dim $tmpStr $tmpStr = $out while (len($tmpStr)<22) $tmpStr = $tmpStr + " " loop $str = $str + left($tmpStr, 22) + " = " + $result if (len($result)<2) $str = $str+" " endif if ( $behaviour = 3 ) ; sort numbers used, so as to check array of possible solutions $nums[0] = $i1 $nums[1] = $i2 $nums[2] = $i3 $nums[3] = $i4 do $found = 0 for $i = 0 to 2 if $nums[$i] > $nums[$i+1] $found = 1 $temp = $nums[$i+1] $nums[$i+1] = $nums[$i] $nums[$i] = $temp endif next until $found == 0 $numbers = "" + $nums[0] + $nums[1] + $nums[2] + $nums[3] ; check for presence in array $found = 0 $i = 1 while ( $found == 0 ) and ( $i < Len($Valid) ) if ( SubStr( $Valid, $i, 4 ) == $numbers ) $found = 1 endif $i = $i + 4 loop if $found and ( ($result>=$Target-$ErrorMargin) and ($result<=$Target+$ErrorMargin) ) $str = $str + " => Correct!!" else if not $found and $result="" $str = $str + " => Correct!!" else $str = $str + " => WRONG!!" endif endif else if ( ($behaviour=1) and ($result>=$Target-$ErrorMargin) and ($result<=$Target+$ErrorMargin) ) or ( ($behaviour=2) and ($result='') ) $str = $str + " => Correct!!" else $str = $str + " => WRONG!!" endif endif $Lix = DisplayText( $str ) endfunction Dim $shellcommand $shellcommand='kix32 Kixgolf3.kix $f='+@scriptname $Lix = DisplayText( $shellcommand ) Shell $shellcommand ;FUNCTION DisplayText ; ;AUTHOR Jens Meyer (sealeopard@usa.net) ; ;ACTION Prints an information text on screen ; ;SYNTAX DISPLAYTEXT(STRING [, TEXTCOLOR]) ; ;PARAMETERS $string ; Required string containing the information text ; ; $textcolor ; Optional text color ; ;RETURNS 0 if successful, otherwise 1 ; ;REMARKS Requires the global variables $OUTPUTLINE (output line counter), ; $LOGGING (true if additional logging to textfile is enabled), ; $LOGGINGFILE (filename for additional logging), ; $OUTPUT (default output redirector, defaults to the screen), ; $SCROLLING (enables scrolling display mode). ; Text will get wrapped into the next line(s). ; $WRAPATEOL is used to maintain state between function calls and ; should speed up execution time. ; ;DEPENDENCIES none ; ;EXAMPLE $retcode=displaytext('This is an informal text!') ; ;KIXTART BBS http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000036 ; function displaytext($text, optional $textcolor) Dim $textlength if vartype($WRAPATEOL)<2 global $WRAPATEOL $WRAPATEOL=setoption('WrapAtEOL','ON') if $WRAPATEOL='OFF' $retcode=setoption('WrapAtEOL','OFF') $WRAPATEOL=0 else $WRAPATEOL=1 endif endif if $OUTPUTLINE>22 and $SCROLLING=0 cls $OUTPUTLINE = 0 endif if $text<>'' if $textcolor='' $textcolor='w/n' endif $retcode=execute('color '+$textcolor) ? ' ' $textlength = len($text) if $textlength<=78 or $WRAPATEOL if $LOGGING $retcode=redirectoutput($LOGGINGFILE,0) ? $text $retcode=redirectoutput($OUTPUT) endif at($OUTPUTLINE,1) $text if $WRAPATEOL $OUTPUTLINE=$OUTPUTLINE + val(($textlength+1)/80) + 1 else $OUTPUTLINE = $OUTPUTLINE + 1 endif else if $LOGGING $retcode=redirectoutput($LOGGINGFILE,0) ? substr($text,1,78) $retcode=redirectoutput($OUTPUT) endif at($OUTPUTLINE,1) substr($text,1,78) $OUTPUTLINE = $OUTPUTLINE + 1 $text = substr($text,79,$textlength-78) $retcode=displaytext($text, $textcolor) return endif endif $displaytext=@error endfunction ; Operators: 64 combinations ; +++ ++- ++* ++/ +-+ +-- +-* +-/ +*+ +*- +** +*/ +/+ +/- +/* +// ; -++ -+- -+* -+/ --+ --- --* --/ -*+ -*- -** -*/ -/+ -/- -/* -// ; *++ *+- *+* *+/ *-+ *-- *-* *-/ **+ **- *** **/ */+ */- */* *// ; /++ /+- /+* /+/ /-+ /-- /-* /-/ /*+ /*- /** /*/ //+ //- //* /// ; Digits: 24 permutations ; abcd abdc acbd acdb adbc adcb ; bacd badc bcad bcda bdac bdca ; cabd cadb cbad cbda cdab cdba ; dabc dacb dbac dbca dcab dcba ; Parentheses: 5 needed combinations ; abcd ; (ab)(cd) ; a(bcd) ; (abc)d ; 0 need (ab)cd \ ; 0 need a(bc)d - 1 solution (1169) needs at any one of these! ; 0 need ab(cd) / ; ------------------ ; 1 need (abc)d ; ------------------ ; 3 need a(bcd) ; 13 need (ab)(cd) ; ------------------ ; 131 need at least one '+' ; 174 need at least one '-' ; 306 need at least one '*' ; 36 need at least one '/' ;! function game24($a,$b,$c,$d) Dim $h, $j, $l, $p, $q, $r, $s, $t, $v, $, $x, $y, $z $h = "+","-","/","*" for $z=1 to 4 for $y=1 to 4 for $x=1 to 2 for each $p in $h for each $q in $h for each $r in $h for each $j in split("0,8~0,8,10,18~0,12~4,16","~") $ = ".0" $s = ""+$a+$+$p+$b+$+$q+$c+$+$r+$d+$ for each $ in split($j,",") $l = chr(40 + ($l="(")) $s = "" + left($s,$) + $l + substr($s,1+$) next $t = execute("$$v=$s") if abs($v-24)< 1E-9 goto E endif next next next next $ = $c $c = $d $d = $ next $ = $b $b = $c $c = $d $d = $ next $ = $a $a = $d $d = $ next $s = "" :E $game24 = $s exit endfunction ;! ;!
[ 25. September 2002, 13:23: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
I believe the 50 random sets will just be simple rotation of the sets I gave. If your program is following jens specs & generating all the 24 permutations of the incoming 4 numbers then the 50 random sets are irrelevant. In theory, the 715 sets I gave cover the complete universe of possibilities.
|
|
Re: KixGolf Results/Code
|
|
Why 715? Where did you get that number from, that is, how did you arrive at that number? (Just curious:)) {edit} Also, it's in there just to be a "quick" check... 715 checks can take some time to go through... {/edit} [ 25. September 2002, 03:48: Message edited by: Fernando Madruga ]
|
|
Re: KixGolf Results/Code
|
|
All other sets are rotations of these basic sets. They came from the basic 4 "For" statements that I mentioned earlier in the discussion in a comment to Richard. I suspect it's the ratio of 2 factorials.
I just had an interesting thought. If someone can reduce the number of operators or the number of number rotations & still pass the above test then it should still meet Jens criteria. It will be just like Howard dropping 3 bracket types & still getting the correct solution. [ 25. September 2002, 04:04: Message edited by: Jack Lothian ]
|
|
Re: KixGolf Results/Code
|
|
That will be left as an exercise to the reader(s)... Good night all. C U Later.
|
|
Re: KixGolf Results/Code
|
|
Missing right quote: code:
$Lix = DisplayText( "Running Test Suite #1: twenty random combos )
{edit} I double pasted the script and cause myself some grief.
Bad Var: $LOGGINGGILE = "game24.log" should be $LOGGINGFILE = "game24.log"
It is now running:
code:
Game24 v 2.0 KiXtart Golf running under KiXtart v4.12 Beta 1 Running Test Suite #1: twenty random combos1\kix32 junk.kix In: 0100; Out: = => Correct!! In: 4442; Out: (4.0+4.0+4.0)*2.0 = 24 => Correct!! In: 0881; Out: = => Correct!! In: 6774; Out: (6.0+7.0)+7.0+4.0 = 24 => Correct!! In: 9676; Out: (9.0-7.0)*(6.0+6.0) = 24 => Correct!! In: 0552; Out: = => Correct!! In: 3017; Out: (3.0+0.0)*(1.0+7.0) = 24 => Correct!! In: 0292; Out: = => Correct!! In: 1098; Out: = => Correct!! In: 9254; Out: (9.0+2.0-5.0)*4.0 = 24 => Correct!! In: 6262; Out: (6.0+2.0)*6.0/2.0 = 24 => Correct!! In: 0214; Out: = => Correct!! In: 9713; Out: (9.0/3.0)*(7.0+1.0) = 24 => Correct!! In: 5428; Out: (5.0-4.0+2.0)*8.0 = 24 => Correct!! In: 7329; Out: (7.0*3.0-9.0)*2.0 = 24 => Correct!! In: 5107; Out: = => Correct!! In: 7057; Out: = => Correct!! In: 5557; Out: = => Correct!! In: 4231; Out: (4.0+2.0)*(3.0+1.0) = 24 => Correct!! In: 2960; Out: (2.0*9.0)+6.0+0.0 = 24 => Correct!! In: 1567; Out: (1.0+5.0*6.0)-7.0 = 24 => Correct!! In: 4342; Out: (4.0*3.0)*(4.0-2.0) = 24 => Correct!! In: 6242; Out: (6.0+2.0+4.0)*2.0 = 24 => Correct!! In: 6974; Out: (6.0/4.0)*(9.0+7.0) = 24 => Correct!! In: 9281; Out: (9.0+2.0*8.0)-1.0 = 24 => Correct!! In: 3431; Out: 3.0*(4.0+3.0+1.0) = 24 => Correct!! In: 0977; Out: = => Correct!! In: 2371; Out: (2.0+3.0*7.0)+1.0 = 24 => Correct!! In: 4421; Out: (4.0+4.0)*(2.0+1.0) = 24 => Correct!! In: 0020; Out: = => Correct!! In: 8607; Out: = => Correct!!
[ 25. September 2002, 05:13: Message edited by: Howard Bullock ]
|
|
Re: KixGolf Results/Code
|
|
Thanks!
That's one of the disadvantages of having a free form language: you don't keep errors within a couple of lines! They show up in the most "weird" places tons of lines after... I'll incorporate the changes into the posted script.
|
|
Re: KixGolf Results/Code
|
|
Richard, I tried to use your udfAnagram() to replace code in Game24() but couldn't get to a point of reducing code.
|