Games
Problems
Go Pro!

Ask Professor Puzzler


Do you have a question you would like to ask Professor Puzzler? Click here to ask your question!

Dear Professor Puzzler,

Pick a three digit number. Reverse the digits. Subtract the smaller from the larger. Now add the digits of your result, and you get 18. Every time. How does this work?

Yvonne from Georgia


Hi Yvonne,

First of all, it doesn't work every time. Let's look at a counter-example first, and then we'll look at why it mostly works.

In order to make this not work, I picked a number in which the first and last digits were the same:

525. Reverse the digits and you get the same number. Subtract these and you get zero. Add the digits of zero, and you get...zero!

So, maybe you should rephrase your instructions to say that the digits have to be different, or that the first and last digits can't be the same.

Okay, so now let's look at the math behind what is happening.

Suppose the number I picked was abc, with representing the hundreds place, the tens place, and c the ones place.

Then the value of my number is 100a + 10b + c. And if I reverse the digits, the new number's value is 100c + 10b + a.

Now, we don't know which number is larger, so we'll assume the original number was bigger. If it was the other way around, we'd just have to reverse the sign of our result.

100a + 10b + c - (100c + 10b + a) =
100a + 10b + c - 100c - 10b - a =
99a - 99c =
99(a - c)

Isn't that interesting! Your result will always be a multiple of 99! Which means it's a multiple of 9 and a multiple of 11.

We have a divisibility rule for nine (you can find several divisibility rules here: Reference Unit on Divisibility Rules) which says that if a number is divisible by 9, its digits add to a multiple of 9. And 18 is certainly a multiple of 9!

From here, the easiest thing to do is to list out the multiples of 99 that are 3 digits or fewer, and you'll see that in each case, their digits add to either 0 or 18:

0 ⇒ 0
99 ⇒ 18
198 ⇒ 18
297 ⇒ 18
396 ⇒ 18
495 ⇒ 18
594 ⇒ 18
693 ⇒ 18
792 ⇒ 18
891 ⇒ 18
990 ⇒ 18

And there you have it! Except for the case of a repeated first and last digit, which gives you zero, every other possibility gives you 18!

Thanks for a fun question, Yvonne!

Professor Puzzler

Hi, there's a video going around in which a guy (Rick Lax) asks you to pick a state, and then he guesses what it is. I don't know how he does it. Kara

Well Kara, first of all, he doesn't do it. At no point in the video does he guess your state. He's a magician, and his goal is to do some misdirection, and if he fooled you into thinking he did guess your state, then he succeeded in his misdirection. Let me talk you though what he did, and then I'll talk you through how he did it (and by the way, don't expect that we're going to make a habit of doing "spoil the magician's trick" posts - this is a unique case).

First, he tells you to pick a state.

Next, he subtly steers you away from two states by using them as examples. If you picked Utah or New York as your state, when he started using those two as examples, you probably said, "Oh, I better pick something different." Ironically, if you'd stayed with your original pick, he would have gotten it wrong.

Next he tells you to take note of your state name, and the last letter in the name. Here's where he uses the examples of Utah and New York, with one being "H" and the other being "K." At this point he instructs you to "lock in" your guess by clicking "Like."

And this, right here, is the one thing about Rick Lax videos that I detest. This is painfully blatant like-baiting. All of his videos seem to have some degree of like-baiting, but this one is just obnoxious. Rick, if you ever read this post, please stop doing stuff like this. Your videos are fun, and people will share them without you doing like-baiting. 

After you've rebelled against being told to "like" the video, and sat there sullenly waiting for him to continue, eventually he puts a bunch of letters on the screen (as shown above) and asks you to find your letter. After he gives you a few seconds, he tells you that your letter is RED.

Wow! How did he do it? Well, unless you picked Wyoming (the G is blue) or Utah or New York, every other state name in the United States ends in A, D, E, I, N, O, S,T, or Y.

All of which are red. In other words, there are only three states you can pick which don't end with a red letter.

