Archive for the ‘arithmetic’ Category

More cookies

Tuesday, July 27th, 2010

I recently received the following interesting problem from Shadowcat, which is a generalization of the cookie problem I’ve written about previously. We again want to count the ways to distribute identical cookies to non-identical students, with the twist that we impose an upper bound on the number of cookies received by each student (quite reasonable if we want to be mindful of the students’ nutrition):

Imagine that instead of ten cookies and five students, you have fifty cookies and ten students. (It’s easier to quantify this situation using larger numbers.) How many ways can you distribute these cookies among the students so that no student has any more than ten cookies?

Students may be given any number of cookies less than or equal to ten, including zero. The cookies are identical, just as in the original problem, so, as with the original problem, it doesn’t matter which cookie the student gets, just how many. But the students, again, are *not* identical, so which student gets a specific number of cookies is important.

I unfortunately haven’t had much time to think about it yet. Feel free to leave comments, thoughts, partial solutions, and solutions in the comments!

Right answers for the wrong reasons

Wednesday, June 30th, 2010


xkcd #759

Here’s a recent xkcd which as a math educator I found particularly funny. Some questions for my readers:

  1. What numbers besides 3 and 9 would “work” here?
  2. Do you have any particularly funny or interesting stories of students getting something right for the wrong reason? Post them in a comment (or, better yet, on your own blog if you have one!).

Also, many parts of my optimal change-carrying challenge remain unanswered (although this is likely due in part to the unfortunate downtime I experienced shortly after publishing it). If you haven’t already, give it a try, you’re sure to find some aspect of the problem that interests you!

Optimal change-carrying

Thursday, June 24th, 2010

Recently Michael left the following challenge in a comment:

I’ve been trying to optimize my change-carrying habits. What is the smallest amount of quarters, dimes, nickels and pennies one can carry while still being able to give perfect change (two decimals)?

It’s not 100% clear what Michael meant by “give perfect change”, but let’s assume the goal is to be able to make any amount between 1 and 99 cents. For non-US readers, US coins are worth 1, 5, 10, and 25 cents.

Some questions for exploration:

  1. What’s the smallest number of coins you can come up with that works? What are they?
  2. Are there multiple solutions, or is the solution unique?
  3. How can you prove that a proposed solution is optimal? Unique?
  4. Can you answer the question for a different system of coins? For example, I am currently spending the summer in Cambridge, England, where coins are worth 1, 2, 5, 10, 20, and 50 pence. What if you also include the 1- and 2-pound (100 and 200 pence) coins, and want to be able to make change for every amount up to 5 pounds (the smallest note)?
  5. The US and UK coin systems both have the property that a greedy strategy works for giving the smallest amount of change. That is, to make a certain amount of change with the smallest possible number of coins, you can just keep picking the biggest coin less than or equal to the remaining amount. What about coin systems without this property? Do they make this problem harder? Easier?
  6. If you got to design your own system of coins with whatever denominations you wanted, how would you design it so that the minimum number of coins needed to make all amounts between 1 and 99 cents is as small as possible? As LARGE as possible?
  7. What are some methodologies for attacking this sort of question in general?

Feel free to come up with your own generalizations as well. Post questions, discussion, and solutions in the comments but don’t peek until you’ve tried solving it! I’ve posted another change-making puzzle before as well; the discussion there might also give you ideas.

The broken weight problem: solutions and further exploration

Tuesday, May 11th, 2010

First of all, let me say to all my readers how fantastic it felt to post a puzzle, after not posting anything for two months, and get eighteen thoughtful, insightful comments in just three days; it’s every blogger’s dream. You all are fantastic and make this a lot of fun — thanks for reading!

I thought I’d take a post just to summarize some of the responses and solutions to the broken weight problem. As many commenters realized, the solution is that the weights are of sizes 1, 3, 9, and 27. Hmm, powers of three… coincidence? Of course not!

As several commenters noted, something involving base three readily presents itself if we realize that there are three possibilities for each weight: it can be on the left of the balance scale, on the right, or not on the scale at all. Since one side of the scale corresponds to adding the weight and the other side to subtracting, we are essentially writing numbers in base three, but using the digits -1, 0, and 1 instead of the usual 0, 1, 2. For example, 25 can be written as 10(-1)1, that is, 1 \cdot 27 + 0 \cdot 9 - 1 \cdot 3 + 1 \cdot 1 (if we were really going to use this system we’d want to come up with a better symbol for -1). In fact, this is known as balanced ternary, and it is a fact (as proved by a few commenters) that n digits of balanced ternary allow us to uniquely represent every integer between \pm \frac{3^n - 1}{2}. With four digits (as in the problem) we can uniquely represent every integer between -40 and 40. There was a bit of confusion in the comments about being able to represent some integers in more than one way, but I think if you try it out you will find that this is not the case.

