Programing Puzzles
JAnderson
ask at me.com
Wed Aug 6 23:59:02 PDT 2008
Wyverex wrote:
> just some fun little programming puzzles I found around online...
>
>
> Problem #2 Test if an int is even or odd without looping or if statement
> (Cant use: do, while, for, foreach, if).
>
> Problem #4 Find if the given number is a power of 2.
>
> Post Solutions to this root, comments to someones solution in that thread.
Some of these are pretty standard interview questions. Although I don't
personally like to ask these sort of questions because they are often
about knowing a "trick" which you an easily lookup. The can be fun to
figure out though.
Here's another common one:
| Write a bitcount for a 32-bit number.
And a little more challenging:
| Write a bitcount for a 32-bit number that is less then 15 operations
without using a lookup table.
| Can you do that in 12 or less?
-Joel
More information about the Digitalmars-d-learn
mailing list