## Drake Equation Calculator

I’ve been mentally working on new program for a week or two. What I wanted this program to do is to calculate the Drake Equation based on whatever variable I put in. I could try different values and see how that effects the total number. Sort of like this.

The Drake Equation is an equation that helps us think about how rare or prolific aliens who could communicate with us might be. The results of the Drake Equation aren’t really considered an accurate estimate of the occurrence of intelligent life, because every variable is an estimate. These estimates vary greatly based on a person’s opinion or philosophy, as well as what scientists have learned. While I don’t think anyone should put too much stock in the equation’s results, I find it really interesting how two different people can have such vastly different numbers.

Needing to practice Ruby more, I thought programming a Drake Equation calculator would be a good exercise. It allows me to use different values each time I run the program, plus I can add on more variables if I want to.

For my program, I wrote two methods: one that will allow the user to put in each variable and one that will multiply an array of variables. The program then calls the variable method to get values for each variable. After getting all the variables, they’re fed into an array, which gets fed into a method that multiplies them together. Other that all of the strings (text) that explains what the variables are, it’s a very short program. (The line numbers are so high because of all my notes at the top defining what the Drake Equation variables are :P)

I ended up having to look up a few things to make this program. First, I had to look up the Drake Equation. I needed to know exactly what each variable stands for and how to describe them. I decided to keep the Drake Equation’s original variable names because it seemed an easier way to keep them straight.

I also had to look up how to do a couple things in Ruby. First, I needed to convert a string to a float. I should’ve been able to guess that it would be .to_f, simply because I already knew that to convert an integer to a string I use .to_s. I also had to look up how to multiply all the floats in my “milkyway” array together. I used .inject(:*) to multiply my array values together.

I double checked how my program calculates, and it seems to work just fine. I’ve run it a few times with different values for the variables, getting wildly different answers. I also expanded the program out to include all of the galaxies we know about, not just the Milky Way.

I’m actually pleasantly surprised at how easy it was to make this program. With getting back into programming, the parts I’ve had trouble with are keeping my variables straight and organizing the objects. Really thinking out how I wanted the program to work and how to achieve that in logical steps helped make the programming itself go quick, without hiccups. I think drawing out a mind map would help me work like this in future projects.