From this problem (generalizing it to arbitrary numbers of weights), we can see that


\displaystyle 1 + 3 + \dots + 3^{n-1} = \frac{3^n - 1}{2}.

JM noted that this generalizes to


\displaystyle 1 + b + b^2 + \dots + b^{n-1} = \frac{b^n - 1}{b - 1}

and wondered whether this has anything to do with solving the problem, or with problems like it. Indeed it does; here’s one for you: suppose you are tasked with designing a set of weights. The weights should make it possible to weigh as many different integer weights as possible, without leaving any out, just like the weights 1, 3, 9, 27 make it possible to weigh every integer weight up to 40 without leaving any out. The one difference is that you want to have two identical copies of each weight. What is the best you can do?

I’ve left the problem slightly vague on purpose, but I hope you will have fun solving it and figuring out what it has to do with JM’s observation! Can you come up with other interesting generalizations of the problem?

Finally, Sam Shah posted a link to a description of his experience using the problem in a real-life problem-solving session.

The broken weight problem

Saturday, May 1st, 2010

Here’s a fantastic problem I recently heard. Apparently it was first posed by Claude Gaspard Bachet de Méziriac in a book of arithmetic problems published in 1612, and can also be found in Heinrich Dorrie’s 100 Great Problems of Elementary Mathematics.

A merchant had a forty pound measuring weight that broke into four pieces as the result of a fall. When the pieces were subsequently weighed, it was found that the weight of each piece was a whole number of pounds and that the four pieces could be used to weigh every integral weight between 1 and 40 pounds. What were the weights of the pieces?

Note that since this was a 17th-century merchant, he of course used a balance scale to weigh things. So, for example, he could use a 1-pound weight and a 4-pound weight to weigh a 3-pound object, by placing the 3-pound object and 1-pound weight on one side of the scale, and the 4-pound weight on the other side.

The solution to this puzzle is really fascinating and leads into all sorts of fun generalizations and other topics; I’ll write more later. For now, as always, feel free to leave questions, observations, and solutions in the comments (so don’t look at the comments before you’ve solved it if you don’t want to see the answer!).

A gentle introduction to the 5th Polymath project

Wednesday, April 21st, 2010

I highly recommend reading Jason Dyer’s description of the Erdős discrepancy problem, the subject of the most recent Polymath project (the Polymath projects are an experiment in massively collaborative mathematics, where anyone at all can contribute something towards a solution). The Erdős discrepancy problem in particular is fascinating because it is quite easy to understand the statement of the problem with only a knowledge of basic arithmetic—but it has been unsolved for almost 80 years!! Jason’s explanation of the problem is clear and engaging, and has cute pictures—go give it a read!

The haybaler

Wednesday, December 16th, 2009

At Penn Alexander’s math club yesterday, the students worked on a fun puzzle that I’d never seen before. It goes like this:

You have five bales of hay.

For some reason, instead of being weighed individually, they were weighed in all possible combinations of two. The weights of each of these combinations were written down and arranged in numerical order, without keeping track of which weight matched which pair of bales. The weights, in kilograms, were 80, 82, 83, 84, 85, 86, 87, 88, 90, and 91.

How much does each bale weigh? Is there a solution? Are there multiple possible solutions?

Unfortunately, the problem seemed a little beyond them (or at least, they thought it was beyond them, so they quickly lost interest) but this seems like a great problem to use in middle school or high school math classes. In middle school, keep them talking and focus on the methods they employ to try to solve it. In high school, perhaps once they solve it you could get them to try generalizing the problem (to other sets of weights, more than five bales, etc.).

m-bracelets code

Friday, November 27th, 2009

By popular demand, here is the Haskell code I used to generate the images in my previous post. This post is literate Haskell; you can simply copy and paste this entire post into a file called BraceletGraph.lhs (or anything you like, as long as it ends with .lhs) and run it yourself. Also, I used Robert Greayer’s lovely BlogLiterately tool to write and format this post.

First, a few imports: we use Martin Erwig’s fgl functional graph library for constructing graphcs, and Ivan Miljenovic’s bindings to the Graphviz library in order to output graph descriptions.

