Page 1 of 7 12345>Last »
Topic Options
#69755 - 2002-09-15 12:19 AM KiXtart Golf V: Game24
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
KiXtart Golf V: 24 Game

The general KiXtart Golf rules are at the end of the post. Following are the goal and rules for the current KiXtart Golf challange.

Goal
Use four integer numbers from an integer range of 0-9 and the following basic math operations +, -, *, /, (, and ) in such a way that the resulting formula equals 24.

Rules
    [*]All four integers must be used
    [*]Each integer may only be used once
    [*]Only the basic math operators +, -, *, / and parentheses ( and ) are allowed
    [*]The formula must conform to standard math rules, thus for example 3 / 2 = 1.5 or 1 / 3 = 0.3 period (0.333333....).

    [*]The formula must conform to the math rules of precedence (for example * before +)

    [*]Some combinations can result in multiple solutions, only one is to be returned

    [*]Some combinations may not result in a valid solution, then an empty string is to be returned

Examples:
( 1 + 2 + 3 ) * 4 = 24
1 * 2 * 3 * 4 = 24

The prototye for the function is as follows:
code:
$outputstring=Game24($digit1,$digit2,$digit3,$digit4)

Example
Given the input:
code:
$out = Game24(1,2,3,4)

one possible output string for $out might be
code:
$out = '(1+2+3)*4'

or
code:
$out = '1*2*3*4'

Test Code
code:
BREAK ON

DIM $rc, $out, $result, $i1, $i2, $i3, $i4

$rc=SETOPTION('Explicit','ON')
$rc=SETOPTION('NoVarsInString','ON')
$rc=SRND(@MSECS)


? 'Game24 KiXtart Golf running under KiXtart v'@KIX
? ''

$i1=1
$i2=2
$i3=3
$i4=4
? 'Numbers = '+$i1+', '+$i2+', '+$i3+', '+$i4
$out=Game24($i1,$i2,$i3,$i4)
if trim($out)=''
? 'Incorrect answer, there is a solution to this combination'
? ''+$out+' <> 24'
else
? 'Please doublecheck your solution to guarantee a correct result'
? ''+$out+' = 24'
endif
? ''

$i1=2
$i2=2
$i3=6
$i4=8
? 'Numbers = '+$i1+', '+$i2+', '+$i3+', '+$i4
$out=Game24($i1,$i2,$i3,$i4)
if trim($out)=''
? 'Incorrect answer, there is a solution to this combination'
? ''+$out+' <> 24'
else
? 'Please doublecheck your solution to guarantee a correct result'
? ''+$out+' = 24'
endif
? ''

$i1=4
$i2=4
$i3=6
$i4=6
? 'Numbers = '+$i1+', '+$i2+', '+$i3+', '+$i4
$out=Game24($i1,$i2,$i3,$i4)
if trim($out)=''
? 'Correct answer answer, there is no solution to this combination'
else
? 'Incorrect answer, there is no solution to this combination'
endif
? ''

$i1=3
$i2=3
$i3=8
$i4=8
? 'Numbers = '+$i1+', '+$i2+', '+$i3+', '+$i4
$out=Game24($i1,$i2,$i3,$i4)
if trim($out)=''
? 'Incorrect answer, there is a solution to this combination'
? ''+$out+' <> 24'
else
? 'Please doublecheck your solution to guarantee a correct result'
? ''+$out+' = 24'
endif
? ''

$i1=RND(9)
$i2=RND(9)
$i3=RND(9)
$i4=RND(9)
? 'Numbers = '+$i1+', '+$i2+', '+$i3+', '+$i4
$out=Game24($i1,$i2,$i3,$i4)
if trim($out)=''
? 'No solution found'
? ''+$out+' <> 24'
else
? 'Please doublecheck your solution to guarantee a correct result'
? ''+$out+' = 24'
endif
? ''


$i1=3
$i2=4
$i3=7
$i4=7
$out=Game24($i1,$i2,$i3,$i4)
? 'Numbers = '+$i1+', '+$i2+', '+$i3+', '+$i4
if trim($out)=''
? 'Incorrect answer, there is a solution to this combination'
? ''+$out+' <> 24'
else
? 'Please doublecheck your solution to guarantee a correct result'
? ''+$out+' = 24'
endif
? ''

$i1=1
$i2=2
$i3=8
$i4=9
$out=Game24($i1,$i2,$i3,$i4)
? 'Numbers = '+$i1+', '+$i2+', '+$i3+', '+$i4
if trim($out)=''
? 'Incorrect answer, there is a solution to this combination'
? ''+$out+' <> 24'
else
? 'Please doublecheck your solution to guarantee a correct result'
? ''+$out+' = 24'
endif
? ''

