Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
LanX,
The C code I wrote to calculate it is below. It finished nearly instantly. I was trying to determine how to write the rest of the code (could it fit in memory).
#include <stdio.h> // Program to count how many 8 character combinations are necessary fo +r brute force // Constants to remove magic numbers #define Z 25 int main (void) { static const short int max[26] = {4, 3, 3, 4, 4, 4, 4, 3, 3, 2, 3, + 4, 3, 4, 4, 3, 1, 4, 5, 3, 4, 2, 3, 2, 3, 4}; // from STDERR of filt +er.pl short int have[26] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int combo = 0; int i, j, k, l, m, n, o, p; for (i = 0; i <= Z; i++) { if (++have[i] > max[i]) { --have[i]; continue; } for (j = i; j <= Z; j++) { if (++have[j] > max[j]) { --have[j]; continue; } for (k = j; k <= Z; k++) { if (++have[k] > max[k]) { --have[k]; continue; } for (l = k; l <= Z; l++) { if (++have[l] > max[l]) { --have[l]; continue; } for (m = l; m <= Z; m++) { if (++have[m] > max[m]) { --have[m]; continue; } for (n = m; n <= Z; n++) { if (++have[n] > max[n]) { --have[n]; continue; } for (o = n; o <= Z; o++) { if (++have[o] > max[o]) { --have[o]; continue; } for (p = o; p <= Z; p++) { if (++have[p] > max[p]) { --have[p]; continue; } ++combo; --have[p]; } --have[o]; } --have[n]; } --have[m]; } --have[l]; } --have[k]; } --have[j]; } --have[i]; } printf("%i\n", combo); return 0; }
It also ended up being part of my final solution since I realized it was unnecessary to keep them in memory using a high water mark algorithm.

Cheers - L~R


In reply to Re^7: Challenge: 8 Letters, Most Words by Limbic~Region
in thread Challenge: 8 Letters, Most Words by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found