Junilu Lacar wrote:Lastly, look at the formula you're using for the percentage. Are you sure it's correct? Are you sure you're dividing the count by the correct number?
rick pine wrote:
Junilu Lacar wrote:Lastly, look at the formula you're using for the percentage. Are you sure it's correct? Are you sure you're dividing the count by the correct number?
I have changed that to 1000 instead. from your questions this is what i gather. If i produce 2 arrays with an idex of 6 i would have a total of 12 values, if i want to roll two dice i should call roll dice twice on the for loop, the names of the arrays beacause it is indexing the numbers that the dice will display, so maybe to diceSide, or diceFace. Also the reason i set the arrays to 7 its because i started the loop at 1, if i set it to 6 and start the loop at i = 0 i get a 0 on the output, and that was the only way i found to stop that from happening.
Sergiu Dobozi wrote:I would just create 3 arrays for this....first array is equal to {2,3,4...12}. Second array will hold the counts and third will hold the percentages. As you can realize they will all have a length of 11.
Junilu Lacar wrote:
Now, with that in mind, pick up your dice and be *that* guy.
I didn't find any movie quotes by searching, but one link with dreadful pick-up lines appeared, which can be relied on to send any woman running.Henry Wong wrote:. . . This almost sounds like a movie quote... and if it is, it is going to irk me for the rest of the day, trying to figure it out...
Henry
Sergiu Dobozi wrote:Since you said one array is enough, I made the program with one array. This is what I have so far...
Junilu Lacar wrote:
Sergiu Dobozi wrote:Since you said one array is enough, I made the program with one array. This is what I have so far...
I had a look at that code before I deleted it. It still was far more complicated than it needs to be. You need ONE simple array that will hold the tally for each distinct result that you can get. You don't need a nested/multidimensional array for this because everything besides the tallies can be calculated.
rick pine wrote:the names of the arrays beacause it is indexing the numbers that the dice will display, so maybe to diceSide, or diceFace.
Also the reason i set the arrays to 7 its because i started the loop at 1, if i set it to 6 and start the loop at i = 0 i get a 0 on the output, and that was the only way i found to stop that from happening.
All things are lawful, but not all things are profitable.
Junilu Lacar wrote:(...) Now, with that in mind, pick up your dice and be *that* guy.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:I have to disagree about using the variable 'ROLL_VALUES'. Why introduce that extra complication? In the old situation we are wasting two array elements, but with the big bonus of simplicity. A price I am willing to pay..
Suppose that we now have three or more dice, and that they are of a special kind: they all contain 6 random numbers. Now, it becomes much harder to determine a suitable mapping function from output to array-index. In the old system you don't have this complexity, at the expense of some wasted elements.
You wouldn't have these problems when using a Map<Integer, Integer>.
There are three kinds of actuaries: those who can count, and those who can't.
rick pine wrote:I really appreciate your ways to improve my code, i will keep them for personal use and to improve my skills. But if i were to turn this in with your ideas i probably would get zero , it would look too good for a novice.
There's a level of coding that you do on a daily basis. This is the level where you're comfortable. You can get things done at this level. But you tend to cut corners because you need to get things done because that's what you're paid to do. Then there's the level of coding that we consider to be perfect. And there's always a gap between our daily level of coding and that perfect level of coding. That gap is important because if we tried to code perfectly all the time, we wouldn't get a whole lot of things done. But that gap is also a measure of how much we suck. Code Retreat is about narrowing that gap, just a little bit. We practice writing perfect code, without the pressure of getting anything done. If all you do at Code Retreat is write one line of perfect code, one method that's perfect, then you've learned something.
And when you go back to work on Monday, you just might be able to raise your daily level of coding that one little bit, so your code is a little cleaner, a little simpler, a little more expressive, and is covered by some better tests.
I already bought and read 3 books from your recommended list: '2', '3', '10.2' - the biggest impact to me did the Clean Code at the moment. Being a quite pedantic person, I really liked authors ideas taught in the book. How author pays attention and highlights importance of the smallest details. Aligned to this topic I want to share one quote from the book which touched me a lot:Junilu Lacar wrote:top 10 books I use right now, it would be this
Uncle Bob's Clean Code wrote:When people look under the hood, we want them to be impressed with the neatness, consistency, and attention to detail that they perceive.
We want them to be struct by the orderliness. We want their eyebrows to rise as they scroll through the modules.
We want them to perceive that professionals have been at work.
Looking to how many times this book have been quoted by Junilu, and the fact that it appears as a first in book in his list, I can't wait to start reading it. Will start right now actually.1. Understanding the Four Rules of Simple Design by Corey Haines
Is that a spider in your hair? Here, threaten it with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|