Why didn't he just make the H, K, and G red? Maybe because that would be too much red (as it is, he stuffed the whites and blues by including the letter H three times). Maybe because he figured that getting it right 47 out of 50 times is more impressive than being right all the time. After all, if he's right 100% of the time, people might try harder to figure out the trick, but if he's not 100% correct, people will think he's just an amazing guesser.

I don't normally "spoil" magicians' tricks on my blog, but the like-baiting means that this video will keep showing up on people's news feeds not because it's so good, but because they get "pushed" into liking it. Really, Rick. Seriously. The like-baiting and share-baiting makes you look pathetic, and you're really not - you're better than that! One of the best comments I saw on your video was: "You'd make a great used-car salesman." Really. That's not how you want to be seen!

So, if you like his videos, then "like" them. Don't "like" them because he told you that you have to!

Professor Puzzler

P.S. - He's got some videos that have some fun number theory in them, and I'd like to do posts on them, just because I love number theory, but I hate spoiling the fun!

Annabelle from England asks, "A farmer had 30 cows and 28 chickens.how many are left?"

Well, Annabelle, I think you may be conflating two different riddles that are somewhat similar, because I've never heard that riddle stated like that. 

Here are the two riddles I have heard, which are similar:

Riddle One: A farmer has 26 sheep and 2 died. How many are left?

Riddle Two: A farmer has 30 cows and 28 chickens. How many didn't?

The problem is that neither of these riddles are fair if you put them in writing, because they rely on similarities of spoken words to trick the listener. Once you commit it to writing, it's no longer a fair question.

You see, in riddle number one, if I was asking it out loud, what I would really be saying is: "A farmer had twenty sick sheep, and two died." So clearly the answer is 18, instead of the 24 you were expecting.

In the second riddle (which sounds like it makes no logical sense), the question (when spoken) is actually "A farmer has 30 cows, and 20 ate chickens." So if there were 30, and 20 of them ate chickens, 10 didn't.

So there you go.  A couple riddles that aren't fair to commit to writing, but are fun if you speak them aloud!

And while we're on riddles, here's a riddle I told some people at my school, and then told them, "In five minutes you won't be able to tell this riddle to anyone."

The riddle is: "Do you know how long cows should be milked?"

And the answer is: "The same as short ones."

Five minutes later I asked them to repeat the riddle back to me, and I got things like:

"How long should you milk a cow?"
"How do you milk a long cow?"
"How are long cows milked?"

It's a fun riddle, because if you don't word it exactly the way I did originally, it spoils the joke!

Kelly from the United States, has some questions that relate to our "Secret Messages and Codes" reference pages, about how different types of "things" get converted into hexadecimal and/or binary. This post will be an attempt to explore encoding a bit more.

Encoding Colors

In your computer's web browser, every color is made up of three numbers. Those three numbers are the red component of the color, the green component, and the blue component. Each of those numbers can range from 0 to 255, with 0 meaning, "Don't use this color," and 255 meaning "Give it all you've got of this color!" and all the numbers in between representating different gradations of that color.

So, for example, you could have a color represented like this: rgb(0,255,0), and that color would be green. You could represent another color like this: rgb(255,0,255). That color would be purple (full-blast red and blue, without any green). Or rgb(128,128,128). That color is equal amounts of all three components, which gives you gray.

rgb(255,255,255) is white, and rgb(0,0,0) is black.

However, that's not the only way to write colors for the computer to understand - you can take those three color components and write them in hexadecimal to tell the computer what the color is.

For example, if a website designer wanted to tell the browser to paint the screen dark purple, the designer could give the browser this number:

#440044

To see how this is purple, split it up into three 2-digit hexadecimal numbers:

#44, #00, #44

Since #44 = 68 (because #44 = 4 times sixteen, plus 4 more), and #00 = 0, this is identical to rgb(68,0,68).

Encoding Numbers

Encoding numbers - either into binary or hexadecimal - is done by the process outlined on our reference pages. It's a structured mathematical process by which we determine the largest power of the base (two or sixteen, for binary or hexadecimal respectively) and then work backwards to determine the digits of the number in a new base.

If I'm programming a computer, and I want the computer to multiply something by 51, my program includes the number 51, but the computer converts that to 110011binary before storing it, because the computer does all its calculations in binary, and all its memory storage is binary.

