Description:
Hey guys. I'm sorry there has not been a challenge for a long time but I've been very busy. But anyway, here is the new challenge! :D
In this challenge you are asked to code an $isdate() alias that will return if a particular date is valid or not (taking into consideration leap years).
You will assume that the format will always be
dd/mm/yyyy - however you may accept 1 instead of 01 in the date and month, but not 07 instead of 2007 in the year. In other words, since in 0008 there is only 1 significant figure, that should be taken.
Checking of this length is unnecessary. If there are more than 2 digits for d, but they are insignificant - ignore them.
Note: this alias will be based on the Gregorian calendar. Dates will be tested all the back to 1/1/1 (01/01/0001) and to the future 31/12/9999. Checking to see if the date is within this range is unnecessary.
Example:
$isdate(a/a/a) = 0
$isdate(/12/2007) = 0
$isdate(0.1/5/2007) = 0
$isdate(30.1/01/1800) = 0
$isdate(.30/9/1500) = 0
$isdate(01/01/2007) = 1
$isdate(1/1/2007) = 1
$isdate(30/2/2000) = 0
$isdate(29/2/2000) = 1
$isdate(29/2/2001) = 0
$isdate(31/04/2010) = 0
$isdate(29/02/1700) = 0
$isdate(29/02/1600) = 1 |
Rules:
Alias name must be 'isdate'
Alias MUST return 0 if date is invalid or 1 if its valid.
No dlls, coms, sockets, regular expressions, $ctime $asctime, or $duration
One submission per user.
Your code will be taken for EXACTLY as submitted. Nothing will be changed in your submitted code - even if a subtle mistake is found.
Alias will be run on mIRC v6.21.
Script must give correct results after consecutive runs.
File will be loaded into the remotes section.
File we will be using to count the code: countcode.php
Code which exploits countcode will be rejected.
Alias will be run on a mIRC with no variables set - a clean mIRC.
Entries will be judged on code size and whether they return the correct result (1 for valid date 0 for invalid).
Feel free to ask any questions in the forum below.
Good luck!