Entries from March 2006 ↓

Encode Decode

This is a simple decoding puzzle. And will set you for some more interesting ones in the future. The test you can have for yourself, is how *fast* can you solve this.

The encoding / decoding has to work only for digits. 0 (zero) to 9 (nine). The first input will be a string of 10 characters. This encoding key will define what the mapping with 0-9. The next will be a mathematical operation that you have to carry out. The equation will be in encoded format, you have to decode and provide the answer.

Consider the example:

Input 1:
2345678901

Input 2:
12 + 23

Answer:
91 (90 + 01)

See if your code can work even with characters and symbols as the encoding key!

 

Hiding your PHP code

There was an interesting post on the in-phpug list today about hiding and compiling your PHP code such that others can not see it. People do not really do a Google before posting questions to a mailing list and that really sucks. Tarique posted an off-topic message (which actually was quite on-topic) about Help Vampires. People who ask stupid questions on lists and suck the energy of others.

There are obviously a lot of answers to hiding PHP code. Encoding, obfuscating and compiling. There are products like Zend Encoder and ionCube that encode the source code. And this code is decoded by the Zend Engine at execution time. Roadsend and other PHP compilers compile the PHP into a single executable file - especially suited for command line or desktop applications. Then there is the all too popular obfuscating technique. Sometime, people write such ugly code that you don’t need to obfuscate it. At others, you can use products like POBS. Justine Silverton has a nice post about how any encoded code can easily be decoded and how obfuscation is the best answer to the need.

Some related resources:

I feel obfuscation is a better way of hiding the code. Compiling should be used if you want to distribute standalone executables.

PS: Thanks to Tarique for inspiring me to write this up ;-)

 

Microsoft iPod

The next generation iPod is coming from… none other than Microsoft!

Check out: YouTube video.

Amazing, isn’t it?

 

Lazy form designer?

Wanted to design a form? But did not want to juggle with HTML? For the average user (and for some of the lazy us), there are options available.

JotForm.com Allows you to drag and drop form elements to create your survey / contact forms. You can then copy the HTML code and paste in your page. The data goes back to jotform and you can even to analysis of the results.

WuFoo.com is a step ahead of jotform. It looks good and the form field choices are practical.

FormAssembly is another similar service. They also offer wForms Javascript library that makes it easy to add interactions and validations to forms.

Check them out! All of them are AJAX apps and very sleek.

Thanks to Shweta for the links!

 

Bowling Alley

Puzzle 3 - Bowling Alley

You may have played the game of bowling. This time’s logic builder is to build a very simple bowling game to find out how many pins you knocked down.

Bowling Alley

Rules

  • 10 pins. Numbered 1 to 10. As shown in the image
  • Ball will hit a front pin only, hitting a pin is ensured to knock it down
  • Every pin knocked, will knock down two adjuscent pins in the next line if they are up. So hitting 5 will knock down 5, 1 and 2. Hitting 10 will knock down all pins.
  • No need to worry about the angle or speed at which the ball will hit the pin.

Input

  • The number of the pin the ball hit. 0 if no pins hit.

Output

  • The count of pins knocked down.
  • If you can show which pins were knocked, that is a bonus!

Go figure!

And if you wanted to play some online Bowling, you can do that on Yahoo! Games