Encoding Graphemes

Do you know what a grapheme is? It is defined as follows: "A grapheme is the smallest unit used in describing the writing system of any given language." Graphemes are the symbols we use to represent meaning.

Graphemes include letters, numbers, and all our punctuation marks - basically, all the characters on your keyboard. Graphemes, like numbers, need to be converted into a numerical language the computer can understand if we want them to be stored in the computer. Technically, they are stored in binary, but we often use hexadecimal to represent graphemes.

But how in the world do you convert something like "&" to a number? There isn't a mathematical process you can use to do that, is there? No, there isn't. There's also no mathematical process for converting the letter "A" to hexadecimal. And, to make your head spin a little, there's also no mathematical process for converting "1" into hexadecimal.

Notice that I put the number "1" in quotes. Because it's not the number 1, it's the grapheme for the number 1.

So if there's no good mathematical method for doing this conversion, what do we do? We just create a table of values, and arbitrarily assign a number to each grapheme. For example,

"A" = 41
"B" = 42
"C" = 43
SPACE = 20
"1" = 31
"2" = 32
"&" = 26

Note that all of these are hexadecimal values. It may be strange to wrap your brain around the fact that "1" = 31. Mind you, I'm not saying 1 = 31. I'm saying "the grapheme for the number 1 has a value of 31 (hex)." If I tried to tell the computer that one equals 31, I think it would have a meltdown!

Incidentally, in computer programming, we don't call them "graphemes" - we call them "characters." And we don't limit ourselves to visible symbols; we also have character codes for things like the backspace key and the tab key, and the arrow keys.

Syntax Determines Encoding

Here's where we finally get around to answering Kelly's questions, which are along the lines of "If I enter 'PURPLE' in the hexadecimal encoder, why doesn't it give me the color values you describe? And If I enter the number 52 in the binary encoder, why doesn't it give me the value you say it will?"

And the answer is: Our encoder is an encoder for graphemes, rather than an encoder for colors and numbers.

So when you entered "PURPLE," you thought you were saying to the computer, "Show me the hexadecimal value for the color purple," but really you were saying, "Show me the hexadecimal values for the graphemes 'P', 'U', 'R', 'P', 'L', and 'E'."

Similarly, when you entered "52," you thought you were saying to the computer, 'Show me the binary value of the number 52, but really, you were saying, "Show me the binary values for the graphemes '5' and '2'."

The key is, we tell you "enter some text" - whenever we are entering "text," we are entering graphemes for the computer to deal with.

In computer programming, and in web design, we have to be able to specify how we want to have the computer interpret the content we provide - whether we want the computer to interpret as colors, as numbers, or as text. This is why programming languages have syntax, or programming "grammar" - the grammar of a programming language helps the computer determine how we want to have things understood.

It's just like English grammar, in a way. Consider the word "content" used in the paragraph above. "Content" can be either a noun or an adjective ("I added content to the page," vs. "I am content with this page."). But when you read the sentence above, you probably didn't even hesitate to understand how I intended you to interpret the word "content." Why? Because the structure/grammar/syntax of the sentence made it clear how the word was to be interpreted.

In the same way, in the world of computer programming and web design, we use syntax to indicate how we want information to be interpreted. One of the simplest rules is: If we put it in quotes, we want it interpreted as graphemes.  Of course, nothing can be that simple. A quotation mark is a grapheme, so what if you want a quotation mark inside the text? How does the computer know whether to interpret that quotation mark as the end of the text, or as part of the text? The rules can get messy!

So for our encoder, since we've said, "enter some text," your entire entry in the textbox is treated as content to be interpreted as graphemes.

I hope that lengthy explanation added some clarity for you! Thanks for asking.

Here's another blog post that explores encoding some more: Letter codes and binary.

If you got to this page by way of Facebook, or other social media, you probably got here by clicking on an image that looks like this:

This is an image I pulled off Facebook, and tweaked the text at the bottom. The person in the image is television host and political commentator Rachel Maddow. The original text (before I modified it)  read: "Trump supporters, protestors clash in Chicago/Violence erupts inside postponed rally."

