The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need a more efficient function
Author Message
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #10
RE: I need a more efficient function
(09-16-2012 10:03 PM)infinitynotpi Wrote:  This is me holding a flower...(see Venn diagram)

Wolfram Alpha

And this is me just showing my ass...

First Function of 2 Boolean Variables

And this is me just being a friend...

I've included some C for you!

Which includes the fast algorithm you're looking for in it -- Monte Carlo

133,784,560 combinations

Snippet here

Code:
/*
* returns number of dead cards, -1 on error
*
* argc, argv are the standard arguments to main
* num_dead is a return value of the number of dead cards
* dead_cards is a return value of the dead cards
*/
static int
parse_args(int argc, char **argv, int *num_dead, CardMask *dead_cards) {
  int i, c, o, rc, len;

  if (num_dead == NULL) {
    return (-1);
  }

  if (dead_cards == NULL) {
    return (-1);
  }

  *num_dead = 0;
  CardMask_RESET(*dead_cards);

  /*
   * parse any options passed to us.
   * -d "c1 [...]" is dead cards
   */
  while((o = getopt(argc, argv, opts)) != -1) {
    switch(o) {
    case 'd':
      len = strlen(optarg);
      for(i = 0;i < len;) {
    rc = StdDeck_stringToCard(optarg+i, &c);
    if (rc) {
      StdDeck_CardMask_SET(*dead_cards, c);
      (*num_dead)++;
      i += 2;
    } else {
      i++;
    }
      }
      break;
    }
  }

  return (*num_dead);
}
[/code]

The Count of Monte Cristo

what good is C programming going to do with his Sphere .SCP? Tongue

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
09-18-2012 08:40 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Messages In This Thread
RE: I need a more efficient function - Rayvolution - 09-18-2012 08:40 AM

Forum Jump:


User(s) browsing this thread: 4 Guest(s)