Author Archive

You are browsing the Author Archive of www. Michael Righi .com.

Sudoku Cheater: My First iPhone Widget (3)

Last year while flying to the west coast I finally got around to learning how to play Sudoku. Thanks to the folks at Attaché Magazine and an unknown passenger previously seated in 11B who partially completed the puzzle before me, I was able to pick up the rules pretty quickly. Thus began my short lived fascination with the Japanese number game.

On my trip back to Pittsburgh I picked up a book filled with Sudoku puzzles to keep me occupied. By the time the flight attendants were serving beverages I was already imagining more interesting uses for the sheets of paper in the book. (Folding and throwing paper airplanes on an airplane is loads of recursive fun!)

The problem I have with Sudoku is that it’s only enjoyable the first few times that you play it. After playing a handful of games you quickly realize that every game is essentially the same. When you’re doing Sudoku you’re not so much playing a game as you are acting out an algorithm. After playing five games you get into a routine. After playing ten games your brain begins to numb itself to outside stimuli as it morphs into a slow, organic Sudoku solving machine. If you manage to solve one hundred puzzles in a row you’ll find yourself completely transformed into an oil sipping, Daft Punk listening, Sudoku solving robot. You’ll go crazy spotting Sudoku puzzles in the world around you. Phone numbers will begin to resemble Sudoku rows and you’ll catch yourself searching for the missing digit. It’s no way to live.

Although the act of playing Sudoku now bores me, I thought it would be fun to write a software application that solved the puzzles automatically. Nearly twelve months later, I finally got around to building it. The current version is implemented as an iPhone widget, although I plan on eventually developing another version that’s better suited for a typical web browser. I figured that an iPhone widget would be the most useful version as many people like to play Sudoku during their bus or train ride to work. More importantly, I was looking for an excuse to build my first iPhone widget and this seemed as good a reason as any.

If you have an iPhone or iPod Touch, navigate your way to http://www.sudokucheater.com/iphone. When I initially wrote this widget I had it perform all of the calculations on the client side within the iPhone itself. Unfortunately the iPhone’s processor isn’t fast enough to handle complex Sudoku puzzles and it was causing my iPod Touch to give up after five seconds of thinking. The current version performs the calculations on the server side which means that even the most complex Sudoku puzzle can be solved in a fraction of a second. In fact, the Ajax communication takes longer to send and receive than it takes my beefy XServe to actually solve the puzzle.

I plan on turning this application into a case study for some of the training that I conduct. The application employs a Java Servlet, JavaScript, HTML, CSS and Ajax which makes it a good candidate for study in many of my corporate training courses. Once the software is a little better tested and documented I plan on releasing the code for examination. Until then I’m eager to hear your feedback on my first iPhone widget.

December 20, 2007 @ 11:38PM EST Update:

Well that was fast. Apple has already included this widget on their list of iPhone web apps.

NHL Brain Teaser (16)

A few weeks ago I was watching the Pittsburgh Penguins take on the New York Islanders and something happened in the game which gave me the idea for an NHL brain teaser. The brain teaser goes like this: Describe a scenario in which an NHL referee could tell you the score of the game but not who’s winning.

If nobody comes up with the answer I’ll post it in a few weeks.

Sunday, November 25th at 8:51PM EST Update:

Mark said, “The referee can not tell you who is winning the fight.” This is a clever interpretation of my question, and I award you points for this guess. I should have been more specific though. Let me rephrase: Describe a scenario in which an NHL referee could tell you the score of the game but not which team is winning. Note: The game is not tied.

Sunday, November 25th at 9:58PM EST Update:

Okay, here’s some more detail to make things clearer. Let’s imagine the Penguins are playing the Islanders. There’s ten minutes left to play in the third period. The ref in question has been on the ice during the entire game. Sidney Crosby decides to have a conversation with the ref during a stoppage in play.

Sidney Crosby: Hey ref, what’s the score?
Referee: One of the teams has scored three goals, and the other team has scored two goals.
Sidney Crosby: So, which team is winning? The Penguins or the Islanders?
Referee: I’m not sure.

Monday, November 26th at 3:47PM EST Update:

Melissa said, “One of the goals could be under contention, or in the process of being disallowed.” Melissa, you are the closest so far but don’t quite have the full answer yet. If a goal is being reviewed because it is under contention, then the referee probably wouldn’t know with certainty what the score is until after the tapes have been replayed. In that sense I would argue that the referee can’t tell you the score because he doesn’t know it with full certainty.

In my scenario the referee knows without a doubt that one of the teams has scored three goals and that the other team has scored two goals. He just doesn’t know which team is winning.

Keep thinking about it. You’re getting close.

Tuesday, November 27th at 5:45PM EST Update:

Melissa said, “Michael, I’m coming up with a lot of horrible answers that revolve around the referee being blind and deaf. I have a question: is this situation particular to hockey, or could you substitute another sport?” Melissa, you are not alone in wondering if the NHL refs are sometimes blind.

To be honest I’m not certain if this could apply to another sport or not because I know NHL hockey much better than I do most other sports. With a little imagination I can think of a way it could happen in the NFL, but it wouldn’t be as clear cut as it is in the NHL.

