Page 1 of 4 1234>
Topic Options
#203324 - 2011-10-23 06:15 PM Kixgolf Mini Putter - End of Month - Public Round
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
=============
The Challenge - End of Month
=============


Your Boss requires that pay checks must be prepared on the final day of the month. Your goal is figure what the last
day of the month is for any year in the future.

*-->A download is available at ( http://www.kixtart.org/forums/ubbthreads.php?ubb=download&Number=248 )

=============
Specification
=============


Given a date in the format of yyyy/mm/dd or yyyy/mm provide the last day of the month in the format of yyyy/mm/dd.

The function SERIALDATE is included in the scoring engine. If you choose, you can use all or parts of the code from
SERIALDATE in your function, however you are not allowed to directly use/call this function. COM Calls to VB or any
other language are not allowed. Must be a all Kixtart solution.

=============
Inputs and Outputs
=============


The input consists of either a date in the format of yyyy/mm or yyyy/mm/dd. Dates in the past do not need to be
considered.


Output must be in the format of yyyy/mm/dd



=================================================================
Notes
================================================================

- The scoring engine has added code to help diagnose which cases are failing. To see test case results:
 Code:
   kix32 kixgolf_eom $verbose=1 ;shows failing results
   kix32 kixgolf_eom $verbose=2 ;shows all results

- The scoring engine expects your (primary) function to be named a().


=======
Scoring
=======


The solution must pass all tests in order for it's KiXgolf Score to be considered.

When posting KiXtart Golf Scores, please include the KIXGOLF_*.TXT file that is created in the script directory. It contains some basic information about the computer that the script is run on and the resulting scores.

============
Test program
============


Test cases are provided to help screen entries and to provide the Golf Score.
Any script that passes the test cases can be submitted. If you are surprised that your solution passed the test cases, please submit it anyway! That will help me identify bugs in the test program.

================================================================
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)

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 does not generate syntax or other errors when running the script in KiXtart.
4) The final solution MUST pass all test scripts that are part of the KiXtart golf challenge.
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 test script contains the official KiXgolf scoring engine
10) Only the person posting a particular score will be recognized for the score, unless the KiXtart Golf Challenge organizer or another delegate posts code on behalf of a player
11) KiXtart Golf (a.k.a KiXgolf) codes must be written inside the KiXgolf UDF collection tags, ';!' and ';!;!'
12) Parameter names of the UDF's can be changed and additional optional parameters can be added.
13) Additional helper UDFs and code can be written as long as they reside inside the ';!' and ';!;!' tags.
14) The use of '$' as a variable is allowed.
15) The UDF layout is up to coder.
16) The UDF is expected to finish in a reasonable time, that is, on modern computers inside 1 hour timeframe.
17) You can submit scores as often as you want.
18) If you reach leading score, you are obligated to post your score immediately so others can try to compete with you.
19) The UDF may only use the KiXtart/KiXforms commands/functions/macros, no other code fragments are allowed.
20) Calls to COM components that are part of a standard default Windows installation are allowed.
21) The use of the KiXforms DLL is also permitted as the KiXforms DLL can now be considered an integral part of KiXtart scripting.
22) Calls to other executables, as long as they are part of a standard default Windows installation are allowed.
23) The UDF should be self-contained (except for any I/O mentioned in the challenge). In particular, you may not do things like fetching extra data from a remote site or file.
24) You may assume ASCII as character set.
25) You may use block comments as the KiXgolf Scoring Engine now supports block comments.
26) You are allowed to only use publicly available versions of KiXtart and KiXforms, private builds or alpha builds are NOT allowed.
27) Your submitted score must include the result print of the KiXgolf test-engine.
28) The SETOPTION() parameters in the KiXgolf script may not be modified and will govern the script behavior. SETOPTION() parameters may change depending on the particular needs of the KiXgolf challenge.
29) Tokenizing the UDF, script, or portions thereof is not allowed.
30) If something is not explicitly denied by the rules, it's allowed.
31) If Confusion arises, arranger of the KiXgolf round has the final say.
32) Additional test cases can be added at any time during the KiXgolf round. The code is expected to pass based on the rules. The test cases may not include tests for all rules and exceptions. Test cases that are added during the public round will not alter the results of the private round.


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



1) Public Round Only. Ends when the new competion starts. Official count down clock to be provided.





*--> You will need the complete package from http://www.kixtart.org/forums/ubbthreads.php?ubb=download&Number=248.


Attachments
kixgolf_eom.zip (521 downloads)
Description:




Edited by Allen (2011-10-25 05:01 PM)

Top
#203325 - 2011-10-23 07:04 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA

Top
#203327 - 2011-10-24 09:10 AM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Wee, a date calculation challenge.. seems to be easy enough, not considering days.
Will grab my putter tonight \:\)
_________________________



Top
#203328 - 2011-10-24 09:27 AM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Aw, whatever I said ...

function a($)
    dim $b
    $ = split($,'/')
    $b = 0,0,3,0,1,0,1,0,0,1,0,1,0
    $a = ''+$[0]+'/'+$[1]+'/'+ (31-$b[$[1]]+(($[0] mod 4 = 0)*($[1]='02')))
endfunction


KiXtart Version  = 4.62
KiXGolf Script   = kixgolf_eom.kix
Scoring Engine   = 3.3
OS               = Windows XP Professional
CPU              = Intel Pentium Celeron
Speed            = 2393 MHz
Memory           = 4096 MB

Tournament       = End of Month
Processing Start = 2011/10/24 09:25:14.953
Processing End   = 2011/10/24 09:25:14.953
Duration         = 0000/00/00 00:00:00.000
# Tests Run      = 18
# Tests Passed   = 18
# Tests Failed   =
Result           = passed
KiXGolf Score    = 134

Thank you for participating in KiXtart Golf!
_________________________



Top
#203329 - 2011-10-24 09:31 AM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
first few obvious strokes.. 128

function a($)
    dim $b
    $ = split($,'/')
    $b = 0,0,3,0,1,0,1,0,0,1,0,1,0
    $a = ''+$[0]+'/'+$[1]+'/'+ (31-$b[$[1]]+($[0] mod 4 = )*(2=$[1]))
endfunction



Edited by Jochen (2011-10-24 09:33 AM)
_________________________



Top
#203330 - 2011-10-24 09:54 AM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
well, the previous is of course built after the leap year rules of the julian calendar which are in the mean time obsolete (since 1564 to be precise)

New rules after pope Gregor:

 Quote:

Leap Year Rules

"Concerning the solar year and types of years.
And concerning the leap year." May 29, 1564
There is a leap year every year whose number is perfectly divisible by four - except for years which are both divisible by 100 and not divisible by 400.


Source: http://www.wwu.edu/skywise/leapyear.html

Please consider adding a few testcases:

2400/02=2400/02/29
2100/02=2100/02/28

In the mean time I'll adapt my code to fit the rules ;\)


Edited by Jochen (2011-10-24 09:56 AM)
_________________________



Top
#203331 - 2011-10-24 10:08 AM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
my first 'gregorian' code for 160

function a($)
    dim $b
    $ = split($,'/')
    $b = 0,0,3,0,1,0,1,0,0,1,0,1,0
    $a = ''+$[0]+'/'+$[1]+'/'+ (31-$b[$[1]] + (($[0] mod 4=) * (($[0] mod 400=)+($[0] mod 100>))*(2=$[1])))
endfunction

with additional two test cases:

2400/02=2400/02/29
2100/02=2100/02/28
_________________________



Top
#203332 - 2011-10-24 10:15 AM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
158

function a($)
    dim $b
    $ = split($,'/')
    $b = 0,0,3,0,1,0,1,0,0,1,0,1,0
    $a = ''+$[0]+'/'+$[1]+'/'+ (31-$b[$[1]] + ($[0] mod 4=)*(($[0] mod 400=)+($[0] mod 100>))*(2=$[1]))
endfunction

_________________________



Top
#203334 - 2011-10-24 10:18 AM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
D'Oh!

function a($)
    dim $b
    $ = split($,'/')
    $b = 0,0,3,0,1,0,1,0,0,1,0,1,0
    $a = $[0]+'/'+$[1]+'/'+ (31-$b[$[1]] + ($[0] mod 4=)*(($[0] mod 400=)+($[0] mod 100>))*(2=$[1]))
endfunction

155
_________________________



Top
#203335 - 2011-10-24 01:27 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
143, look Ma, no DIM

function a($)
    $ = split($,'/')
    $a = $[0]+'/'+$[1]+'/'+ (31-substr("030101001010",$[1],1) + ($[0] mod 4=)*(($[0] mod 400=)+($[0] mod 100>))*(2=$[1]))
endfunction

_________________________



Top
#203336 - 2011-10-24 01:30 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
140

function a($)
    $ = split($,'/')
    $a = $[0]+'/'+$[1]+'/'+ (31-substr(_3_1_1__1_1,$[1],1) + ($[0] mod 4=)*(($[0] mod 400=)+($[0] mod 100>))*(2=$[1]))
endfunction

_________________________



Top
#203337 - 2011-10-24 01:46 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
138 (as there is always a non-numeric char in that string after a number we can omit the length of substr)


