

However, the variables in runExperiment are named m, n, a, b, etc. The variables numTrials and numExperiments are good names because they hint at the significance of those variables to this program. For example, the runExperiment function relies on numExperiment and numTrials, so those should be passed parameters. It's generally better to explicitly pass variables your function will need rather than using the vague implicit linkage of a global variable. Avoid the use of global variablesĪs you have already noted, global variables should be avoided in favor of local variables. Only include files that are actually needed. The inverse of the above suggestion is to avoid having extra #includes. It's important to make sure you have all required include files to make sure your program compiles reliably.
Slack coin flip code#
The code uses rand() but doesn't #include. Make sure you have all required #includes Putting using namespace std at the top of every program is a bad habit that you'd do well to avoid. There's a lot that can be improved here, so I hope that these suggestions are useful to you.
Slack coin flip trial#
Int numExperiments = 1000 //Number of experimentsīool printT = false //Whether to print the results of each trial Int numTrials = 5 //Number of trials per experiment Int choose(int, int) //Performs a combination (nCk)ĭouble probability(int) //Calculates the probability of a coin hitting heads n times (binomial thrm)ĭouble chance = 0.5 //Chance of landing on heads Void getInfo() //Gets the information to perform the experiment Void runExperiment() //Performs and prints the results of the trials Name Lastnameīool generate() //Performs a coin flip with the given chance Right off the bat I know that I should pass things by reference instead of by value and that I shouldn't have used global variables. I'm pretty new to computer science so I'd like to learn the correct practices and everything.
Slack coin flip how to#
I turned this in already but I really enjoyed doing the assignment and I'd like to know how to make it better, faster, etc. Then, it displays the results, as well as the theoretical and observed probabilities of each event happening. For example, given 5 trials per experiment and 20 experiments, the program will flip a coin 5 times and record the results 20 times. DecisionBot is a simple decision maker for Slack.Asks the user for the chance of a coin landing on heads, the number of trials per experiment, and the number of experiments. There are times when a quick decision is what you want, but there's no time to waste debating. Use it in Slack to roll a dice, flip a coin or play Rock, Paper, Scissors! Stop wasting time Where are we going for lunch?Īre you and your team always arguing about what to do for lunch? With you can make a quick decision and. No more argumentsĭecisionBot is a simple decision maker bot that provides you an efficient way of deciding who's right and who's wrong in that never-ending argument or just to settle something quickly. The DecisionBot will listen for your instructions and respond with the correct results. This bot is really simple to set up and use, just include in a message and follow the instructions.


The DecisionBot helps you settle disputes and makes casual decisions in Slack channels. Got an issue or an idea? Get in touch on Twitter decisions using Slack
