There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:
OP repeatedly stated he understood the radix algorithm, and he only needed assistance when it comes to the implementing part. Now, I wonder, what in this topic made you to spell out the algorithm again?
Junilu Lacar wrote:
Piet Souris wrote:
OP repeatedly stated he understood the radix algorithm, and he only needed assistance when it comes to the implementing part. Now, I wonder, what in this topic made you to spell out the algorithm again?
I'm afraid I may have crossed the line between being helpful and being overbearing. I apologize to David if he feels that way. It's just that I've been watching this thread and got a sense that David is in this way over his head. Since he said a lot of the code was already given and that he only had to complete some parts, my reckoning was that this would be a two- to three-hour exercise. Instead, it seems it dragged on significantly longer and he is obviously struggling with some of the programming language constructs, for example, using square brackets instead of parentheses with a method call. What's more, one of sections to be filled by him has the comment "make a recursive call to radix" -- that's like kicking the guy in the head when he's already got the wind knocked out of him.
As I said, from my vantage point, it seems like he was just poking around and trying one thing or another without a concrete plan of attack. I was simply trying to get him back on the right track. But again, my enthusiasm to help may have gotten the best of me, so please accept my apologies if that is the case here.
Stefan Evans wrote:My initial reactions:
A couple of your comments look like they have been copied/pasted, and don't apply where they are.
Specifically the second "put the number into the correct pocket" comment.
Yes, comments ARE important.
Rather than doing a peek to print out the number, then a dequeue, I would just do a dequeue, and then print out the result.
Your method of printing destroys the queue in the process. Not sure if you can do anything about that really, but a non-destructive print method would be useful for debugging :-)
As I think has been pointed out before, in one place you have used '10' rather than the NUMDIGITS constant. That might create a problem if you change the constant :-)
The algorithm itself looks like it should work. What are your results?
You:
After that, I would go through, from right to left, putting those items starting with kth number 9 back into the original queue.
Me:
Agreed. In what order will you get the numbers, according to this strategy?
There are three kinds of actuaries: those who can count, and those who can't.
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|