Monthly Archives: December 2008

Number Digits Puzzle #1 – Solution

A couple of days ago, I posted the following puzzle:

There is a ten digit number where the leftmost digit is also the number of zeros in  the number, the second leftmost digit is the number of ones and so forth until the last digit (or rightmost digit) is the number of nines in that number. What is this number and is it unique?

Congratulations to the folks that figured it out, including Trae (of posted the solution to the comments section.  I’d award him a prize if I had one to give.  Instead he’ll have to settle for a virtual pat on the back.

The answer: 6210001000

Now the real question is how do you come up with the answer and is it unique?  Additionally, you might ask how this works for a smaller number of digits, that is, do the same problem but start with only 3 digits, or 4 digits, etc.?

I came up with a very similar explanation as the original source for the problem so I’ll give credit where credit is due.  You can read the original post here:

Continue reading Number Digits Puzzle #1 – Solution

A new collection of math jokes

image Ok, so I know that several of the readers of this blog will enjoy this, several others will groan as they read, and many others will just roll their eyes at the lack of humor below.  I’m posting anyways.

And for the record, at one time, I have laughed out loud at every one of these. There, I confessed.


Q: How does a mathematician induce good behavior in his children?
A: `I’ve told you n times, I’ve told you n+1 times…’


A mathematician and his best friend, an engineer, attend a public lecture on geometry in thirteen-dimensional space.
"How did you like it?" the mathematician wants to know after the talk.
"My head’s spinning", the engineer confesses. "How can you develop any intuition for thirteen-dimensional space?"
"Well, it’s not even difficult. All I do is visualize the situation in arbitrary N-dimensional space and then set N = 13."


One day, Jesus said to his disciples: "The Kingdom of Heaven is like 3x squared plus 8x minus 9."
A man who had just joined the disciples looked very confused and asked Peter: "What, on Earth, does he mean by that?"
Peter replied: "Don’t worry – it’s just another one of his parabolas."


[I’ve heard the ones about the Abelian Grape and Zorn’s Lemon, but this one was new to me]

Q: What is normed, complete, and yellow?
A: A Bananach space…


A mathematician has spent years trying to prove the Riemann hypothesis – without success. Finally, he decides to sell his soul to the devil in exchange for a proof. The devil promises to deliver a proof within four weeks.
Four weeks pass, but nothing happens. Half a year later, the devil shows up again – in a rather gloomy mood.
"I’m sorry", he says. "I couldn’t prove the Riemann hypothesis either. But" – and his face lightens up – "I think I found a really interesting lemma…"


That’s enough for now.  Are you smiling yet or just confused?

Mathematical Moment #2

Number Sense in fourth grade.

(Continuation of a series from a while back… –> Mathematical Moments)

image In the fourth grade, I was first given the opportunity to participate in a UIL competition that I really enjoyed.  In Texas, there are quite a few academic contests which are part of the UIL (University Interscholastic League), and by that time, I had dabbled in only one event and it was called “Story Telling”.  In that event, you and a group of students were read a story and then one by one, you were asked to re-tell to the story to a judge who would score your storytelling ability.  I tried it, and to be honest, I stunk.

Fortunately, in the fourth grade, another event became available to me, namely “Number Sense.”  In this competition, you are given a 10 minute test with 80 math questions, almost entirely arithmetic. The most challenging aspect of the test is that all calculation must be done in your head, no scratch paper or marks on the test are allowed.  Also, no calculators are allowed.  It’s all in your head. 

The teacher who coordinated the extra-curriculum program for Number Sense asked each of the fourth grade teachers to recommend students who might be interested and appropriately skilled to participate.  For whatever reason, I was the only fourth grader that ended up being involved.  I can vividly recall the first couple of meetings with the Number Sense team.  I can’t be sure of who the older kids were, but I would hazard to guess that it included the same individuals that I would later compete against in Number Sense throughout high school, namely Nick Hiemstra and Tony Cook. 

Three things come back to my mind as I think about those early meetings:

1. Holes in the ceiling tiles.  It was in these first two meetings that I was taught the art of flicking pencils into the ceiling tiles above.  The room we used was an older room that wasn’t being used for anything else and when I arrived, I discovered a group of guys having the best time flicking pencils up into the ceiling.  There were holes everywhere and a least a couple dozen pencils sticking out. I tried my hand at it and succeeded at least a few times before we were caught and strongly urged not to continue this act of destruction. So we continued at a later time.

2. Rolling Chalkboard.  For some reason, I never imagined that a chalkboard would be anywhere but fastened to a wall.  It seems silly now, but I was amazed in fourth grade by a chalkboard on wheels that you would flip over and write on both sides.  Why it amazed me, I have no idea, but I still remember that feeling of awe toward a chalkboard.  I guess it was my destiny to build a career around such a thing: writing on the board…

3. Mental Arithmetic. I was like a dry sponge immersed in the ocean when it came to this first exposure to a vast wealth of tricks for mental calculation.  Tricks for multiplying by 11, by 25, by 125, for squaring numbers ending in 5, for adding fractions whose numerator is 1, for multiplying any two digit numbers together, for adding long sequences of numbers, and on and on.  I fell in love with mathematics for the first time.  I had been fast at the Multiplication tables in 3rd grade but this opened a whole new world to me.

The one tragedy I remember that came out of this new experience was when I misunderstood our sponsor and believed that I was actually on the team for that first contest.  The team was traveling to River Road in Amarillo.  I called the sponsor the night before to find out when we were leaving and learned that I was not going.  oh, the pain.  I still remember how that felt.  I knew I was going to have to get good and I vowed to memorize the little 20-page (or so) red paper booklet with all the number sense tricks.  After only a few weeks, I had done just that.

There are lot more Mathematical Moments that come from my involvement in Number Sense but my fourth grade year was the first and probably set me on the road to where I am today.

Shortest Sudoku Solver in Python

image Well over two years ago on this blog (have I really been around that long?), I posted a link to a story that Sudoku had been solved.  (The original link to the Math-Forge Story is broken, so here in alternative version of the story.) While just about every computer scientist and programmer I know has thought up a quick little code to solve a Sudoku puzzle, the interesting element of the above story is that the algorithm solving Sudoku was connected to techniques used in diffraction microscopy.

Now, when I say “quick little code”, I meant an easy algorithm to implement, but not necessarily an elegant or amazingly small code that would accomplish the solution.  Here is definitely the smallest (shortest) code I’ve seen that will do it.

def r(a):i=a.find('0');~i or exit(a);[m
in[(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)or a[j]for
j in range(81)]or r(a[:i]+m+a[i+1:])for m in'%d'%5**18]
from sys import*;r(argv[1])

Here’s one that is slightly longer (185 bytes as opposed to the 178 above)

use integer;sub R{for$i(grep!$A[$_],@x=0..80){
R($A[$i]=$_)for grep!$t{$_},1..9;return$A[$i]=0}

HT: Scott’s Blog