After seeing the reponse to the recent programming challenge put up by Michael I thought I might put up another challenge of perfection - Make it Small. I hope to make this a regular challenge and feel free to PM me any suggestions.
The goal is to create a php code solution for a given problem and see who can make the smallest snippet of code (by lines and/or characters) to suit. No prizes or giveaways - just a good fun challenge and a way to show off your skill(z). Anyone can create a solution for a problem but at the end of the day its how you achieve it that makes the difference.
Challenge 1 - Outputing times for a select box
The Issue
You need to create a single function that returns an array of all of the possible times from 12:00AM to 11:45PM in 15 minute increments with a prepended zero for hours/minutes less then 10.
Summary
* 12:00AM - 11:45PM
* 15 minute increments
* Prepended zero for hours/minutes (eg. 01:00AM NOT 1:00AM)
Sample array output
$time[0] = '12:00AM';
$time[1] = '12:15AM';
$time[2] = '12:30AM';
$time[3] = '12:45AM';
$time[4] = '01:00AM';
$time[5] = '01:00AM';
........
$time[] = '11:30PM';
$time[] = '11:45PM';
Results so far
(All submissions close one week from original post time)
Characters counted excluding spaces and variable names - lines count as one character. Execution time based on being run 200 times on same machine.
James Gifford
68 characters
0.65 seconds
m4rw3r
75 characters
0.63 seconds
wiredesignz
113 characters
1.29 seconds
xwero
276 characters
0.65 seconds