Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualAlpha_ProgDes

Posted 28 April 2013 - 10:45 AM

First let me say this, this problem is from How To Design Programs, 2nd Edition (Chapter 4, Section 4.5.1).
 
Second, this is not homework. I'm self-learning.
 
Now, I've made two attempts at this problem. First and Second. My issue is that I know I'm doing something wrong. But I don't know what it is. My process of going through the problem is jacked somehow. In the first attempt, the code looks like right. I'm using recursion, following the steps the book has laid out (to the best of my understanding). But the result produced is the answer plus junk. In the second attempt, there is some recursion and helper functions. And the answers are correct. However, the code feels .... wrong. As if I didn't do it the Scheme way. It's like writing C with classes and not idiomatic C++. It's right, but it's wrong.
 
So any tips, hints, pointing in the right direction, would be greatly appreciated.

#2Alpha_ProgDes

Posted 28 April 2013 - 10:45 AM

First let me say this, this problem is from How To Design Programs, 2nd Edition (Chapter 4, Section 4.5.1).
 
Second, this is not homework. I'm self-learning.
 
Now, I've made two attempts at this problem. First and Second. My issue is that I know I'm doing something wrong. But I don't know what it is. My process of going through the problem is jacked somehow. In the first attempt, the code looks like right. I'm using recursion, following the steps the book has laid out (to the best of my understanding). But the result produced is the answer plus junk. In the second attempt, there is some recursion and helper functions. And the answers are correct. However, the code feels .... wrong. As if I didn't do it the Scheme way. It's like writing C with classes and not idiomatic C++. It's right, but it's wrong.
 
So any tips, hints, pointing in the right direction, would be greatly appreciated.

#1Alpha_ProgDes

Posted 27 April 2013 - 11:28 PM

First let me say this, this problem is from How To Design Programs, 2nd Edition (Chapter 4, Section 4.5.1).

 

Second, this is not homework. I'm self-learning.

 

Now, I've made two attempts at this problem. First and Second. My issue is that I know I'm doing something wrong. But I don't know what it is. My process of going through the problem is jacked somehow. In the first attempt, the code looks like right. I'm using recursion, following the steps the book has laid out (to the best of my understanding). But the result produced is the answer plus junk. In the second attempt, there is some recursion and helper functions. And the answers are correct. However, the code feels .... wrong. As if I didn't do it the Scheme way. It's like writing C with classes and not idiomatic C++. It's right, but it's wrong.

 

So any tips, hints, pointing in the right direction, would be greatly appreciated.


PARTNERS