Showing posts with label permutations. Show all posts
Showing posts with label permutations. Show all posts

Saturday, September 06, 2014

How Many Colored Tetrominoes?

Question: How many different colored tetrominoes are there if we allow only four colors total?

Second question: What the heck is a tetromino?

Dominoes are a great game with rectangle tiles, composed of two adjacent squares with certain numbers of pips on them. A tetromino is a group of four adjacent squares, each sharing at least one side with at least one other square. In other words, those little falling shapes made popular in the game Tetris, and all of its knock-off variations, as seen below:

There are five basic arrangements, if you allow for reflection. (That is, if you allow for picking a piece up and flipping it over.) If you only allow for rotation, then there are seven shapes, each of which can be designated a letter of the alphabet to describe it.

In most games, the shapes are different colors because a) it's a great visual, and b) it's a clue to the player that, say, a "J" is falling not an "L". Ditto for the "S" and "Z" pieces.

As with any successful game, there have been many imitations and variations. Even games that are somewhat unrelated produce their own variations, which are suddenly similar to Tetris. I've seen a few of these where the pieces, for a multitude of reasons, are multicolored instead of monocolored, as shown below:

This lead me to thinking about the number of possible colored blocks that could fall in the game of varying shapes and color schemes. My only arbitrary limit was that each block had to contain each of the same four colors. (Naturally, I picked red, yellow, green, and blue, pretty much by default.)

First instinct is to use the Counting Principle: the number of shapes times the number of four-color arrangements. That would give us (7) X (4!), or 7 X 24 = 168.

Unfortunately, first instincts may put you on the right track, but they sometimes leave things out. In this case, we can't forget about rotational symmetry.

The I piece (the line) has rotational symmetry of Order 2. If you rotate it 180 degrees, it looks the same. That makes it the same twice in one 360-degrees rotation. The S and Z pieces also have Order 2 symmetry. The O piece (the square) has rotational symmetry of Order 4. If you rotate it 90 degrees, it looks the same. That makes it the same four times in one 360-degrees rotation.

So we have 3 shapes with 4! color variations, 3 with 4!/2 variations and 1 with 4!/4 variations: 3 X 24 + 3 X 12 + 1 X 6 = 72 + 36 + 6 = 114 possible tetrominoes.

For some reason, I feel better knowing this, and maybe it won't distract me so much next time I play one of these games on the train where I have no wifi. (A Tetris Offensive, perhaps?)

