# Search:

Type: Posts; User: aghast

Page 1 of 2 1

1. ## Thread: Generate all 10-digit phone numbers - backtracking

by aghast
Replies
5
Views
193

### 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. ## Thread: Problem with part of program

by aghast
Replies
2
Views
359

### 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. ## Thread: Production Code and Good Practices.

by aghast
Replies
7
Views
478

### 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. ## Thread: reverse number printing

by aghast
Replies
4
Views
343

### 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

by aghast
Replies
2
Views
270

### Don't worry about it. Calling code should be...

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. ## Thread: Resizing hash table

by aghast
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,...

by aghast
Replies
21
Views
955

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

Okay, but ...

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

q->data[0] = data;

by aghast
Replies
5
Views
438

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...

by aghast
Replies
5
Views
438

### 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.

by aghast
Replies
21
Views
1,173

### 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. ## Thread: A few more assembly to C++ questions

by aghast
Replies
7
Views
754

### 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,...

by aghast
Replies
21
Views
955

### 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. ## Thread: A string from a different function

by aghast
Replies
3
Views
435

### 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. ## Thread: A few more assembly to C++ questions

by aghast
Replies
7
Views
754

### 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. ## Thread: c code: split string || multiple/optional delimiters || memcpy - optimize

by aghast
Replies
4
Views
353

### 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. ## Thread: Is char *argv[] a 2-dimensional array?

by aghast
Replies
5
Views
590

### 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. ## Thread: [Beginner] strcmp in reverse order

by aghast
Replies
5
Views
444

### 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. ## Thread: Find if number x is less than y without comparison operator.

by aghast
Replies
6
Views
534

### 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. ## Thread: Longest common prefix divide and conquer - seg fault

by aghast
Replies
7
Views
671

### 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. ## Thread: co operative scheduler design

by aghast
Replies
2
Views
335

### 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.

by aghast
Replies
21
Views
1,173

### 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. ## Thread: Get Exponent of Float

by aghast
Replies
16
Views
730

### 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. ## Thread: Cursor placement on the screen

by aghast
Replies
3
Views
447

### 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. ## Thread: What am I overlooking with my library?

by aghast
Replies
26
Views
1,003

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

Try using "-Wl,-rpath" (note: -r) instead of "-Wl,rpath"
25. ## Thread: How am I doing so far?

by aghast
Replies
18
Views
1,507

### 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