Page 3 of 5 <12345>
Topic Options
#70104 - 2002-09-24 02:57 AM Re: KixGolf Results/Code
Fernando Madruga Offline
Starting to like KiXtart

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
HURRA! You did it! [Smile]

(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! [Smile] )

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

Top
#70105 - 2002-09-24 03:08 AM Re: KixGolf Results/Code
Fernando Madruga Offline
Starting to like KiXtart

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

[Smile]
_________________________
Later,   [b]Mad[/b]ruga

Top
#70106 - 2002-09-24 03:14 AM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I am looking to save a little more than that. [Wink]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70107 - 2002-09-24 03:37 AM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

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

Top
#70108 - 2002-09-24 04:15 AM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Fernando, cat got your tongue?

[ 24. September 2002, 04:16: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70109 - 2002-09-24 10:06 AM Re: KixGolf Results/Code
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
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

Top
#70110 - 2002-09-24 11:35 AM Re: KixGolf Results/Code
Fernando Madruga Offline
Starting to like KiXtart

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
Nope. Neither of my two cats ate my tongue... [Smile]
I just had nothing more to say! Although it was a nice boost!

I've been busy working on my own code... [Smile]

BTW: Do you mind if I "borrow" your parenthesis generation code? [Smile]

[ 24. September 2002, 12:09: Message edited by: Fernando Madruga ]
_________________________
Later,   [b]Mad[/b]ruga

Top
#70111 - 2002-09-25 12:27 AM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
All's fair in phase two. Beg, borrow, and steal. All code is fair game.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70112 - 2002-09-24 02:50 PM Re: KixGolf Results/Code
Jack Lothian Offline
MM club member
*****

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

Top
#70113 - 2002-09-24 04:08 PM Re: KixGolf Results/Code
Fernando Madruga Offline
Starting to like KiXtart

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

Top
#70114 - 2002-09-24 04:11 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Jack, no I don't, in fact it adds a character.
$e=Split("+ - * /") = 19 spaces inside quotes are counted.

$h = "+","-","/","*" = 18
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70115 - 2002-09-24 04:13 PM Re: KixGolf Results/Code
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Does kixgolf count the spaces inside the quotes?
_________________________
Jack

Top
#70116 - 2002-09-24 04:15 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Yes. Turn on the KixGolf debug (;~) and look at the log.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70117 - 2002-09-24 04:15 PM Re: KixGolf Results/Code
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22303
Loc: OK
yes, if not the code has been changed...
it should anyway...

test it.
_________________________
!

download KiXnet

Top
#70118 - 2002-09-24 04:20 PM Re: KixGolf Results/Code
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Thanks - just goes to show assumptions should always be tested.
_________________________
Jack

Top
#70119 - 2002-09-24 04:40 PM Re: KixGolf Results/Code
Howard Bullock Offline
KiX Supporter
*****

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

Top
#70120 - 2002-09-24 04:43 PM Re: KixGolf Results/Code
Jack Lothian Offline
MM club member
*****

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

Top
#70121 - 2002-09-24 05:07 PM Re: KixGolf Results/Code
Fernando Madruga Offline
Starting to like KiXtart

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

Top
#70122 - 2002-09-24 05:35 PM Re: KixGolf Results/Code
Jack Lothian Offline
MM club member
*****

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

Top
#70123 - 2002-09-24 07:14 PM Re: KixGolf Results/Code
Anonymous
Unregistered


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.

Top
Page 3 of 5 <12345>


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

Who's Online
1 registered (Allen) and 150 anonymous users online.
Newest Members
Hdrthtsr19956, Kylie99, msmile042, rayd8, HardKn0X
17597 Registered Users

Generated in 0.135 seconds in which 0.05 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