function game24($a,$b,$c,$d)
endfunction

================================================================
KiXtart GOLF - How To Play
================================================================


Most importantly, anybody can play, no age restrictions, no penalties, no handicap!

The object in "real" golf is to hit the ball in the hole in the fewest strokes. The object in KiXtart Golf is to get from input (tee) to target (hole) in the fewest keystrokes.

Example: How many positive elements are in array $a?

Array $a could be of structure $a=[1, 2 ,-3, 4, -5, -7, 8, 9]

One approach:
code:
for $b=0 to ubound($a)
if $a[$b]>0
$c=$c+1
endif
next

for a score of 45.

Another solution is:
code]DO
$b=$b+1
if $a[$b]>0
$c=$c+1
endif
UNTIL $b>(UBOUND($a)+1)[/code]

for a score of 53.

Better approach: Code sample 1

================================================================
KiXtart GOLF - The Rules
================================================================


1) The goal of KiXtart Golf is to score the lowest strokes.

2) Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the line of code to work. Therefore, carriage returns and line feeds do not count or spaces in between the '=' sign when assigning variables, e.g. '$a = $b' scores 5.

3) Code can be constructed any way you like, as long as it is syntactically correct with KiXtart.

4) The final solution MUST pass all test scripts that accompagny the KiXtart golf challenge.

5) The use of '$' as a variable is allowed.

6) In case of questions about a particular way to count the KiXtart Golf Challenge organizer has the last call.

7) During the private coding phase, no code is allowed to be posted. Violations result in disqualification of said player.

8) During the public coding phase, code should be posted, reused, and borrowed from other players.

9) The following script can be used to count the KiXtart Golf score: http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=003608

================================================================
KiXtart GOLF - The Duration of the Competition
================================================================


1) Private coding phase: From date/time of posting the tournament challenge to the following Saturday, 3pm EST (BBS+6 time)

2) Public coding phase: From Saturday, 3pm EST (BBS+6 time) to the following Wednesday, 3pm EST (BBS+6 time)

3) Final results: The following Monday, 11am EST (BBS+6 time)

[ 16. September 2002, 23:07: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#69756 - 2002-09-15 12:24 AM Re: KiXtart Golf V: Game24
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Whoops there it is....

Gonna start th(dr)inking [Big Grin] [Big Grin]
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#69757 - 2002-09-15 12:32 AM Re: KiXtart Golf V: Game24
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Just a little history to this:

I was at a good friends party celebrating his Ph.D. defence (after nearly six years of working on it) when a mutual friend of ours started talking about the '24 Game'. He's a math teacher and using it in his classroom.

Naturally, with the help of a couple of 'Mike's Hard Lemonade', some of us started solving the numbers he threw at us. We stumbled for about 20 minutes through possible solutions for '3 3 7 7' before he told us. I guess, the increasing amount of empty bottles made him believe we'd never find a solution to that one, even though there are multiple.
_________________________
There are two types of vessels, submarines and targets.

Top
#69758 - 2002-09-15 12:52 AM Re: KiXtart Golf V: Game24
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
that really seems tricky.

not an easy job for me this... no no...

getting coffee ready...
_________________________
!

download KiXnet

Top
#69759 - 2002-09-16 12:36 AM Re: KiXtart Golf V: Game24
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, got it in head...
trying to write it in sketchboard gives me headache...

shoul eat up a lot of memory...
_________________________
!

download KiXnet

Top
#69760 - 2002-09-15 01:02 PM Re: KiXtart Golf V: Game24
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens, the 3377 got me badly.
last night scrolled it around about an hour...

anyway, as trying to solve it, let me ask some:
1) we can't use the same number more than once
2) we are to use integers, not floating point counting?
_________________________
!

download KiXnet

Top
#69761 - 2002-09-15 01:07 PM Re: KiXtart Golf V: Game24
Anonymous
Unregistered


Given the origins of the game, do you think it is fair for an answer
to be able to use Kixtarts 'Integer maths' truncation?
i.e. are the following results valid or not ?
a) '(9/2)*6-3'
b) '(9*5+4)/2'
I think we should state that the result should adhere to
'real world' (ie floating point) maths.

Top
#69762 - 2002-09-15 02:19 PM Re: KiXtart Golf V: Game24
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Oh boy...a really tough one this is...

I'm able to find solutions manually. Now finding a way to make KiX think like me...
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#69763 - 2002-09-15 02:27 PM Re: KiXtart Golf V: Game24
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I skipped that option already cause wouldn't that make random number mixes?

meaning also that solution might never come up...
_________________________
!

download KiXnet

