Reputation: 67233
What is a classic programming puzzle which will require a lot of conditional logic and branches to solve?
Thanks
Upvotes: 2
Views: 829
Reputation: 4762
If the purpose is for an interview (i.e. you need to have a candidate bang out some code as part of the evaluation process), I've always liked Project Euler question 11.
If it's for your own use to learn a new language, etc. I prefer some of the code kata at codingdojo.org (the OCR one is pretty entertaining in any language).
Upvotes: 2
Reputation: 386
I like the problem of writing a function that computes the least number of multiplications to compute x^N (e.g., for N = 30, you can compute x^N with 6 multiplies - x -> x^2 - > x^3 -> x^5 -> x^10 -> x^15 -> x^30.
There's no known efficient algorithm, so you have to use branch-and-bound. The conditional logic and branching come in when you are trying to bound. See this wikipedia article for more details - http://en.wikipedia.org/wiki/Addition_chain
Upvotes: 3
Reputation: 8141
Here are a lot of small programming puzzles. a Lot of them are about logic
Upvotes: 2
Reputation: 241701
Eight queens and Towers of Hanoi are classics. Solving Sudoku is quite interesting too and is really a graph coloring problem in disguise.
Upvotes: 9