Codeworx Design Studio / Dev

Welcome to the Codeworx Design Studio Development Blog! A little place where the CX Development Dept. can post and express our thoughts!

Thursday, January 04, 2007

Solutions to the Cracker Barrel Puzzle

I was very happy to check my email the other night and find that my blog had received its very first comment. The comment was from someone asking for the solution to the Cracker Barrel Puzzle, so I’ve decided to publish all the solutions that I found when I wrote the program.

Now as a little background you must understand how to interpret the solutions, so start off by marking your puzzle as shown in the diagram below:



The reason is because there are 36 potential “moves” that are listed below:

124, 136, 247, 259, 358, 36A, 456, 421, 47B, 48D, 58C, 59E, 631, 6AF, 654, 69D, 742, 789, 853, 89A, 952, 987, A63, A98, B74, BCD, C85, CDE, DEF, D96, D84, DCB, E95, EDC, FA6, FED

For example the first rule “124” should be read: “golf tee in hole 1 should jump over tee 2 and land in hole 4”. Once you understand these rules you can quickly work through the solution.

The solution file for download contains just over 13,000 solutions in the following format:

15: DEF,69D,259,742,D84,FA6,247,36A,BCD,A98,D84,742,124,

The first number is the hole to leave a golf tee out of. In this case it should be hole 15 or on our board, hole F (15 hex is F). From that point you can work through the steps DEF, 69D, etc until you only have 1 golf tee left.

The solution file is available for download here: http://www.codeworxdesign.com/bkn/Sol-Output.txt

Enjoy working through the solutions and thank you for the comment, I encourage everyone to leave a comment and ask a question, make a suggestion or issue a challenge…

~ Bobby



Saturday, December 30, 2006

Cross Domain AJAX Calls and the RSS Reader

Just the other night I sat down and decided to write an RSS reader that could be easily embedded into a web page. My plan was to use AJAX to pull the news feed and display it. I had just finished up another AJAX test project the week before and so I decided to use the Prototype library. Everything seemed very simple, I completed the code to download the feed and display the top 5 or so headlines in a nice little box. I even had a nice little spinny while the feed was downloading.

Just when I thought I was finished I opened the reader in Firefox and that is when my fun first started. The reader wasn’t working! I checked my code, I checked the Firefox console and there were no errors. Thinking it might have been a problem with Prototype I reverted back to some AJAX code that I had used before and re-wrote the reader to use it. Same issue except this time I was getting a security error in the console. A quick Google revealed an unfortunate issue. Firefox did not allow cross domain calls, meaning because the call was not coming from the same domain it is considered a security concern. I did find some code that you could add that would force Firefox to ask whether the user wanted to download the feed, but knowing that it would cause concern for most users, I decided to cut my losses and just display a nice message stating Firefox was not supported at this time.

Thinking I was complete I loaded it onto a test server and went for a look-see. Hmmm, no feed! Looking at the bottom of my IE I see the all so familiar error page icon indicating that I had a scripting error and sure enough, I get the message, permission denied….

Doing a little more research on the cross domain AJAX issue I realized that IE had the same security restrictions when attempting a call on a remote server versus running the content and making the call locally which I had been doing with Stresser and the RSS Reader. This was very frustrating and so now I was trying to figure out how to salvage the work I had done.

Unfortunately, I did not find a “clean” way around the cross domain issue and so I was forced to use a different method. The new method involved creating a server side page that would download the RSS feed, parse it and create a JavaScript file that could be included by the user.

A most fun night…

~ Bobby

Sunday, December 17, 2006

CODE POST: Stresser (Web Application Load Utility)

A couple weeks ago I was presented with the challenge of testing load on a particular web application and I needed a tool to do nothing but generate page requests. I had been playing with various JavaScript libraries such as Prototype, Moo FX, Script.aculo.us and decided I would try to create a basic web application that used AJAX to generate a number of random asynchronous calls to a web application.



I ended up choosing Prototype, and although in the past I had created my own AJAX code, the Prototype library made it surprisingly simply. I looked over the documentation for Prototype and within minutes I had modeled the framework for my stress tool in just a few lines of code.

The rest was just the basics and although not the most elegant code it was functional and the premise behind "Stresser” was simple. You specify a URL that you want to send HTTP requests to and specify what parameters you want passed. I kept the parameters in what I called a "Parameter Bank” and once you specified the interval it would send a new request you could begin generating traffic. To ensure there was some feedback as to whether the result had changed, I used Paul Johnston’s Javascript MD5 implementation to hash the results and output the size.

Always a fan for writing things from the ground up I must admit I was impressed and sold with the easiness of using the Prototype JavaScript Library. I recommend you check it out.

