Results 1 to 11 of 11
  1. #1
    俺はまんこが大好きなんだよ baseline bum's Avatar
    Post Count
    97,883
    NBA Team
    San Antonio Spurs
    College
    UCLA Bruins
    Here's my C++ implementation of the function isodd

    bool isodd (int i)
    returns true if i is an odd integer, false otherwise

    Code:
    bool	isodd (int i)
    {
    	if ( i == 0 )
    		return	true;
    		
    	int k = ( i < 0 )? -1 : 1;
    
    	srand (time (0));
    	/* to make as many cache
    	 * misses as possible
    	 * while also adding
    	 * an exponential series
             * of recursive calls
    	 */
            int m = round ( ( double (rand ()) / double (RAND_MAX + 1)) * double (RAND_MAX) );
    	if ( isodd (m))
    		return ! isodd (-i + k);
    	else
    		return	! isodd (i - k);
    }
    The stack size would have to be infinite for this function to ever have a chance to return a value for anything other that 0 unless all calls to rand are zero.

    I gotta apply to Microsoft and begin work on Longhorn immediately!

    The operation count in one iteration (N>0) is:
    f[N] = R f[R] + f [N-1]
    where R is a random integer between 0 and RAND_MAX (a value guaranteed to be at least 32768) with expected value RAND_MAX/2

    of course, f[R] = R1 f[R1] + f[R-1] where R1 is another random variable with the same distribution as R

    It logically works though, since it inches toward zero one number per iteration .
    Last edited by baseline bum; 11-23-2004 at 07:25 PM.

  2. #2
    The Sean Marks Dance Duff McCartney's Avatar
    Post Count
    9,190
    NBA Team
    San Antonio Spurs
    Yeah well Scooby Doo can do-do, but Jimmy Carter is smarter.

  3. #3
    俺はまんこが大好きなんだよ baseline bum's Avatar
    Post Count
    97,883
    NBA Team
    San Antonio Spurs
    College
    UCLA Bruins

  4. #4
    SW: Hot As Hell
    Post Count
    7,069
    NBA Team
    San Antonio Spurs


    Which one of those minimized programs on your start bar is the porn on?

  5. #5
    Split the defense Spurbanana's Avatar
    Name
    Anna
    Location
    Houston
    Post Count
    255
    NBA Team
    San Antonio Spurs
    College
    Rice Owls
    wow, I'm in Comp Sci AP and that's the first C++ code I've ever seen. Looks like Java.

  6. #6
    Maaaaaannnn fuck.... E20's Avatar
    Location
    California
    Post Count
    15,142
    NBA Team
    San Antonio Spurs
    College
    Cal Bears
    Are you a programmer BB or are you taking classes. Interesting stuff. I was really interested in becoming a game designer before I started watching Basketball.

  7. #7
    Fantasy Football Guru Guru of Nothing's Avatar
    Post Count
    7,583
    NBA Team
    San Antonio Spurs
    Where the is Ducks when you need him?

  8. #8
    The D.R.A. Drachen's Avatar
    Post Count
    11,214
    NBA Team
    San Antonio Spurs
    College
    UTSA Roadrunners
    not nice to be mean to someone for being smart and understanding something that you never will.

  9. #9
    Rich and Smooth
    Location
    SA
    Post Count
    220
    NBA Team
    San Antonio Spurs
    Geek Alert!!! Geek Alert!!!

  10. #10
    Basketball Expertise spurster's Avatar
    Post Count
    4,132
    NBA Team
    San Antonio Spurs
    I don't think it qualifies as an algorithm for odd numbers because it is very unlikely to ever return an answer.

  11. #11
    俺はまんこが大好きなんだよ baseline bum's Avatar
    Post Count
    97,883
    NBA Team
    San Antonio Spurs
    College
    UCLA Bruins
    If Bogo Sort can be an algorithm, this one can't?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •