# Programming Challenges

Show 40 post(s) from this thread on one page
Page 4 of 19 First 1234567814 ... Last
• 08-25-2003, 07:26 PM
tecknophreak
sorry, stuck with the shifting counter, non-shifting is quicker, believe it or not

Code:

```unsigned int reverseBits(unsigned int x) {     unsigned int res(0), cntr(32);     while (cntr--) {           res <<= 1;           res |= x & 1;           x >>= 1;     }     return res; }```
[/B][/QUOTE]
• 08-25-2003, 11:31 PM
Sepero
Nice job, techno.
• 08-26-2003, 01:16 AM
Strogian
Quote:

sorry, stuck with the shifting counter, non-shifting is quicker, believe it or not
Heh, that makes me think of one.. Come up with bitwise-shift and increment (or decrement) functions, using only the bitwise operations. (that doesn't include >> :))
• 08-26-2003, 08:10 AM
tecknophreak
Quote:

Originally posted by Sepero
Nice job, techno.
Why's everyone always got to spell my name wrong? :( Oh, right maybe cause I spelled it wrong in the first place. :D
• 08-26-2003, 09:40 AM
o0zi
I get that all the time as well, teckno:) I've had oozi, OOzi, Oozi, oozy...
Let's get it right people, it's an o, then a zero, then a z, then an i. But Rob will do fine:)
• 08-27-2003, 01:03 PM
tecknophreak
Quote:

Originally posted by Strogian
Heh, that makes me think of one.. Come up with bitwise-shift and increment (or decrement) functions, using only the bitwise operations. (that doesn't include >> :))
can it include << ? So you're looking for a counter?

so we can use ~ ^ & | and what not, but no >>.

Just making sure I have this correct. I'll be spending the next 4 hours running long tests which need barely to no interaction. This'll give me something to do.
• 08-27-2003, 03:40 PM
Strogian
Well, I want functions that replace the ++ and >> operations, so naturally you shouldn't use ++ or >> in the function. :) (<< and -- are also no-good, but I don't think they'd help you anyway :))
• 08-27-2003, 07:06 PM
dchidelf
Do you want replacments for both pre and post increments? (ie ++x and x++)
• 08-27-2003, 08:48 PM
Strogian
Oh, wow. I'd never thought of that. Hey, if you can do it, go ahead! :)
• 08-28-2003, 07:47 PM
mullet
Looks like you have had some interesting theoretical/mathematical challenges, so far. Heres something practical:

Define a simple hangman program
It takes one word as its only parameter
The user has 2x as many guesses as there are letters in the word to guess the word. the user enters a letter on stdin, the program prints out the word, with that guess and any previous ones revealed as letters in the word, other letter are replaced by *. Also printed out is the number of guesses left before the user runs out of time. So a sample run may go as follows:

hangman sameple
e
***e**e
you have 13 guesses remaining
s
s**e**e

etc.

have fun, this is easy compared to some earlier challenges and will hopefully less able programmers a chance to test their skills.

mullet
• 09-02-2003, 11:09 AM
lagdawg
I deciphered Sepero's first code. I mostly figured it out without a program but used it just to help. Anyway, I have attached the code to decipher the code in Perl. Did anyone else get it?
• 09-03-2003, 06:18 PM
Strike
The python rot13 can be made way shorter:

Code:

```def rot13(s):     return s.encode('rot13')```
:)
• 09-03-2003, 08:14 PM
x_Ray
Quote:

Originally posted by Strike
The python rot13 can be made way shorter:

Code:

```def rot13(s):     return s.encode('rot13')```
:)

I actually mention that in the original post... :p
• 09-07-2003, 08:58 PM
zdude255
Heres a java solution for the add 2 numbers without +

Code:

``` public int add(int a, int b){ BigInteger bigA = new BigInteger(a); BigInteger bigB = new BigInteger(b); BigInteger ans = bigA.add(bigB); return ans.intValue(); }```
Sorry for no indent, I did this in galeon
• 09-08-2003, 09:44 PM