#69835 - 2002-09-17 03:28 PM
Re: KiXtart Golf V: Game24
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Well it looks like it's back to the drawing board.
|
Top
|
|
|
|
#69836 - 2002-09-17 03:37 PM
Re: KiXtart Golf V: Game24
|
Fernando Madruga
Starting to like KiXtart
Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
|
I think we can rule out one of the 7 situations: a(bcd).
{EDIT} BOY! Was I wrong on this one!!! Read below... {/EDIT} Why? Follow me... We can have one of 4 operators between 'a' and the rest of the expression.
code:
a+(bcd) -> (bcd)+a : does not matter what ops are inside as + is low precedence a-(bcd) -> nothing! : What kind of expression would you need inside parens to get 24 by subtracting to 0..9?? Yes, I know that 0-(-something) will be positive, but we can't have another negative number inside the parens!!! {edit} Actually, we can, but it does not create a solution! {/edit} {edit} And it can be rewritten as not to need the parens! {/edit} a/(bcd) -> nothing! : Again, what kind of number would we need inside parens to get 24? A very small number! In order to be so, we'd need something like a/(b/c/d) because a/(b+c/d) or a/(b/c+d) would not give a number below 1 unless the added item was 0 and even then it would not be "small enough" to get 24... (hope you're still following me!) If we did not use a / inside the parens, then the number would not be between 0 and 1 and so, dividing a number from 1 to 9 by it would not yield the needed result! Finally, a/(b/c/d) can be simplified as a/b/c/d !!! a*(bcd) -> (bcd)*a : We will arrive at this test case sooner or later! So, no need to handle it in here. Please check my assumptions, but I do believe that a(bcd) can be safely left out of the game as we're not trying to get ALL solutions but just ONE!
The same may hold true for more cases, but I have to go now. I'll check the others later... [ 18. September 2002, 02:06: Message edited by: Fernando Madruga ]
_________________________
Later,
[b]Mad[/b]ruga
|
Top
|
|
|
|
#69842 - 2002-09-17 09:59 PM
Re: KiXtart Golf V: Game24
|
MightyR1
MM club member
Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
|
|
Top
|
|
|
|
#69847 - 2002-09-18 02:00 AM
Re: KiXtart Golf V: Game24
|
Fernando Madruga
Starting to like KiXtart
Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
|
You're not on this one? That's bad... It's fun... It's my 1st one from "scratch": all I did in the last one was crop some bytes out of someone else's code... Maybe I'll do some coding this time... I did however continue my findings:
code:
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 '/'
So, and for the purpose of this game that is to find ONE (repeat: ONE) solution, we can eliminate these constructs: (ab)cd, a(bc)d, ab(cd). The (abc)d construct is only used for these numbers (and respective permutations): 1277 == (7*7-1)/2. The a(bcd) construct is needed for these 3 sets: 1346 == 6/(1-3/4); 1456 == 6/(5/4-1); 1668 == 6/(1-6/8) As for the (ab)(cd), 13 is too much to test for... Even 3 may prove to be too much! Hope this helps you guys, even though I may be shooting myself in the foot, but hey! this is just a friendly competition... Gonna do some work, then sleep over it. I'll probably only get back to this in some 48 hours or so to start (and finish) my coding for this one, so don't be surprised if you don't read from me for a couple of days... [ 18. September 2002, 17:31: Message edited by: Fernando Madruga ]
_________________________
Later,
[b]Mad[/b]ruga
|
Top
|
|
|
|
#69849 - 2002-09-19 12:58 AM
Re: KiXtart Golf V: Game24
|
Fernando Madruga
Starting to like KiXtart
Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
|
Well, I could rewrite it to use some kind of "infinite" precision math routines: it would probably take a few days instead of some minutes, but would not fail... However, you have to look at floating point math in another way: is the PC's floating point accuracy enough to overcome potential "rounding" errors? I think that, in this case, where we have only 4 numbers in the range 0..9 and 3 (THREE!) operations, any inacuracy that is introduced is certainly VERY close to 0, that is, below 0.000001 or most likely even lower than that. Today's computers conforms to IEEE 8 byte floating point math: it's inexpensive (processing wise due to the builtin math coprocessor) and has "decent" accuracy (don't feel like digging some specs now!). If you consider that, with only 3 operators, and something like 10+ decimal places of accurate calculation you will SURELY not have an error above the 8th decimal digit, I assume that testing for 24 within 1^-6 is most likely enough... Also, I don't know how to prove this mathematically, but you would not get a number THAT close to 24 with only these 4 digits & 3 operators... I'll do the following: I'll change my generator program to save ALL possible combinations regardless of whether they evaluate to near 24 or not, and I'll then see what is the number that comes closer to 24, without actually being 24 and that shouldn't be 24. I'll post the results later... [ 19. September 2002, 01:00: Message edited by: Fernando Madruga ]
_________________________
Later,
[b]Mad[/b]ruga
|
Top
|
|
|
|
#69850 - 2002-09-19 01:23 AM
Re: KiXtart Golf V: Game24
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Has everyone lost sight of what the purpose of this exercise is? Take a problem with a set of specific given criteria, mix in some KiXtart ingenuity, comradery, and FUN. Uncover some shortcuts, inconsistencies, workarounds, etc. Satisfy the given requirements not all possible requirements. After we play & learn a little, the code can then be written in a percise bulletproof fashion. We are still in the FUN stages. Don't scare away those that don't share is the enthusiasm for extremes.
|
Top
|
|
|
|
#69851 - 2002-09-19 01:44 AM
Re: KiXtart Golf V: Game24
|
Fernando Madruga
Starting to like KiXtart
Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
|
I second that Howard! The only reason I wrote the perl program to compute all possible solutions, was because I figured that, being a small and easily computable set, I could perhaps simplify the algorithm! I did, as 3 types of parentheses constructs can be safely eliminated! BTW: I'm now running the "updated" script, that will save all possible values, correct or not, but I'm doing this only for fun! I want to know if I'm right in my previous post... Meanwhile, and this is not to blame Ruud, perl's floating point implementation is a LOT more robust: I ported the exact same script to KiXtart and (while taking loads more time to run! ), it only found less than half the solutions! In fact, for some numbers, it wasn't even able to find ANY solution when the perl script DID find at least one! Again, KiXtart is certainly *not* the best tool for this "game" in case you're taking it a bit too serious, but it's a good tool for loads of other stuff!
_________________________
Later,
[b]Mad[/b]ruga
|
Top
|
|
|
|
#69853 - 2002-09-19 09:29 AM
Re: KiXtart Golf V: Game24
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
I kinda like the high-brow tangents these things fly off into.
There is always the danger I might learn something new, and to a jaded techie that's one of the major bonuses of this board.
The code I have does *not* work with all possible combinations - it only finds 422 of Fernando's 465.
It's been crippled because of keeping the size down. In the processes I've also doubled the time that it takes to run, just to save 2 characters.
However, it does adhere to the rules and gives the correct results
It's also given me a corker of a UDF that I'll publish once the first round is over. It is so cute I'm going to name my first-born after it.
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 444 anonymous users online.
|
|
|