So let me explain what's going on here. Facebook allows web desigers to make use of something called "open graph" icons to give people a hint of what the post is about. If you assign an open graph icon to your blog post, when someone shares it on facebook, that image is what appears in their facebook feed, above the page's title and description.

But dishonest websites like to "trick" people into clicking their links. They think, "Oh, my article isn't interesting enough that people will want to visit my page. But if they think it's a video, they'll click it, because they think it'll play right in their Facebook page without loading an entirely new page. So I'll take a still shot from a video, make sure it has the little red play icon in the middle, and it will be completely indistinguishable from a video!" (There's even a WordPress plug-in that'll help you create that "here's a video" deception.)

An icon is "a person or thing regarded as a representative symbol of something." Icons have meanings. The little red rounded rectangle with a triangle in it has a specific meaning. It means "This is a video. Click to start watching." It does not mean, "Hey, my website has a video, and if you click here, I'll show you about 500 ads, and then, if you can manage to locate it, you can click another arrow icon that means what you expected this one to mean."

Why didn't they just post the video? Because if they post the video, people might not click through to their website, and if people don't click through to their website, they won't get ad impressions on their site, and they won't get revenue.

And the "pretend video" image isn't the only kind of click-bait out there, of course. You have articles with titles like, "You won't believe what happened next..." and "This will completely destroy Obama's presidency..." and "This video had me crying at 1:24..." and you can't resist the urge to click, even though you know it's not going to make you cry, it's not going to end anyone's presidency (or candidacy) and when you've finished reading/watching, you're going to wish you hadn't wasted your time.

But you just can't resist clicking...

To make matters worse, many click-bait sites masquerade as right-wing "news" sites or left-wing "news" sites. I say "masquerade" because most of them have no inclination to do any fact checking. They expect you to do their fact checking for them. Actually, scratch that. They don't expect any such thing. They assume that you'll see their page, recognize that they hold to the same core left/right values as they do, and therefore assume that anything they say must be true.

The only thing that's more insane than the stuff that gets reported on these "news" sites is the masses of people who - apparently without thought - like and share it.

Don't be gullible. You're a smart person. You know how to think for yourself, and do a little research.

My general policy is, when I see click-bait titles or "fake video" images, I don't click them, because I don't want to help click-bait sites get any income. The more we encourage them, the more they proliferate. But in this case, since I've been wanting to write this blog post, I bit the bullet and clicked through.

The page I got to when I clicked the "breaking news" image was so filled with advertising that when I found the actual video on the page, the video would not stop scrolling out of view over and over again for about 20 seconds, while advertising filled in all around it. I'm not exaggerating.

There was a brief associated article, which said absolutely nothing that added anything to the video. That in itself ought to cause you to ask: "Why does the page even exist?"

The answer is: the page exists to earn money. And that's not necessarily a bad thing. But, if a page exists only to earn money, adds no value to content that exists elsewhere, places no value on positive user experience, or places no value on truth, then it's a page that probably shouldn't exist.

The problem is, once people have been sucked into the vortex of a click-bait site, if they like the video (or other content) they saw there, they feel as though their best option is to share it from the depths of the cesspool. 

But here's the thing. You're not stuck sharing their version. Because you're a smart individual, and you value your friends far too much to make them suffer through the same foolishness that you just suffered through. You're intelligent enough - all you have to do is run a search engine query to find a better version of the content somewhere else. In fact, you already did that when you fact-checked the content! (Right?) In the case of my example, I just searched for "Rachel Maddow Trump protest" in google, and found the original video.

Share original content, not desperate click-bait copycats. All your friends will thank you.

And then, just to complete your helpfulness, go back to facebook, find the click-bait link you clicked on, and report it to Facebook, telling them that it's spam, or that it's unhelpful content, or whichever reporting option you find most appropriate. Facebook actually has stated on their blog that they want to eliminate click-bait, and are steering their algorithms in that direction. Give them a helping hand.

Please do your part to resist click-bait. Because you're smarter than that.

Older posts

Blogs on This Site

Reviews and book lists - books we love!
The site administrator fields questions from visitors.
Like us on Facebook to get updates about new resources
Home
Pro Membership
About
Privacy