Prototype (http://prototype.conio.net/)

I would also recommend that you check out Script.aculo.us which has some very nice effects (some of which we recently used on the Codeworx Design Site.

Script.aculo.us – (http://script.aculo.us/)

To download the code for Stresser you can visit:

http://www.codeworxdesign.com/bkn/Stresser-SRC.asp

Tuesday, November 28, 2006

As always I try to post at least once a week to talk about some of the buzz around the Codeworx Design Studio Development Department. Today I’m happy to talk about a new service launched called Hardin County Pages Classifieds. This is a simple service we are offering to the community of Hardin County, Kentucky to post items for sale. The service is totally FREE and we already have several listings! From a development perspective we will be improving the system over the next couple weeks to streamline listing and such, but if you have something to sell, post it on the classifieds: http://www.hardincountypages.com/classifieds/listings/submit.htm.

~Bobby

Tuesday, November 21, 2006

The design department is working feverishly on projects this week, but I wanted to take a moment to briefly talk about a great new product from Codeworx Design Studio called Easy Edit. The product launched on Sunday, November 19th and is going to be the first in a long line of services and products geared toward making web site owner’s lives easy.

The premise is very simple; we wanted a basic way for web site owners to make changes to their content because we find very often that web site owners are tied to their web design companies paying high fees to make simple changes. As a business we made a decision that this is NOT the way we wanted to make our money as a company and that we wanted to spend our time designing and building systems for our clients that would bring more value. For a small business every dollar is crucial…

In line with the launch of Codeworx Easy Edit, the Design Dept. put together a nice front page spread (A big Woo Hoo! to the Design Team!).

If you get time please check out our Easy Edit Demo, give it a try and please provide us feedback, we love to get user feedback and hear ways to make the products and services we create better and easier to use.

~ Bobby

Please remember, as a legal disclaimer, that my views are not to be considered the views of Codeworx Design Studio, Inc.

Wednesday, November 15, 2006

FREE Microsoft E-Learning

If you've been reading your MCP Flash then you know about a lot of the great offers from Microsoft, I figured I would pass this FREE offer along to everyone:

Dig Deep and Go Further with Microsoft SQL Server 2005
http://www.microsoft.com/learning/sql2005/digdeep/default.mspx

Enjoy!

~Bobby

Tuesday, November 14, 2006

Creative Representation of Problems

I had originally thought about speaking about a topic more close to home and more about Codeworx Design Studio as a business, but for a variety of reasons, I’m going to instead talk about a different topic with regards to programming in general.

Just this past week alone I found myself preaching a couple times about the importance of being able to represent problems. This was one of the earliest things I was taught by one of my favorite college professors (Professor. Robert Lamphere). Mr. Lamphere was big on representation and while talking with him about various problems & solutions, it actually opened my eyes to other ways of looking at things beyond how I was already representing problems. In my opinion, great programmers possess the skill of representation; I believe this goes to the fundamental skill of creative problem solving. And so as I talk to developers early in their career, I always try to talk about creative representation of problems.

An example that I like to use and which I will talk about here is what I call the “Cracker Barrel Puzzle”. For those who don’t live around Elizabethtown, KY, hopefully you have heard of a restaurant called Cracker Barrel. One of the things that I always liked about Cracker Barrel was that they had these puzzles on each of their tables which consisted of a triangle with 15 holes. In 14 of the holes were golf tees, and the object of the puzzle was simple, try to leave as few golf tees as possible by “jumping” other golf tees. And the term “jumping” follows the rules of jumping in checkers, in order to “jump” another tee, the destination hole had to be free.



One day I was curious how many combinations there were to this puzzle, so I decided to write a program designed to solve the puzzle. After some thought, I determined that instead of trying to represent the program as a shape, perhaps using some kind of array or structure that could “visually” represent the puzzle. The puzzle could be represented as a single string of 15 hex characters and that every move possible could be represented by only 36 rules (each rule defined as 3 hex characters: starting, jumped, destination). By representing the program in this manner, I was able to create a fairly straightforward program that tested various conditions for these 36 rules and ultimately find the combinations that resulted in only 1 golf tee being left on the board.



Ultimately, I ended up finding thousands of solutions and at one point I dumped them all into a database and tried to determine which starting point on the puzzle board produced the most results. With the information I had gathered, what I designated as hole 13, seemed to have the most solutions possible.

But again, the point here is that by representing a problem in a different manner, you are most of the time able to take something that while at first may seem hard and break it down into easier steps. So remember this next you have a creative problem to solve. Try to get inspiration from things around you. I try to model what I can off of nature (bee flight, leaf patterns, rain drops, etc) as it seems that in the world of nature, there is a system which apparently works, but then again, don’t rule out things more mechanical and man made, I remember Mr. Lamphere once talking about using gears as a method of representation where one part of the representation was a small gear and the other part a large gear and the intersection or point at which the teeth of the gears met could potentially be a solution?

~ Bobby