The Friday Fragment

Published on 23 October 2010
This post thumbnail

It's Friday, and time again for the Friday Fragment: our weekly programming-related puzzle.

This Week's Fragment

This week, we'll take another step in our web service "bot wars:"

Write code to score the results of calling rock, paper, scissors web services. Remember, rock beats scissors, scissors beat paper, and paper beats rock. And bombs and dynamite don't count.

To “play along”, provide either the URL or the code for the solution. You can post it as a comment or send it via email. If you'd like, you can build atop results from our last Friday Fragment.

Last Week's Fragment - Solution

Last week's puzzle continued along our simple web service vein with the flip-side: calling a web service.

Write code to call your rock, paper, scissors web service and keep counts of how many times each is returned.

Here's a really simple solution in PHP:

      $counts = array("rock" => 0, "paper" => 0, "scissors" => 0);
      $url = '';
      for ($i=0; $i<100; $i++)

It's a bit oversimplified (e.g., no error handling), but does the job.