Adding 1 without using =, -, *, /

Started by
42 comments, last by mmmmm 19 years, 10 months ago
quote:Original post by haro
I picture it as little more than a question to determine whether or not an applicant has had any non-college experience in programming. And even if they don''t know the answer immediately, their thought process while trying to solve it can generally tell alot.

Good point, hadn''t thought of that. I like those questions that you posted, still thinking about #3...
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Advertisement
quote:Original post by haro
3. What is a simple fail-safe method of encrypting any given string besides 1to1 replacement?


XOR by a constant!! Be really clever and pick one that looks cool in hex(0xdeadbeef or 0xcafebabe), they''ll never figure it out!!!
quote:Original post by sjelkjd
quote:Original post by haro
3. What is a simple fail-safe method of encrypting any given string besides 1to1 replacement?


XOR by a constant!! Be really clever and pick one that looks cool in hex(0xdeadbeef or 0xcafebabe), they''ll never figure it out!!!


Exactly! Questions 1&3 were amusingly very similiar in their themes.
int AddOne(int i){	int c = 1;	do	{		i ^= c;		c = (~i & c) << 1;	}while( c);	return i;}


cheers! but don''t expect anyone to do your homework again.

This topic is closed to new replies.

Advertisement