# Names

Yesterday’s post about haters brought back memories and a smile.

It was a few years ago and one of the students in my class came in and announced that his mother or sister or someone had had a baby girl.

After the applause and congratulations, came the questions.  What are they going to call her?

But, the computer science teacher in me saw an opportunity for an interesting problem.  What if we wrote a program to generate the names of babies?

It was a problem that scaled nicely and included a bunch of programming concepts.

We had just finished talking about arrays and had done a few examples to show how they might be used.  We started simply.

We began with a couple of one dimensional arrays and I think each had 10 elements.  Now, we were naming our future kids so the last name was easy.  All we had to do was determine a first and middle name.  All the program had to do was pick a random number from 1-10 and go to the array for the first name.  Then pick another random number and go to the array for the middle name.  Concatenate these two (don’t forget the space) to your last name and, voila, instant name for your child.

Now, it was time to review and up the level of sophistication.

• If we did it after the sex is known, we need to branch to either the boy’s or girl’s names
• If we do it before the sex is known, it would be nice to generate a boy’s name and a girl’s name to cover our bases
• We need to make sure that we don’t randomly generate the same first name and middle name
• What if we wanted to reuse an existing family name or increase the odds that we pick someone from the same gene pool?
• A database of 10 names is pretty limited.  Fortunately, data files were also part of the curriculum.  Somewhere I got a big list of boy’s and girl’s names.  It’s easier now – Popular Names for BoysPopular Names for Girls
• It would be nice to be able to loop through the program to regenerate names in case we don’t like the ones that we originally generated instead of having to rerun the program
• It led to some interesting discussions about names after some students decided to colour code the results either blue or pink.  Are the list names exclusive?

Ah!  Teachable moment.  Now, we didn’t have YouTube back then but I had a case of CDs in the car and a portable player in the classroom.

So, back to the original premise.

What brought this memory back?  It was the names that the accounts I described yesterday used.  I’ve yet to be followed by a Bill Smith or Susan Jones.  They all look like they were created by a random name generator.

At the very least, it was nice to think back to this great problem.  It started simple but had legs.

This site uses Akismet to reduce spam. Learn how your comment data is processed.