I’ll give you a big hint. This is possible in the NHL thanks to the help of video replay. This scenario would not be possible in hockey leagues that don’t have access to video replay.

Also, there should be no tricky interpretation of my words when I say “the ref can’t tell you who’s winning.” The ref can’t tell you who’s winning because he honestly doesn’t know who’s winning. In fact, it’s not just the refs who would find themselves in this predicament. A knowledgeable fan watching the game would also be able to tell you the score but not know who’s winning.

Tuesday, December 5th at 10:42AM EST Update: ******Spoiler Alert******

Congratulations to Ian who was the first to come up with the correct answer! Steve also did a great job of elaborating on Ian’s answer and coming up with a clear explanation of how this could happen in the NFL.

In the NHL when a goal is scored a red light behind the goal typically turns on, the referee points to the net to acknowledge the goal, play is stopped and the players celebrate.

At least this is what usually happens. However, sometimes a player will shoot the puck so hard into the net that it bounces out so fast that nobody is really sure if it’s a goal or not. In a blur of motion the referees are sometimes tricked into thinking that the puck bounced off a goalpost or perhaps even the goalie’s skate.

This happened a few weeks ago when Tyler Kennedy of the Pittsburgh Penguins appeared to have scored his first NHL goal. After Tyler Kennedy thought he had a goal he put his hands in the air to celebrate, only to watch as the play continued without any red light acknowledgement or referee confirmation. When a questionable “goal” like this occurs the referees will let the play continue until there’s a normal stoppage in play. At the next break in the action the referees will call “upstairs” (which is really a video replay booth in Toronto) to have the goal reviewed.

The problem is this: what if the next break in the play is caused by the other team scoring a goal? In this scenario both Team A and Team B believe they’ve scored a goal. If it turns out that Team A’s goal is illegitimate, then Team B’s goal stands. If, however, the video replay reveals that Team A’s goal is in fact a legal goal then everything that happened after that goal was scored is undone. Team B’s goal wouldn’t count, and the clock would be rolled back to the time the goal was scored.

While the referee is waiting to hear back from the video replay booth he would know that one of the two goals would count, but not know which one. In other words, he would know that the score was about to become 3-2 or 2-3 depending on which team’s goal was valid.

Ron Paul: Tell Ten (4)

In the past year I’ve become a big fan of congressman Ron Paul, and it’s been a while since I’ve found myself cheering for a Republican. Maybe it’s his consistent support for the U.S. Constitution, his unwavering belief in the importance of civil liberties or perhaps just the fact that he’s originally from Pittsburgh. Whatever the reason, I became inspired tonight to do my share in supporting the man that I hope becomes the next president of the United States of America.

Let me begin by explaining the source of my motivation.

A number of my family members hold views that I feel are consistent with Ron Paul’s, and I became curious to see how they were planning to vote. I recently asked a family member how he felt about Ron Paul, to which he responded, “Who?”

See, unlike most of my family I tend to get the majority of my information via online channels, whereas my family prefers dead trees and Wolf Blitzer. It’s no secret that Ron Paul’s been getting a lot of Internet attention but very little mainstream media attention, at least until late. It bothered me that some of my friends and family members might be Ron Paul supporters if only they knew of the man. I don’t care for whom a person votes so long as the vote is made ignorance-free.

That’s why tonight I created a Facebook group entitled “Ron Paul: Tell Ten”. It’s an initiative to encourage Ron Paul supporters to share information with friends and family who don’t yet know about Ron Paul.

Here’s the group description:

Presidential candidate Ron Paul’s popularity has been gaining huge momentum in the last few months. Once lagging in the polls and in money raised, Ron Paul is now winning polls and raising record amounts of cash. However, time is running out. With less than two months until the primaries begin there are still too many voters who don’t know the values that Ron Paul would bring to the White House.

By joining this group you agree to share your passion for Ron Paul with ten family members and friends who aren’t yet familiar with him. Ron Paul’s popularity has grown virally on the Internet, and it’s important that this viral growth of knowledge continue into the “real world.”

Let’s face it. Nobody is comfortable talking politics with friends or family. It’s a difficult topic to bring up and a potentially touchy topic for many. Fortunately, bringing up a man like Ron Paul in conversation is much easier than most politicians because of the beliefs he holds.

For example, if a friend or family member is passionate about bringing the troops home, explain Ron Paul’s belief in non-intervention.

If a friend or family member feels strongly about civil liberties, explain Ron Paul’s support for privacy and personal liberty.

If somebody you know is a gun enthusiast, teach them about the number of bills that Ron Paul has proposed to protect the second amendment.

Although not everybody will agree with Ron Paul on all issues, his unique views allow more people to relate to him than is the case with most politicians.

For help on how to cater your discussion to your audience, I encourage you to read up on Ron Paul’s views at http://www.ronpaul2008.com/issues/

By joining this group you promise to share your passion for Ron Paul with ten new people in the next ten days. Together we can extend Ron Paul’s Internet popularity into the “real world” and give him a fighting chance in the primaries which start as early as December.

If you’re a Ron Paul supporter and you have a Facebook account, I encourage you to join the group at http://www.facebook.com/group.php?gid=6306622262.