Search:

Type: Posts; User: aghast

Page 1 of 2 1 2

Search: Search took 0.00 seconds.

  1. Your problem statement is a little unclear. If a...

    Your problem statement is a little unclear. If a number has "3 distinct even digits" what does that say about the remaining digits? Could the extra digits also be even, or must they be odd? Are the...
  2. Replies
    2
    Views
    362

    Also, you need to have a tracking variable, to...

    Also, you need to have a tracking variable, to scan through the loop and remember which was the greatest sum. Something like this:



    int tracking_variable = 0;
    for (... loop ...) {
    result...
  3. Replies
    7
    Views
    486

    I believe that returning the result of a...

    I believe that returning the result of a comparison or boolean operation is exactly the right thing to do, if the function you are writing is a predicate.

    That is:



    bool is_lower(int ch)...
  4. Replies
    4
    Views
    351

    First, write a test function: bool ...

    First, write a test function:



    bool
    arrays_equal(int *a1, size_t len. int * a2)
    {
    if (NULL == a1 || NULL == a2)
    return len == 0; // equal for 0 elts, otherwise not equal
  5. Don't worry about it. Calling code should be...

    Don't worry about it.

    Calling code should be bounds checked by correct construction, not by adding checks:

    for (int i = 0; i < length(array); ++i)

    This avoids the need for any kind of...
  6. Replies
    2
    Views
    295

    I would be wary of trying to down-size a hash...

    I would be wary of trying to down-size a hash table. First, because I'm not sure when you would need it: would it be easier to wait and destroy the whole thing?

    Second, because if you shrink it,...
  7. Thread: FIFO Queue

    by aghast
    Replies
    21
    Views
    960

    Okay, but ... First, let's talk about...

    Okay, but ...

    First, let's talk about notation:



    (*q).data[0] = data;

    q->data[0] = data;
  8. Replies
    5
    Views
    441

    I already did: to make it circular, follow the...

    I already did: to make it circular, follow the next pointers until you are almost back where you started. Then insert your new value.

    Start with the simple case: how do you insert a single new...
  9. Replies
    5
    Views
    441

    For a list to be circular, you have to be able to...

    For a list to be circular, you have to be able to start as some point P, and follow the list in a single direction, and eventually end up back at the very same point P.

    Your example code is not...
  10. Replies
    21
    Views
    1,185

    For the sieve version, have you tried putting the...

    For the sieve version, have you tried putting the table generator in a separate thread, and allowing the primes to wait on generation? Actually, maybe several threads? (If you're using bool entries...
  11. Replies
    7
    Views
    762

    This looks to me like a 24-bit number being...

    This looks to me like a 24-bit number being shifted in two parts.

    The first pair of LDA's gets the upper 16 bits, shifts 2, stores a byte. The next pairs of LDA's gets the lower 16 bits, shifts 2,...
  12. Thread: FIFO Queue

    by aghast
    Replies
    21
    Views
    960

    When you are seated at a table in a restaurant,...

    When you are seated at a table in a restaurant, what does the table look like?

    That's what queueInit() does. It "sets the table." It doesn't know who is going to eat, or how many, or what they...
  13. Replies
    3
    Views
    437

    When you pass a value as an argument to a C...

    When you pass a value as an argument to a C function, it is passed "by value". That is, a byte-for-byte copy of the value of the argument is placed on the call stack or in a register, where the...
  14. Replies
    7
    Views
    762

    If these functions aren't defined for you, then...

    If these functions aren't defined for you, then you'll need to write them yourself. I'd suggest that you create a bunch of "low level" functions in a header file, using the pre-processor to select...
  15. What are the valid characters that make up a...

    What are the valid characters that make up a "GENE", exactly? Is it just "ACTG", are "actg" allowed? Are there other characters?
  16. Replies
    5
    Views
    592

    Sorry, but this is false and wrong. First: ...

    Sorry, but this is false and wrong.

    First:
    6.4.5 String literals



    6.4.5(6) In translation phase 7, a byte or code of value zero is appended to each multibyte character sequence that...
  17. Replies
    5
    Views
    450

    Are you comparing the strings in order to sort...

    Are you comparing the strings in order to sort them, or are you comparing the strings just to determine if they are equal or not?

    If you are trying to produce an ordering, then you'll have to...
  18. I would suggest that you evaluate this question...

    I would suggest that you evaluate this question the same way a CPU evaluates this question: do a subtraction, and then look at the resulting number.

    A naive approach would be something like:


    ...
  19. In this code (from lcp): int m = (l +...

    In this code (from lcp):

    int m = (l + r)/2;

    strcpy(str1, lcp(str, l, r));
    strcpy(str2, lcp(str, m+1, r));

    I think the first strcpy line should be "lcp(str,...
  20. Replies
    2
    Views
    339

    I think the first thing to do would be to figure...

    I think the first thing to do would be to figure out how context switching is going to work.

    Write yourself a set of functions that do the absolute minimum scheduling: round-robin.

    - Tasks...
  21. Replies
    21
    Views
    1,185

    The rand() function typically returns 16 or...

    The rand() function typically returns 16 or 32-bit numbers. Those numbers are within the memory capacity of most modern PCs.

    You're asked to generate 10E6 or 100E6 numbers at random to check if...
  22. Replies
    16
    Views
    743

    You can extract a bit field from an unsigned...

    You can extract a bit field from an unsigned value using multiply (to force the upper bits off the end, clearing the top part, followed by divide (to force the lower bits off the end, clearing the...
  23. Replies
    3
    Views
    455

    There was once a Unix library called "curses". It...

    There was once a Unix library called "curses". It is long since dead, but in the spirit of open source there are a bunch of clones of that library in various languages for various target...
  24. Replies
    26
    Views
    1,026

    Try using "-Wl,-rpath" (note: -r) instead of...

    Try using "-Wl,-rpath" (note: -r) instead of "-Wl,rpath"
  25. Replies
    18
    Views
    1,525

    Turns out, no! First, I explicitly referenced...

    Turns out, no!

    First, I explicitly referenced C (vice C++) in my text. So, yeah, @laserlight had it right -- I had been in the C forum previously, and just assumed that @etech's code was C since...
Results 1 to 25 of 33
Page 1 of 2 1 2