Top
#69764 - 2002-09-15 02:32 PM Re: KiXtart Golf V: Game24
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Hmmm, then maybe the other way around...

--> Getting myself to think like KiX [Big Grin]
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#69765 - 2002-09-15 03:04 PM Re: KiXtart Golf V: Game24
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
My 12 year old son plays this game in Math class. Hopefully I'll get some time today to attack this.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#69766 - 2002-09-15 03:44 PM Re: KiXtart Golf V: Game24
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hoby, you are pretty old if your son is almost the same age as I! [Big Grin]
_________________________
!

download KiXnet

Top
#69767 - 2002-09-15 03:46 PM Re: KiXtart Golf V: Game24
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You better not get caught under-age drinking...or is that only a U.S. thing?

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

Top
#69768 - 2002-09-15 03:52 PM Re: KiXtart Golf V: Game24
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hoby, who will know if you drink at home?

and also, if you have papers which say you are 32?
_________________________
!

download KiXnet

Top
#69769 - 2002-09-15 04:05 PM Re: KiXtart Golf V: Game24
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Guys:

Just to clear up a potential point of confusion:
a) '(9/2)*6-3'
==> (9/2)*6-3 = (4.5)*6-3 = 24 is a correct answer for the combination (2,3,6,9)
b) '(9*5+4)/2'
==> (9*5+4)/2 = (45+4)/2 = (49)/2 = 24.5 is an invalid answer for the combination (2,4,5,9)

You must use 'real world' math, not the incorrect integer math module build into KiXtart.

I have updated the rules to reflect this issue.

I have also removed the EXECUTE statement that checks for correct answers since it will fail if the '/' is used and the operation results in fractions. This was an oversight in my coding since I forgot about the messed-up integer math in KiXtart.
_________________________
There are two types of vessels, submarines and targets.

Top
#69770 - 2002-09-15 04:12 PM Re: KiXtart Golf V: Game24
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Another thing. The combination (3,3,7,7) is definitely one of the harder ones to solve and the consumption of alcoholic beverages might not be able to assist successfully in finding that solution.
_________________________
There are two types of vessels, submarines and targets.

Top
#69771 - 2002-09-15 06:02 PM Re: KiXtart Golf V: Game24
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
just wanted to count the possibilities...
I may have counted wrong, but got result of 5040 different compinations...

 
_________________________
!

download KiXnet

Top
#69772 - 2002-09-15 06:29 PM Re: KiXtart Golf V: Game24
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
That's possible [Smile]

I do know that some number combinations can be solved in 80+ ways. However, I just require one single valid combination.

For example (1,2,3,4) has a total of 98 solutions but (3+1)*(4+2) could be considered a mutation of (4+2)*(3+1). Or reformatted:
code:
(1+3)*(2+4)=24
(3+1)*(2+4)=24
(3+1)*(4+2)=24

I've been playing around with it yesterday during my class and I believe it all boils down to four generic formulas. However, you're welcome to code all 5040 unique permutations [Big Grin]
_________________________
There are two types of vessels, submarines and targets.

Top
#69773 - 2002-09-15 06:34 PM Re: KiXtart Golf V: Game24
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I'm trying to, but do you understand how many loops I need there...

I already have on the paper, 17 internal loops...

you know:

for each $ in $var
for each $var in $
....
next
next

and it's getting pretty awfull!

{edit}
for the ones who do not know their path yet, I can say, this is not correct one!

I'm making too complex and now I trash everything and start from the cratch...

[ 15. September 2002, 19:07: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#69774 - 2002-09-15 07:17 PM Re: KiXtart Golf V: Game24
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
I think that I get 18,432 permutations.

There are 4 possible places for operators ie.

Operator*number*operator*number*operator*number*operator*number

The first operator can only take on the value + or - but the other 4 can take on all 4 values. So we have 128 operator permutations.

The parenthesis generate another 6 permutations. Although this number could go higher if one considers (1+2+3+4) to be different from 1+2+3+4 or if (1)+(2)+(3)+(4) is considered to be different from 1+2+3+4.

Finally, then one can rotate the 4 numbers in the 4 positions which gives another 24 permutations.

Thus 128*6*24=18,432

I don't obviously see a way to get a solution that doesn't use brut force. I also not sure limiting the number of solutions that are desired influences the size of the code. The code must potentially search all permutations to ensure that no solutions exist. In fact, requiring only 1 soultion might increase the size of the code.

Just some thoughts.

PS. Maybe the general forum might be a better place for this competition.

[ 15. September 2002, 19:22: Message edited by: Jack Lothian ]
_________________________
Jack

Top
Page 1 of 7 12345>Last »


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

Who's Online
0 registered and 718 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.075 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

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