function a($)
    $ = split($,'/')
    $a = $[0]+'/'+$[1]+'/'+ (31-substr(_3_1_1__1_1,$[1]) + ($[0] mod 4=)*(($[0] mod 400=)+($[0] mod 100>))*(2=$[1]))
endfunction

_________________________



Top
#203338 - 2011-10-24 02:17 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
134 btw: using right vs. substr is in this case equal in score ..


function a($)
    $ = split($,'/')
    $a = $[0]+'/'+$[1]+'/'+(31-right(_1_1__1_1_3_,$[1])+($[0] mod 4=0 & ($[0] mod 400=0|$[0] mod 100>) & 2=$[1]))
endfunction

_________________________



Top
#203339 - 2011-10-24 04:17 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
haha
 Code:
function a($)
    $ = split($,'/')
    $a = $[0]+'/'+$[1]+'/'+(31-right(_1_1__1_1_3_,$[1])+($[0] mod 4=0 & ($[0] mod 400=0|$[0] mod 99>) & 2=$[1]))
endfunction

 Code:
KiXtart Version  = 4.62
KiXGolf Script   = kixgolf_eom.kix
Scoring Engine   = 3.3
OS               = Windows XP Home Edition
CPU              = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed            = 2793 MHz
Memory           = 768 MB

Tournament       = End of Month
Processing Start = 2011/10/24 09:16:43.286
Processing End   = 2011/10/24 09:16:43.302
Duration         = 0000/00/00 00:00:00.016
# Tests Run      = 18
# Tests Passed   = 18
# Tests Failed   = 
Result           = passed
KiXGolf Score    = 133

Thank you for participating in KiXtart Golf!


Edited by ShaneEP (2011-10-24 04:18 PM)

Top
#203340 - 2011-10-24 04:21 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: ShaneEP]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
you haven't read the whole thread, didn't you Shane?

add these to the ini and you'll fail 1 of 20 tests ;\)

2400/02=2400/02/29
2100/02=2100/02/28
_________________________



Top
#203341 - 2011-10-24 04:23 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
 Code:
function a($)
    $ = split($,'/')
    $a = $[0]+'/'+$[1]+'/'+(31-right(_1_1__1_1_3_,$[1])+($[0] mod 4=0 & ($[0] mod 4=0|$[0] mod 99>) & 2=$[1]))
endfunction


 Code:

KiXtart Version  = 4.62
KiXGolf Script   = kixgolf_eom.kix
Scoring Engine   = 3.3
OS               = Windows XP Home Edition
CPU              = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed            = 2793 MHz
Memory           = 768 MB

Tournament       = End of Month
Processing Start = 2011/10/24 09:21:50.394
Processing End   = 2011/10/24 09:21:50.394
Duration         = 0000/00/00 00:00:00.000
# Tests Run      = 18
# Tests Passed   = 18
# Tests Failed   = 
Result           = passed
KiXGolf Score    = 131

Thank you for participating in KiXtart Golf!

Top
#203342 - 2011-10-24 04:25 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Oh ok

 Code:
function a($)
    $ = split($,'/')
    $a = $[0]+'/'+$[1]+'/'+(31-right(_1_1__1_1_3_,$[1])+($[0] mod 4=0 & ($[0] mod 40=0|$[0] mod 100>) & 2=$[1]))
endfunction


 Code:

KiXtart Version  = 4.62
KiXGolf Script   = kixgolf_eom.kix
Scoring Engine   = 3.3
OS               = Windows XP Home Edition
CPU              = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed            = 2793 MHz
Memory           = 768 MB

Tournament       = End of Month
Processing Start = 2011/10/24 09:24:24.408
Processing End   = 2011/10/24 09:24:24.424
Duration         = 0000/00/00 00:00:00.015
# Tests Run      = 20
# Tests Passed   = 20
# Tests Failed   = 
Result           = passed
KiXGolf Score    = 133

Thank you for participating in KiXtart Golf!

Top
#203343 - 2011-10-24 04:31 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Thanks for doing the research Jochen.

Everyone please add the two cases to the INI.

2400/02=2400/02/29
2100/02=2100/02/28


Top
#203344 - 2011-10-24 04:31 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: ShaneEP]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ok, that one's better I have to confess.

*thinks of a case to spoil it*

edit: Well done Shane, the mod 40 seems to be bulletproof!


Edited by Jochen (2011-10-24 04:35 PM)
_________________________



Top
#203345 - 2011-10-24 04:32 PM Re: Kixgolf Mini Putter - End of Month - Public Round [Re: Jochen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Haha Im sure you will, I would probably never be able to get that low from scratch.
Top
Page 1 of 4 1234>


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

Who's Online
0 registered and 2141 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.092 seconds in which 0.043 seconds were spent on a total of 14 queries. Zlib compression enabled.

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