#69817 - 2002-09-17 02:43 AM
Re: KiXtart Golf V: Game24
|
Fernando Madruga
Starting to like KiXtart
Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
|
Oops...
I missed that "real math" thing...
Anyway, here's the revised script.
code:
BREAK ON Global $Target $Target = 24 $ErrorMargin = 0.0001 $rc=SETOPTION('Explicit','ON') $rc=SETOPTION('NoVarsInString','ON') $rc=SRND(@MSECS)
? 'Game24 KiXtart Golf running under KiXtart v'@KIX ? '' test24(1,2,3,4,1) test24(2,2,6,8,1) test24(4,4,6,6,2) test24(3,3,8,8,2) test24(RND(9),RND(9),RND(9),RND(9),3) 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 $str = 'In => '+$i1+', '+$i2+', '+$i3+', '+$i4+'; Out => ' $out=Game24($i1,$i2,$i3,$i4) $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 $error=Execute("$$result=("+$out+")") $result=Trim($result) $str = $str + $out + " = " + $result if ( $behaviour = 3 ) $str = $str + " => Not sure..." 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: 7 combinations ; (ab)(cd) ; (ab)cd ; (abc)d ; a(bc)d ; a(bcd) ; ab(cd) ; abcd ;! function game24($a,$b,$c,$d) endfunction ;! ;!
Being such a big problem, I'd sugest to this group to come up with a 100% working solution for finding the answer and adding a function named checkresult or something else to the test program that would take the {edit}expression{/edit} and return true if the result is the expected one. One should be allowed to use that function in one's code, so as to save a lot of cdlbs/ints/adding error margins/whatevers to the code. I think we all could benefit from that... Not only in the interest of making one's code shorter, but mainly in making it a lot more readable and focusing on the problem at hand, instead of in ways to best deal with what seems to be some incongruencies in the language itself...
Just my two cents...
{edit} removed poll {/edit} [ 17. September 2002, 20:39: Message edited by: Fernando Madruga ]
_________________________
Later,
[b]Mad[/b]ruga
|
|
Top
|
|
|
|
#69819 - 2002-09-17 03:21 AM
Re: KiXtart Golf V: Game24
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
The criteria that matters is does it pass the tests that Jens lays out. This is not suppose to be a perfect algorithm or data engine. [ 17. September 2002, 03:22: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#69821 - 2002-09-17 11:03 AM
Re: KiXtart Golf V: Game24
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
KixGolf v3.0.3 score = 449, running under KiXtart v4.11 RC 1 Time taken (ticks): 10003, Pentium Pro 180.
Passes all tests, including finding a solution for "3,3,8,8"
{edit} I only fixed the "3,3,8,8" when I saw the messages about an hour ago, so I guess Jack is first to post with a correct solution {/edit} [ 17. September 2002, 11:09: Message edited by: Richard Howarth ]
|
|
Top
|
|
|
|
#69826 - 2002-09-17 01:37 PM
Re: KiXtart Golf V: Game24
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
KixGolf v3.0.3 score = 413, running under KiXtart v4.10
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
2024-03-08 [mole]
Thanks for getting the posts back again.
2024-04-18 [MarineV]
will the db errors get fixed????
2024-04-26 [Tonny]
database error, please!
2024-05-09 [NTDOC]
I'm not seeing any errors
2024-05-31 [chojin]
DB is down again
2024-06-04 [selsner]
Still no access, please help!
2024-06-07 [mole]
Looks like DB is back again. Thanks.
2024-06-17 [It_took_my_meds]
We encountered a problem. The reason reported was Database error only visible to forum administrators Please click back to return to the previous page.
2024-07-04 [Armin73]
There is still a database error 🤷♂️
2024-07-09 [0neZero]
There is still a database error 🤷♂️
2024-07-10 [Allen]
DB working a few times in between the messages above. Working again as of 7/10. Thanks Doc
2024-08-31 [NetGnostic]
Bummer, the Database error is back.
2024-09-04 [NTDOC]
Fourms are back up without error for the moment
2024-10-02 [Arend_]
Wll still have database errors ;-)
2024-10-03 [Allen]
Thanks to Doc... it's back.
2024-12-09 [chojin]
could we move kixtart to a new place in order to keep it living ? maybe create a github page and a subreddit?
2024-12-10 [Allen]
do know about moving it, but I know Doc is aware of the DB issue. Should be back online soon.
2024-12-10 [Allen]
don't know...
2025-02-09 [Comet]
Greetings. I installed KiX on my new Windows 11 computer, and joined this foum. Hello World!
2025-02-10 [Allen]
Welcome
2025-03-07 [Comet]
UBB Error We encountered a problem. The reason reported was Database error only visible to forum administrators
2025-06-30 [mole]
Thanks for getting this working again.
2025-07-28 [mole]
UBB Error We encountered a problem. The reason reported was Database error only visible to forum administrators
2025-08-01 [Arend_]
I think it's fixed, I don't have the problem.
2025-10-06 [Comet]
The UBB Error no longer happens for me.
2025-10-21 [M_Moore]
UBB Error We encountered a problem. The reason reported was Database error only visible to forum administrators Please click back to return to the previous page.
2025-10-26 [NTDOC]
System has been cleaned up. Should be okay again now.
2025-10-26 [Allen]
Thank You Doc. Really appreciate your efforts!
|
|
0 registered
and 475 anonymous users online.
|
|
|