Quote:
Originally Posted by minotaurs
Just so you know everything is cool. Sevendeuceo helped me and he spoted some wrong things in my code and for the 1st picture of equity distributions i just used other board
Glad you guys got it figured out, thanks for letting me know. Some more thoughts on debugging when working through this video series --
Generally speaking, bugs are a part of programming. Thus, debugging is an unavoidable. If some of your code doesn't work while you're going through this video series, and you have to set out to fix it, please don't think of that as an unfortunate detour. On the contrary, it's an important and valuable part of the process. If you just copy down everything I write, and it works perfectly, you haven't gotten your money's worth
.
So, I hope peoples' debugging process goes beyond comparing their code to that in the video. That isn't realistic, of course. When you write your own code, there won't be an answer key available, and you'll have to figure out problems on your own. If you get stuck when working through the video series, I'm happy to help, but try to provide as much relevant info as possible. There's only so much we can do with "My X doesn't work, and here's a picture of it not working." And if that's all the info you have, you likely haven't spent enough time trying to figure out the problem yourself.
To make this easier on everyone involved, I ask that people who want help debugging adopt a particular procedure. Let me explain --
Generally, debugging will happen when you have some assumptions about how the code should work, but the program doesn't do what you think it should. E.g. "My picture doesn't match the picture in the video." Please start there and work backwards to the source of the issue.
So, you have a function that's producing a wrong answer, and that function has some inputs. Google image search provides this helpful illustration, where I guess "I" is "Input":
As far as I can recall, for all functions we write in this video series, the output follows deterministically from the input. That is, if you run it a bunch of times with the same input, you'll get the same output every time. Our functions don't use random numbers or reach out over the network for data or anything like that. So, if the output is wrong, then either
- one of the inputs is wrong, or
- the logic in the function itself is wrong
Test each of those cases, starting with the inputs. For each input to the function: figure out what you think it should look like, and then check what it actually is when you run the program. Print statements are helpful for this. If all the inputs are correct, then it's the function itself that is at fault. Otherwise, if one of the inputs is bad, move to the place where that input is being generated and repeat the process. This process should narrow down the problem to a a particular function.
So,
please provide all of the following info (in a nicely formatted way) if you need debugging help:
- What function is giving a wrong answer, what is that answer, and what should the answer be?
- For all inputs to the function:
- what should the input be?
- what is the input when you actually run the code?
- If all the inputs are correct, then presumably the problem is in the current function. Please provide your code for that function.
- If one of the inputs was not correct, then move to the function that produced that input and go back to 1.
Finally, once we do solve the issue, it'd be great if an explanation were recorded in this thread in case other people have the same problem.