> import Data.Graph.Inductive
> import Data.GraphViz
>
> import System.Environment

A "link" in a number bracelet is a pair of digits; knowing a pair of digits completely determines the remainder of the bracelet.

> type Link = (Int,Int)

The next link in a bracelet is obtained by adding and taking the result mod m.

> nextLink :: Int -> Link -> Link
> nextLink m (a, b) = (b, ((a + b) `mod` m))

We construct the list of all possible links.

> braceletLinks m = [ (a,b) | a <- [0..m-1], b <- [0..m-1] ]

We now also construct the list of all the "edges" from one link to the next.

> braceletEdges m = [ (l, nextLink m l) | l <- braceletLinks m ]

We will also need a function to convert a link into a unique numeric representation, since the graph library assumes that vertices are named by integers.

> linkToLabel m (a, b) = a*m + b

The rest of the code simply interfaces with the fgl and graphviz libraries to create a graph and output it as a .dot file. This was the hardest part of the code to write—but it was hard only in the sense that it took me a while to look through the documentation for the fgl and graphviz libraries to figure out how to do what I wanted.

> braceletGraph :: Int -> Gr Link ()
> braceletGraph m = mkGraph (map mkNode (braceletLinks m))
>                           (map mkEdge (braceletEdges m))
>   where mkNode l       = (linkToLabel m l, l)
>         mkEdge (l1,l2) = (linkToLabel m l1, linkToLabel m l2, ())
>
> dotGraph m = graphToDot True (braceletGraph m)
>                              []
>                              linkAttrs
>                              (const [])
>
> linkAttrs (_, (a,b)) =
>   [ Label . StrLabel . show $ a
>   , Shape Circle
>   , Color [colors !! a]
>   , FillColor $ colors !! a
>   , Style [SItem Filled []]
>   ]
>
> colors = cycle $ map ColorName [ "lightblue"
>                                , "red"
>                                , "orange"
>                                , "yellow"
>                                , "green"
>                                , "blue"
>                                , "purple"
>                                , "brown"
>                                , "pink"
>                                , "grey"
>                                ]
>
> main = do
>   (m:_) <- fmap (fmap read) getArgs
>   putStr . printDotGraph $ dotGraph m

We can run this program by passing it the value of m we want to use, and it outputs a file in .dot format, which we can turn into an image using one of graphiz’s graph layout tools, like neato or circo. For example:

$ ghc --make BraceletGraph.lhs
$ ./BraceletGraph 9 > bracelets9.dot
$ neato -Tpng bracelets9.dot > bracelets9.png

m-bracelets

Sunday, November 22nd, 2009

It is easy to generalize number bracelets to moduli other than 10—at each step, add the two previous numbers and take the remainder of the result when divided by m. Here are some pretty pictures I made of the resulting bracelets for m ranging from 1 through 12. Click on any of them to get a larger version.


m = 1
Bracelets for m=1

m = 2

Bracelets for m=2

m = 3
Bracelets for m=2

m = 4
Bracelets for m=4

m = 5
Bracelets for m=5

m = 6
Bracelets for m=6

m = 7
Bracelets for m=7

m = 8
Bracelets for m=8

m = 9
Bracelets for m=9

m = 10
Bracelets for m=10

m = 11
Bracelets for m=11

m = 12
Bracelets for m=12

I used a little Haskell program to output descriptions of the graphs, and Graphviz to generate the images. I’d be happy to post the code if anyone is interested.

Number bracelets

Tuesday, November 17th, 2009

Recently I’ve been volunteering with the middle school math club at Penn Alexander, a PreK-8 school in my neighborhood. Today we did (among other things) a fun activity I’d never seen before, called “number bracelets”. The students seemed to enjoy it; it worked especially well with a bunch of students all working on it at the same time since they were able to compare notes.

Here’s the idea: start with any two one-digit numbers you like. For example, let’s choose 4 and 6. Next, add the two numbers: 4 + 6 = 10. Throw away the tens digit of your answer (if any); this is the next number in the sequence. In our case we get 0. Now we have 4, 6, 0 and we do the same thing with the last two numbers, 6 and 0: 6 + 0 = 6. So now we have 4, 6, 0, 6. Continuing, we get

4, 6, 0, 6, 6, 2, 8, 0, …

Try some different starting numbers. Do the sequences ever repeat? How many different sequences can you make? How long can they be? Can you generalize this to other sorts of rules for generating sequences?

A much better description (with pretty pictures, more questions for exploration, and spoilers) can be found here.