PHP Competition Results - The Winner
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

And the winner is…..
Todd Pinel
Where do I start with my praise for Todd’s entry? So much effort has been put into this entry its amazing. As a starting point you should first go have a look yourselves, Todd has helpfully already hosted it here. Let the praise begin..
Implementation
So first and foremost this thing is FAST, Todd has implemented a version of the A* search.
From Wikipedia:
To know which routes will likely lead to the goal, A* employs a heuristic estimation of the distance from any given point to the goal. In the case of route finding, this may be the straight-line distance, which is usually an approximation of road distance.
Along with the A* search Todd also included a Breadth first search so you can make comparison between them. Although Todd had a mixture of procedural an OO I believe the combination in this case worked very nicely.
I also really liked the fact that you could upload new directories which it would store away for you to select from later. The standard directory Todd supplied had a massive 159000 words which just allows you to enter your two words and experiment to see what two words can connect.
Presentation
A really nicely presented and simple to use interface. On top of that a flashy sliding effect along with use of AJAX, what more could a geek want?
Documentation
The entry was well documented and as part of the application Todd included an about page that explains how it all works so others can learn.
Sample Code
This is one of the methods from Todd’s priorityQueue class.
function dequeue() { $result = null; if(!$this->isEmpty()) { $result = $this->peek(); $tempItem = array_pop($this->queue); if(!$this->isEmpty()) { $hole = 0; $child = 0; while($hole < (int)($this->getItemCount()/2)) { $child = 2*$hole + 1; if(($child < ($this->getItemCount() - 1)) && ($this->queue[$child]->compare($this->queue[$child + 1]) < 0)) { $child += 1; } if($this->queue[$child]->compare($tempItem) < 0) { break; } $this->queue[$hole] = $this->queue[$child]; $hole = $child; } $this->queue[$hole] = $tempItem; } } return $result; }
If you wish to download the complete entry click here.
Final Scores
| Entry | Nick | Stuart | Cal Evans | Total |
| 1st. Todd Pinel | 4 | 6 | 6 | 16 |
| 2nd. Evan Chiu | 1 | 3 | 4 | 8 |
| 3rd. Karol Grecki | 6 | 1 | 1 | 8 |
| 4th. JB | 2 | 2 | 3 | 7 |
| 5th. Maurice Fonk | 3 | 4 | 0 | 7 |
| 6th. Rob Haynes | 0 | 0 | 2 | 2 |
Judges comments
Nice UI. The code however, is a mix of procedural and OO. It’s not very maintainable and poorly documented. Also, the fact that it did not run out of the web root properly counts against him. In the end however, It did succeed in transforming hand to foot. It does distress me a bit that this is the best of the examples. After reviewing all of the entries, I went back to this one because it was my favorite.
I like the use of Ajax and the UI was clean and understandable. However, he totally ignores security Best Practices and uses unfiltered input from the user. The heart of this solution is a web service called webmorphservice.php. it’s totally procedural and not very flexible or extensionable. I would have rather have seen the service written in OO so that it could have easily been extended. The author did uses classes within the the service however the classes are totally lacking documentation.
In the end, this one was my favorite because it worked, the UI was clean and the code was (compared to the others) reasonable well done.
- Excellent use of OOP
- Multiple search algorithms
- Clean, functional interface
- Excellent use of Ajax
- Doesn’t report an error when the start and end words don’t exist in the dictionary
So we come to the end! (for now) thanks again to everyone who took part, this includes everyone to submitted an entry, the judges, and everyone else who helped support the competition. I will be in touch with the top three to confirm details for how each of the prizes will be delivered.
My last word on this, do you need a job Todd?
Pingback by University Update - AJAX - PHP Competition Results - The Winner on 21 July 2007:
[…] Link to Article ajax PHP Competition Results - The Winner » Posted at The Programming and […]
Comment by Mgccl on 21 July 2007:
…the speed is fast…
A* search is amazing can’t believe you can implement on this…
AND..
WoW…
who knows there is a levenshtein() function built into PHP, that would totally save me huge amount of time xD…
OWNED everyone!
congrats Todd Pinel
Comment by Karol on 21 July 2007:
That’s quite impressive Todd, congratulations.
You really thought about scalability and the UI is great.
Still, if think your code suffers from poor documentation, maintainability and seams overly complex. But on the other hand, I used 3rd party framework so my job was easier and I could focus on making the code look pretty
Nice work.
Comment by Karol on 21 July 2007:
Mgccl, you should look at other contestants code. Others used levenshtein() including me. If you know php the first thing you do solving a problem is visit the manual, it’s a language were most of the common problems are already solved by built in functions.
Comment by Evan on 21 July 2007:
Yay Todd! I’m very pleased to see that your entry is a clear victor. When I first checked it out after you posted it, I wondered if I even had a chance. I’m glad your silly watch didn’t keep you from winning this!
Comment by Rob Haynes on 21 July 2007:
Congrats, Todd. I really like the use of OO, the coding style, and the A* search. Super-nifty!
Comment by John on 22 July 2007:
Forget that - just seen it - very impressive.
Comment by John H on 22 July 2007:
Awesome, Todd. Congrats!
While the criticisms might be valid, the thing looks and works great and the performance is outstanding. After all, this is essentially a proof of concept and not necessarily intended to be a production-ready application.
Pingback by developercast.com » Nick Halstead’s Blog: PHP Competition Results - The Winner on 23 July 2007:
[…] Halstead has posted the winner of the PHP programming competition - Todd Pinel: Where do I start with my praise for Todd’s […]
Comment by Todd Pinel on 24 July 2007:
Awesome wicked!! Thanks everyone I just got back from a weekend away and what a great surprise to come home to!! This contest was first and foremost just fun!! I had a great time getting into this project and then watching with anticipation as the results poured in.
This was initially just a shot in the dark to see what I could come up with and then because it was so much fun I started tweaking and trying different things to make it more efficient. The presentation and user interface were more of an afterthought so hopefully that explains the shortcomings you see. The criticisms from the judges on these points are well deserved and very valid.
The “heart” of the solution was not really a webservice (even though I put that in the file name), it was something I just threw in to separate some of my code out of the main page and it also let me use the scriptaculous slide effect for geek points. I felt guilty even calling it a webservice… My intentions were with more time to create a proper webservice using NuSoap or something else 3rd party. One thing I’ve found is creating webservices in php is much more of a hassle then say creating them in .NET. So I think it’s a testament to the judges ability that they caught that one and called me out on it:)
The security issue is a bad one as well, the spanking on that is well deserved lol. I also need to come clean and admit I am a bad documenter. Actually I don’t think I documented any of my code at all. I find when I get in the groove and I’m coding and having a good time I don’t comment unless it’s something overly complex. I will usually come back after the fact and try to document with others in mind. This is bad with a capital B and something I definitely have to work on. But I will say when I’m getting paid $$ to create applications I do make sure the stuff I don’t like doing (UI safeguarding and documenting) gets done, and gets done right.
SO in closing thanks to Nick, the judges and everyone else involved. I had a great time and I’ve been able to take a lot away from this little experience in learning as well. And in response to Nick’s last word… I’ve got a job but I’m always looking for work
Pingback by All in a days work… on 24 July 2007:
[…] PHP Competition Results - The Winner The test: write a PHP app to get from one word to another by only changing one letter at a time. Each new word must also be in the dictionary. We had some amazing entries and the winner used AJAX, used A* Search and well deserved its place as winner. (tags: PHP) […]
Comment by blue falcon on 24 July 2007:
Is this guy a class act or what? a testament to the people who participated. congrats Todd
Pingback by Todd’s Blog » Blog Archive » Morphing Chump to Champ on 4 August 2007:
[…] it…. I won the programming competition over at Nick Halstead’s blog!! Check out this link to view the details. Even though I goofed and submitted late I still came out on top. I morphed […]