|
|
|||||||
code:; This function scores the specified file and returns the KixGolf score. [ 04 June 2002, 19:46: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Nice work Howard - ok, we have our clubs (Kixtart) and now we have our scorecards (KixGolf), all we need now is a fairway (Jens) and a rainy weekend ... four !!! [or should we say: four point one zero!!!] -Shawn |
||||||||
|
|
|||||||
So Howard, I guess the strategy would be to develop our solution as a UDF (assuming the puzzle was presented as such) in a seperate file, say kixgolf.kix, and this script would contain just a single function - the UDF being worked on. Then we would also have a "proof script", that included and called the puzzle UDF, this would be our driver script. Then, we would run your kixgolf script against our solution script, and that we be the official golf score, yeah ? -Shawn |
||||||||
|
|
|||||||
Once presented with a problem, we could all write a solution then post just the KixGolf score. It would be interesting if everyone that tried would post thier score even if it was not the best. They could then retry and post an improved score if possible. Then after 24 hours we could post the code. The solution could be what ever was called for, a UDF or just script code. You would save your entry to a file (you choose the name). Then score your solution by executing: Kix32 KixGolf $A=YourFile You will first have to save the above code to a file called KixGolf.kix. It just so happens that I used the script on itself just to see how many strokes it was. {edit} I see how the score for the scoring script can be improved by one stroke already. [ 04 June 2002, 16:08: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Might be able to improve the kixgolf script score by a few strokes if you used the split function to "parse-out" the script, line-by-line. A default split (no second parm specified) should be able automatically skip over all the white-space that your checking for now, then all thats left is to do some sort of instr($c,";") to get at the comments ? -Shawn |
||||||||
|
|
|||||||
slight problem with the script: What if someone encloses a ; between quotes? Or what if a space is enclosed between quotes? Shouldn't these count as part of your score as well because they are pertinent to the code? IMHO: The only spaces or tabs that shouldn't be counted are at the beginning and end of a line. All text within quotes should be counted. Other characters above ASCII 127 should count as well, because who would use them unless they pertained to the code? Brian [ 04 June 2002, 16:28: Message edited by: BrianTX ] |
||||||||
|
|
|||||||
Good catch. Any suggestions to correct it. If not, I'll look into it. Questions: Should all text within quotes be counted? What characters should definitely not be counted? Before we start using it, I want it to be sound and everyone buy off on it. [ 04 June 2002, 16:32: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Brian, would you penalized someone for: $A = 1 vs. $A=1 or $A=1 ;Set var $a because the spaces are not at the beginning of the line? [ 04 June 2002, 16:35: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
You have a good point, but I thought the objective was NOT to maximize readability, but to minimized the size of the file. If you're talking about having a space where one need not be, then why penalize for the size of variable names, either? Either you can optimize for execution speed (i.e. number of keywords, variables, operators), or you can optimize for size. Just my 2 cents. Brian [ 04 June 2002, 16:42: Message edited by: BrianTX ] |
||||||||
|
|
|||||||
I guess since we have a potential scoring script that could permit some enhanced readability we could score around those additional spaces. The variable length is also a good point but that would start to complicate the scoring script. I guess we need to clarify what is really important and what the ultimate goal really is. If we really want cryptic hard to read/understand code we could go with raw file size, but if the goal is to strive for good coding technique then we could permit some improved readability and attempt to only count applicable code. I just want to write the solutions and had a hard time understanding how they compared to to others. This is why I wrote the scoring script. that way we all could easily calculate a score based on the same rules. We just need to clarify what those rule will be. [ 04 June 2002, 16:52: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
I'm with you on that! I agree that a scoring script/function is a great idea. I just think that we need to make sure that the rules regarding what syntax is counted follows common sense. Obviously, having extra spaces where they are not needed is done strictly for readability, but some spaces are still necessary for scripts to function properly. Examples: code:Cannot be shortened to:If $hello = "hi, how are you?" $yes = 1 Endif code:However,If$hello="hi,howareyou?"$yes=1Endif code:can be shortened to:$a = $a + 1 code:I suppose my point is that KiXtart code needs spaces and carriage returns in some cases and in other cases does not. As such, should these be counted?$a=$a+1 I feel that definitely ALL characters in quotes should be counted. As for counting which spaces are necessary and which are not, that is probably not very easy to do.. that's why I suggested counting all spaces not at the beginning or end of the line. If this sounds like it is making things too complex, then it's not really a big deal. Any further thoughts? Brian |
||||||||
|
|
|||||||
The Script at the top of this post has been modified to count all characters enclosed in quotes. |
||||||||
|
|
|||||||
I guess I should chime in, too, since I did manually counting for the scores. Thus code:both lines get the same score since the spaces are not important.$a=$a+1 Also, code:will also result in the same score. Oh, and everything enclosed within wuotes gets counted, too.IF $a=1 ? 'test' ENDIF That's why i think a GolfScore UDF is hard to implement because people write code differently. Anyway, I will try to come up with another challenge by this weekend (couldn't do anything last weekend because I trashed my home computer with a stupid mistake). I will also update the rules that nobody is allowed to post a solution within the first 24 hours except the KiXtart Golf score. In a second 24 hour period, everybody is allowed to post code and improve other people's code, too. Therefore, the fairways will get harder, too. No more par 3's. [ 04 June 2002, 20:11: Message edited by: sealeopard ] |
||||||||
|
|
|||||||
Jens, did you give the KixGolf.kix a go around yet? If not, please check it out and let me know if it scores as you would. |
||||||||
|
|
|||||||
I thought of another situation.. what if you have single quotes inside double quotes or the other way? How will you handle that? (Howard, hope you don't mind.. I borrowed a little from your script...) I added enhancements including multiple quote handling, file closing, better text formatting on printed messages.... Give this script a go: code:$f is passed on the commandline$Q = 0 $f=filename.kix Brian |
||||||||
|
|
|||||||
Brian, I don't mind help but I do not quite understand the double quote issue that your code corrects. The currently posted code above handles quotes within quotes. Both the current script and your script seem to yield the same results on my test files. I wasn't concerned with the nicety of using close since file handle "1" isn't used again and would be forced closed when Kix32 exits. Formally closing the file handle is better style but I do not believe it matters in this case. I do like your use of the "&" to keep $Q and $R to either "0" or "1". This reduced the code requirement that my empty string or ASCII value approach required. You score some points. [ 05 June 2002, 02:32: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
how about just manually stripping out comments and not counting any spaces, even if in text. If you have more and a few spaces, you would probably have quite a few 'words' which would most likely push up your score anyway. 4 additional 'words' would probably have about 10-15 or more characters in it, the 3 spaces wouldn't make a big deal of difference. The idea is efficiency... succinct(sp) output should be a requirement also |
||||||||
|
|
|||||||
Radimus, I think that we are just about finished with the scoring script. If we can agree on the script rules, scoring would be much faster. Did you give the scripts a try yet? |
||||||||
|
|
|||||||
When can I supply CODE for you guys to clean up? hehehe |
||||||||
|
|
|||||||
Well Doc, you have to be "in the game" to get your code scanned - so we'll make sure to invite you to the "Kixtart Classic Invitational Golf Tournie" this weekend (if we play). Depends on the "weather", and on "whether" Jens can get another course designed ... |
||||||||
|
|
|||||||
The Sarge is jumping up and down, yelling: can I play? can I play? please, please, please !!! [ 05 June 2002, 13:22: Message edited by: DrillSergeant ] |
||||||||
|
|
|||||||
LOL, as long as you promise to stay - and post at least once a day ! Howard, Jens, I'm getting a little nervous now - all these other big guns want a piece of the action - afraid my Kixtart slice might come back to haunt me ... -Shawn [nice to see you back my friend - missed you !] |
||||||||
|
|
|||||||
Okay, just to make it official: Despite having a dead computer at home right now (messed up the BOOT.INI during a repartitioning operation [and yes, I do have a backup ;-)]) I am already designing a new course. It will be posted on Saturday morning EST and will contain updated rules for KiXtart Golf to make it a) more challenging, b) more interesting, c) give you the chance of messing with others people's code, too. I am also soliciting ideas for the coding challenge, it does not need to be anything practical, though. I will also give the KiXGolf script a try. [ 05 June 2002, 16:05: Message edited by: sealeopard ] |
||||||||
|
|
|||||||
You're right, Howard. The problem with the quotes was in MY script, not yours. I had just assumed you had to work around it as well. After counting, I think I only saved about 5 keystrokes total in the script. Brian |
||||||||
|
|
|||||||
We seem to concur... KixGolf.kix is my code KixGolf2.kix is Brian's code C:\Data\Scripts>%tmp%\kix32 kixgolf.kix $A=KixGolf.kix KixGolf score = 393 C:\Data\Scripts>%tmp%\kix32 kixgolf.kix $A=KixGolf2.kix KixGolf score = 335 C:\Data\Scripts>%tmp%\kix32 kixgolf2.kix $F=KixGolf.kix KixGolf score = 393 C:\Data\Scripts>%tmp%\kix32 kixgolf2.kix $F=KixGolf2.kix KixGolf score = 335 [ 05 June 2002, 17:48: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Ok, probably too late to mention this (and may be repetitive) but I always thought what we were counting was the "non-white-space" in the script. The way I was doing that was with Microsoft Word and the "wordcount" option in the Tools menu. Specifically the Character Count reported under that. If I take Howards script, and strip-out the comments, I get a count of 385 characters. Does that make sense ? Why the descrepency ? Sorry for bumping this to the top again - but I mean, we should sort this out because, by my reckoning, we got two scripts that report different results, yeah ? ps. oops. is that because your are counting the whitespace inside quotes, right ? [ 05 June 2002, 19:57: Message edited by: Shawn ] |
||||||||
|
|
|||||||
Hey Jens, There a bunch of stuff on this board that isn't practical... Why should this be any different? |
||||||||
|
|
|||||||
Yes Shawn I have 8 white-space characters in quotes. That added to your 385 makes 393. I am glad to see that the code was at least executed a few times. [ 05 June 2002, 20:17: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Whitespace (actually anything) inside quotes does count. So code:should result in a score of 18 since only the space between ? and doesn't count.? 'This is a text!' |
||||||||
|
|
|||||||
Jens, it appears that your right! C:\Data\Scripts>%tmp%\kix32 kixgolf.kix $A=junk.txt KixGolf score = 18 where junk.txt = code:? 'This is a text!' |
||||||||
|
|
|||||||
Yeah, and I did this even without KiXtart Does that make me an old-timer? |
||||||||
|
|
|||||||
Right than ... lets hit the links ... |
||||||||
|
|
|||||||
It seems pretty slow... I wonder when the KixGolf will start? Brian |
||||||||
|
|
|||||||
I already have an idea and will post the next KiXtart Golf challenge on Saturday morning EST. |
||||||||
|
|
|||||||
Howard, Your KixGolf scoring script is reporting to few point !!! Each CRLF must be counted as one point (nessesary whitespace) Also it dosn't count the nessary whitespaces inside the code, your script will count this code: code:As 15 pointsIf $a>5 $x=1 EndIf Assuming this would be working KiX-code: code:The result should be 18, because all the whitespaces are required.If$a>5$x=1EndIf The following UDF, also counts required whitespaces, it might stil need some minor ajusts. I have added the possibility to count parts of a script. If the optional parameter $CountMarkers is used and <> '' or 0 the UDF wil look for the line: ;GolfStart before beginning to count And wil stop counting when the line: ;GolfEnd is found. code:-ErikFunction KixGolf($A,Optional $CountMarkers) ps. I belive that only expirienced 'KiXters' will use this function, so it is not commented on how to use. I won't release it in the UDF section because i am sure it can be improved, and maybe some of you wil have something to add. Also, this UDF is of no general use, so maybe this or something similar should be linked directly to the active Golf tournament. [ 17 July 2002, 22:19: Message edited by: kholm ] |
||||||||
|
|
|||||||
'If$a>5$x=1EndIf' should be 'If $a>5 $x=1 EndIf' and is therefore KiXtart Golf score 18, indeed. Nevertheless, the @CRLF is not counted as per the rules. i am not aware of any programming Golf competition that counts the CRLF as a character. |
||||||||
|
|
|||||||
so, we should work around with crlf with maybe 2000000 strokes which is working... cracking is possible you know. would be nice to make that sized script with score of 454 |
||||||||
|
|
|||||||
Jens, You have to count CRLF as ONE whitespace, because this code is also reported as 15 points code:Statements has to be separated by at least one whitespace, being:If $a>5 @CRLF Space Tabulator If you omit to count the @CRLF the reported size wil not be of an operational script!! -Erik |
||||||||
|
|
|||||||
The goal of a golf tournament should be to create the smallest WORKING KiX-script The current rules state: 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. I my opinion this should be refrased to: Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the code to work. @CRLF counts 1 if the line containes code !!!! If the goal of the golf tournament is to find the size of the smallest possible WORKING KiX-script to accomplish the job @CRLF has to be counted as 1 point when a line containes code. Observe that @CRLF would normally count as 2. So you do get a small discount -Erik [ 18 July 2002, 01:16: Message edited by: kholm ] |
||||||||
|
|
|||||||
I'll let you guys argue this one out. The code I provide strips all white out and counts what left. I have not sat down to to examine all the possibilities where a white space character is or is not required. I do count all spaces within quoted strings. I think that as long as we measure with the same yard/meter stick the judging will be OK, especially when the spread seems to be 1,000 strokes. If the finalist are 1 or 2 strokes off at the end and they want to be so detailed, then they can counted anyway they want. |
||||||||
|
|
|||||||
Howard, I know you rest your case. Your script counts as expected by the current rules!! But if you use a KiX statement with 'many' reserved words like: For Each $x In $y Or For $i = 1 To 10 Step 2 The score wil be unfair if you don't count in the nessasery whitespaces. Summarizing: Your script is flawles BUT I uppose to the current rules. -Erik |
||||||||
|
|
|||||||
Erik: I get your point. I guess we then should count the @CRLF as one stroke, namely the [ENTER] key. The added sideeffect would be that less lines of codes result in less strokes becasue of less @CRLF. I will have this corrected in the rules. Erik: Thanks for the discussion on it. BTW, do you participate in the current challange, there's still time to join since we won't go into the second phase until Saturday evening EST (midnight board time). |