POW – Quick Escape

This is the first of a new series of posts called the “Problem of the Week” (POW). As is evidenced by the title, these problems will be posted weekly. Every Sunday, I will post the answer to the previous week’s POW.

Problem

You are a member on a team of four people competing against five other teams. Each person gets a distinct number which represents how many minutes it will take that person to get across a bridge. Person A can go across in at least 1 minute, person B in 2 minutes, person C in 5 minutes, and person D in 10 minutes. Your team, just as the others, has one flashlight to share between one or two people as you cross the bridge. One of the people crossing must have the flashlight in hand. The goal is to get everyone from one side of the bridge, to the other in less time than the other teams did. The time to beat is 19 minutes. The reason it takes so long is because two people can only cross the bridge at the speed of the slowest individual. Also, the flashlight may not be thrown to someone to cut down on time. Is it possible for your team to get everyone across the bridge in less than 19 minutes? If so, how can you do it?

Example Run

  1. Person A (1 minute) and person D (10 minutes) go across to the target side with the flashlight in 10 minutes.
  2. Person A (1 minute) comes back across the bridge with the flashlight in one minute, bringing the total time to 11 minutes.
  3. Person A (1 minute) and person C (5 minutes) go across to the target side with the flashlight in 5 minutes, bringing the total time to 16 minutes.
  4. Person A (1 minute) comes back across the bridge with the flashlight in one minute, bringing the the total time to 17 minutes.
  5. Person A (1 minute) and person B (2 minutes) go across to the target side with the flashlight in 2 minutes, bringing the final time to 19 minutes.

Divisibility Rules for 11 and 12

On Wednesday I explained how to determine if a number is divisible by 3, 6, and/or 9. I also posted a comment with a link to rules for 2, 3, 4, 5, 6, 7, 8, 9, and 10. Therefore, I think it is time for 11 and 12.

Divisibility Rule for 11

Let’s say that we want to determine if 31823 is evenly divisible by 11.  I will know that it is evenly divisible by 11 if 3 – 2 + 8 – 1 + 3 is evenly divisible by 11.  31823 is divisible by 11 because 3 – 2 + 8 – 1 + 3 is equal to 11.

Let’s try 9123:  3 – 2 + 1 – 9 = -7.  Since -7 is not divisible by 11, 9123 is not evenly divisible by 11.

Let’s try one more together to make sure you understand the pattern.  Is 9876543210 divisible by 11?  Since 0 – 1 + 2 – 3 + 4 – 5 + 6 – 7 + 8 – 9 = -5 and -5 is not evenly divisible by 11, 9876543210 is not evenly divisible by 11.

Okay, so now that we understand the pattern, how do we find a nearby number that is divisible by 11?  Believe it or not, you just have to subtract the number that you get from our math problem to the original number, to get one that is divisible by 11.

Let’s use 9123.  3 – 2 + 1 – 9 gave us -7.  Using that number, we can do the following:  9123 – (-7) = 9123 + 7 = 9130.  This means that 9130 is evenly divisible by 11.

Now let’s try our other number that wasn’t divisible by 11:  9876543210.  We will subtract -5 which came from 0 – 1 + 2 – 3 + 4 – 5 + 6 – 7 + 8 – 9.  Using that number, we will find the answer by doing this:  9876543210 – (-5) = 9876543210 + 5 = 9876543215.  That means that 9876543215 is evenly divisible by 11.

Divisibility Rule for 12

A number is divisible by 12 if it is divisible by both 3 and 4.  The reason this is true is because 12 = 3 × 4.  Knowing this, the only part that you may not understand is when a number is evenly divisible by 4.  This is the case when the last two digits of the number are divisible by four.

If you have trouble looking at a two digit number and figuring out if it is divisible by four, try the following:

  1. If the right-most digit is odd, it is not divisible by four.
  2. If the right-most digit is 0, 4, or 8, the next digit to the left must be even.
  3. If the right-most digit is 2, or 6, the next digit to the left must be odd.

As I explained in my previous divisibility post, a number is evenly divisible by 3 only if the sum of the digits in the entire number is even divisible by three.

View Saved Password

In different browsers, there are different ways to view saved passwords. If you don’t know how to do it in your password, and you are fortunate enough to find this page 😉 , you could you simply do the following:

  1. Go to the page where your password is saved.
  2. Copy and paste the following into your address bar:
    javascript:(function(){for(var c=document.getElementsByTagName("INPUT"),a=c.length-1;a>=0;a--)(function(b){if(b.type.toUpperCase()=="PASSWORD"){var a=b.oncontextmenu;b.oncontextmenu=function(){try{clipboardData.setData("Text",b.value),alert("Your password has been copied to the clipboard.")}catch(c){alert("Your password is:\n"+b.value)}a&&a.apply(this,arguments);return!1}}})(c[a])})();
     
  3. Hit the enter key.
  4. Right click the password field to get your password.

For those of you who know JavaScript and want to know what the code originally looked like, it is as follows:

(function() {
  var arrInputs = document.getElementsByTagName("INPUT");
  for(var i = arrInputs.length - 1; i >= 0; i--) {
    (function(input) {
      if(input.type.toUpperCase() == "PASSWORD") {
        var oldOnContextMenu = input.oncontextmenu;
        input.oncontextmenu = function() {
          try {
            clipboardData.setData("Text", input.value);
            alert("Your password has been copied to the clipboard.");
          }
          catch(e) {
            alert("Your password is:\n" + input.value);
          }
          if(oldOnContextMenu)
            oldOnContextMenu.apply(this, arguments);
          return false;
        };
      }
    })(arrInputs[i]);
  }
})();

Basically, the code loops through all of the password fields and sets the oncontextmenu event so that it will either copy the password to the clipboard (IE only) or display the password in an alert. If oncontextmenu was previously set, this function will execute afterwards.