Main
Latest
- myXchange July 2008
- The Netherlands at war with Zimbabwe?
- Plazes
- work@cafe
- Critter.co.za
- We got the gear, now kick butt!
- Firefox 3
- Twitter SMS Restored
- Unique IDs in the Google App Engine Datastore
- Unix Timestamp Bomb
Archives
- June 2004
- July 2004
- August 2004
- September 2004
- October 2004
- November 2004
- December 2004
- January 2005
- February 2005
- March 2005
- April 2005
- May 2005
- June 2005
- July 2005
- August 2005
- September 2005
- October 2005
- November 2005
- December 2005
- January 2006
- February 2006
- March 2006
- April 2006
- May 2006
- June 2006
- July 2006
- August 2006
- September 2006
- November 2006
- December 2006
- January 2007
- February 2007
- March 2007
- April 2007
- May 2007
- June 2007
- July 2007
- August 2007
- September 2007
- October 2007
- November 2007
- December 2007
- January 2008
- February 2008
- March 2008
- April 2008
- May 2008
- June 2008
- July 2008
- August 2008
- September 2008
- October 2008
- November 2008
- December 2008
- January 2009
Warcode
I was out most of the day but when I got back I saw Jonathan Endersby's post Codewar on the Clug Park I was almost outraged as I knew here goes a perfectly good 30 mins I'll never see again. However, it ended up being more than worth-while just in terms of fun. :)
However, awesome code there is not much of. However, what there is much of, especially in the PHP world, is absolutely horrible code. I didn't feel up to the challenge of writing nice code so I thought I would add to the scandal instead, which was definitely not very difficult (it's PHP after all):
<?php
$a = array();
for ($i = 0; $i < 6; $i++) {
while (in_array($x = mt_rand(1, 10), $a) || !($a[] = $x)) {}
echo "$a[$i] ";
}
Actually I can't even blame PHP here. This is just out-right disgusting.
Who on earth can read this now? It looks like it's been written by a retard. I should be ashamed! Especially after doing all that work in a conditional statement. What blatant abuse of a computer language! If this was a human language, they would have banned me off the internet due to pushing foul language to a new all-time low.
As Jonathan Hitchcock could rightly point out, this could loop forever. However I do believe that mt_rand is substantially better then the "usual" rand. After all, if you want to write freakish code, might as well do it properly.
Good challenge! Keep them coming! :)
Copyright © 2004-2009 Charl van Niekerk. All articles are released under the Creative Commons Attribution 2.5 South Africa licence, unless where otherwise stated.


0 Comments
Post a Comment