Page 1 of 5 12345>
Topic Options
#70064 - 2002-09-21 09:13 PM KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Is it time to post the code?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70065 - 2002-09-21 09:15 PM Re: KixGolf Results/Code
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
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 ]
_________________________
There are two types of vessels, submarines and targets.

Top
#70066 - 2002-09-21 09:17 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70067 - 2002-09-21 09:35 PM Re: KixGolf Results/Code
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
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

_________________________
There are two types of vessels, submarines and targets.

Top
#70068 - 2002-09-21 09:54 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70069 - 2002-09-21 11:22 PM Re: KixGolf Results/Code
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Howard,

You can shawe of 4 by omitting the last Exit [Big Grin]

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

Top
#70070 - 2002-09-21 11:31 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I kinda liked my parentheses toggle from my first:

$l = chr(40 + ($l="("))
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70071 - 2002-09-22 11:04 AM Re: KixGolf Results/Code
Anonymous
Unregistered


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 ]

Top
#70072 - 2002-09-22 02:50 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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. [Cool]

{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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70073 - 2002-09-22 03:20 PM Re: KixGolf Results/Code
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
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.
_________________________
Jack

Top
#70074 - 2002-09-22 03:56 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70075 - 2002-09-22 04:08 PM Re: KixGolf Results/Code
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
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 ]
_________________________
Jack

Top
#70076 - 2002-09-22 04:13 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70077 - 2002-09-22 04:14 PM Re: KixGolf Results/Code
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Kixtart seems to evaluate 3/0 as zero.
_________________________
Jack

Top
#70078 - 2002-09-22 04:18 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70079 - 2002-09-22 06:06 PM Re: KixGolf Results/Code
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
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 ]
_________________________
There are two types of vessels, submarines and targets.

Top
#70080 - 2002-09-23 03:50 PM Re: KixGolf Results/Code
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
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.
_________________________
Jack

Top
#70081 - 2002-09-23 07:16 PM Re: KixGolf Results/Code
Fernando Madruga Offline
Starting to like KiXtart

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
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... [Smile]

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...
_________________________
Later,   [b]Mad[/b]ruga

Top
#70082 - 2002-09-23 08:36 PM Re: KixGolf Results/Code
Fernando Madruga Offline
Starting to like KiXtart

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
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 ]
_________________________
Later,   [b]Mad[/b]ruga

Top
#70083 - 2002-09-23 08:43 PM Re: KixGolf Results/Code
Fernando Madruga Offline
Starting to like KiXtart

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
It's me again... [Smile]

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 ]
_________________________
Later,   [b]Mad[/b]ruga

Top
Page 1 of 5 12345>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 180 anonymous users online.
Newest Members
diefnet, Arogya, gkustra, emnipetro, Hirze
17644 Registered Users

Generated in 0.041 seconds in which 0.012 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org