(As always, you're free to correct my math. In the event of an actual mistake, I'll edit my work and pretend I have no idea what you're talking about.)

Friday, May 23, 2014

Day 28 of 30: Process of Elimination

This is day 28 of the 30-day blogging challenge. Putting horse racing metaphors aside on Indy weekend, it's the final lap and we're going all out.

If you ever watched Are You Smarter Than a Fifth Grader?, then you know that Jeff Foxworthy makes a great game-show host, with his ability to crack a joke at the right time and to be topical with what the contestants have said. He's a little slow moving the game along with all the pauses, but I think that that was more the decisions of the producers or directors. It's because of Foxworthy that, two season ago, I recorded the first few episodes of Are You Smarter Than a Bible Student?, better known as The Great American Bible Challenge. It's not a show for "religious nuts". It's funny, entertaining, and educational -- true if you've read the Bible, parts of it, or are just interested in all this Bible stuff you've heard about over the years.

I don't watch it to see if I can outscore the Bible study group contestants any more than I think I could outrun Jeopardy! champions or Who Wants to Be a Millionaire? millionaires -- especially not if they're groups of nuns or rabbis. Yes, rabbis, who may have had a bit of an edge specializing in that first half of the Bible.

No, I watch it for moments that lead a confused Foxworthy to query a contestant, "Where are the pizza ovens in the Bible?"

I'm with Jeff -- my pastor never mentioned them in his sermons.

So why the long appreciation about the show now, in its season? Because of something from this week's episode. An attempt to build tension among those who know their Biblical lion-killers, but totally destroyed it among the mathematically aware. That is, me.

The penultimate round, the one that decides which two teams advance to the final round, is called The Chosen Three. One member of the team is asked a question with multiple answers. Six choices are displayed, three of which are correct and three are incorrect. There could be other correct answers which aren't one the board. To give an overly simple non-religious example:

Which of the following are days of the week?
Monday ... Tuesday ... Frog ... Jelly ... Friday ... Wisenheimer

There are more than three possible correct answers, but only three correct answers are given. The other three are incorrect. It seems to be random whether these questions are relatively easy or impossibly difficult. Or it could just be a matter of my education on the matter as I haven't attended a Bible study in years. After all, I answered one question because I remembered it from The Ten Commandments, not from Sister St. Mark's religion class.

Okay, so here's the math.

There are three teams. They go to the team with the most points first. If that team gets all three correct, they are a lock for the final round because no team will be able to catch them. If they miss one or two (or all three), they leave the door open for one or both of the other teams to pass them. (It is possible to miss all three, but there's one one combination that doesn't include any correct answers, which is difficult enough randomly, but this is also supposed to be the "smartest" player who should be able to identify at least one of the answers. That said, I think I remember seeing it happen exactly once in two years.)

So the second team gets a question about who killed a lion in the Bible. I didn't write down all the names, and I didn't even recognize all the names. The first four were Saul, David, Daniel and Samson. (And then two with more "Biblical" names.) The contestant said that he knew that David killed a lion, and that Daniel, who was known for being in the lion's den, just "palled around" with one but didn't kill it. He added that he didn't think that Saul had killed a lion. He wasn't sure about Samson, so he chose the other two.

This team needed two correct answers to be a lock for the final round. Foxworthy revealed that David did indeed kill a lion. They need one more, so tension is mounting. He says that the contestant was right that Saul did not kill one. And then jokes about Daniel. And ... waitaminute, what did you just do, Jeff?

Sure, you're going to try to increase the tension by revealing an incorrect guess, but that didn't matter anymore.

There are three choices that we don't know about. Two of them have to be correct. The contestant picked two out of the three. Ergo, he had picked one of the two correct answers! Yes! I was so annoyed that I used the word "Ergo"!

Simple process of elimination, Jeff. There weren't enough choices remaining to have had both incorrect. His other two guesses had to be Yes-No, No-Yes or Yes-Yes. There are only three incorrect choices and you revealed two of them. So while tension was mounting, and I'll grant you that at times like this a contestant might not be thinking logically, those with no cars in the race (Indy weekend!) already knew the outcome!

That was a little bit of disappointment in an otherwise fine broadcast. Well, that and the lack of pizza ovens.

Saturday, May 03, 2014

Day 8: One for the Roses

This is Day 8, for those keeping track, and if you are keeping track, is that track Churchill Downs? This afternoon will be the 140th running of the Kentucky Derby, the first leg of horse racing's Triple Crown.

The "Sport of Kings", as it once was known, is accessible to all, young and old. And to math teachers. Seriously, there are nineteen horses in the race, numbered 1 to 20 (skipping number 11, which was scratched), and people place bets not only on which horse will come in first, but on which will come in second and third as well!

Sounds like a permutation problem to me!

Disclaimer: Gambling has its risks. There are no sure bets. Winners of horse races are not random numbers of equal probability. Bet with your head, not over it. Four score and seven years ago, yabba dabba doo, m-o-u-s-e.

When you place a bet on a horse to win, you put down your $2.00. Let's say that you want to "Dance With Fate" and you bet on the horse of the same name. (This is not unusual. People bet on horses because of names without any regard to the background and track record of the horse in question. Fools and their money?) As of this writing, Dance With Fate has odds of 14-1. That means that should he win, you'll be paid $28 plus your original $2.00, give or take. (Betting is parimutuel, meaning it depends on all the money bet in the race, and the odds shown are rounded.)

So your $2 bet gets you $30, which is nice, but it will barely buy you dinner, or, for that matter, pay for the snacks and beverages you probably consumed while waiting for the race. (Granted, you would've had to pay for them anyway.) If you want a bigger payout, you have to risk a larger amount, or take a riskier bet.

The next bet is to pick the exacta where you pick the horses which will finish first and second, in that order. You want to have it both ways? Sure, you can: just make two bets! That's allowed. But, first, let's look at this one bet. How many possible exacta bets are there? There are 19 horses which could theoretically win the race (despite what the experts will say about some of them). That means that there are 18 remaining who can place (i.e., come in second). Applying the Counting Principle, we find that there are 19 X 18 = 342 possible outcomes for first and second.

As previously stated, you can make multiple bets, put at $2 per shot, it'll get a little pricey. No one's planning on $2 x 342 = $684 on betting slips (I hope). However, there is one thing you can do to improve your payout: "wheel" your bet. If you are planning on putting money on one particular horse to win, you can play the exacta with each of the other 18 horses. At $2 apiece, you'll bet $36, but the combination of payouts (and I won't even pretend to be able to explain how its calculated) will likely (but not definitely) be higher than if you bet the entire $36 on your horse to win. But, again, if your "winning" horse fails to win, you get nothing.

Trifecta, Anyone?

Finally, there's the trifecta: picking horses to win, place and show (i.e., third place, obviously). How many possible permutations are there? Glad you asked!

It's 19 X 18 X 17 = 5,814 for all of them, or 1 X 18 X 17 = 306, of you're sure that your horse is a winner. Hint: that's not a good bet to make, even if you're playing for buttons or jellybeans with your friends.

Let's narrow it down. Suppose you pick any four of the nineteen horses. How many bets do you have to make to cover every permutation of horses coming in first, second and third?

It's 4! = 4 X 3 X 2 X 1, which the odd horse finishing out of the money. That's $48 for a $2 bet. Remember: I'm not commenting about the viability of the bets; I'm just talking about the math.

Handicapping Today's Derby Race

Okay, so you read the sports pages, saw what the experts had to say, checked all the stats for the past year, and looked into the parentage of each of the participants. (No, you didn't, but let's say you did.)

Which horses do we bet on? That's easy!

Pick your kids' ages or birthdays and your lucky number. Wheel them and make a bet. Enjoy the race and a cool drink as you kiss your money good-bye.

That's what I'd do, but I won't because they closed the OTBs around here.