Header tag

Friday 29 March 2019

Maths Puzzle: Magic triangle

As I begin to draw the MathEMagic series to a close, I'd like to start expanding on the analysis I carry out for each puzzle.  It's all well and good to provide the solution to a problem, and some rationale for why, but I always find it interesting to see how a problem can be extended and if there are any patterns in the results.

This puzzle, taken from MathEMagic, is simply:  use the numbers 1 to 6 in the circles shown on the edges of this triangle, so that the sum of each edge is the same, and form a 'magic triangle'.

This (I thought) was a fairly simple puzzle, but one which can easily be extended to become more difficult - although throughout, the same strategy applies.  The general rule that I follow is to distribute the numbers in ascending order to each of the edges of the triangle, and then make adjustments towards the end of the series.

Starting with 1, 2 and 3, these go in the corners, and then the remaining 4, 5 and 6 go in the middle of each side, so that 6 goes between the two smallest numbers, and 4 goes between the two largest.  With 5 fitting in between 1 and 3, the triangle is balanced, and the sum of each side is 9.

The logical extension is to look at a triangle which has four circles per side, and to start with the same strategy.





As we can see from the diagram on the right, the digits 1, 2 and 3 are placed in the corners, then 4, 5 and 6 go into the sides, followed by 7, 8 and 9.  It's a similar process, but taken a step further.  It takes slightly more care to distribute the 4, 5, 6, 7, 8 and 9 in a balanced way, but it's not too difficult.  The sum of each side, in this case, is 17.

And we can even extend this further to five circles per side, and even to six.  Given this healthy trend, I would conclude (without real proof) that it's possible to continue this series indefinitely.


Here are the solutions for the triangles with lengths five and six.


Side length = 5.  Sum of sides = 28.

Side length = 6.  Sum of sides = 42


I then did some additional work on the sum of the sides for each triangle.  As the triangle becomes one circle longer, the sum of each side increases (as we are using larger and larger numbers).  We can study this relationship in more detail.

3 circles per side - sum is 9
4 circles per side - sum is 17
5 circles per side - sum is 28
6 circles per side - sum is 42

Taking the difference between 9 and 17; 17 and 28; 28 and 42; we obtain 8, 11 and 14 and the difference between those terms is 3.  This means that we have a constant second difference - the difference between the differences is a constant value, and this means that the sum of the sides is related to the side length by a quadratic relationship.  We also know that the second difference is 3, and this means that the the co-efficient of the square in the quadratic relationship is 3/2 (i.e. half of the second difference).

Hence
sum of side = 3/2 (length)^2 + b length + constant

If we let the sum of the side be s, and the length be l, and start to analyse the relationship by looking at the terms for 3l2/2, we get:


l
1
2
3
4
5
3l2/2
1.5
6
13.5
24
37.5
l/2
0.5
1
1.5
2
2.5
3l2/2 + l/2
2
7
15
26
40
+2

9
17
28
42

3l2/2 does not give integer results for odd values of l, hence I added l/2 so that all odd values would give integers.  3l2/2 + l/2 does give results close to the values I was aiming for, and you can see that 3l2/2 + l/2 + 2 gives the result, where l = edge length -  1

So: s = (3l2 + l + 4) / 2

Where s is the sum of each side of the triangle, and l is (length of each side -1 ).


So, for example, for a triangle with side length = 6, the sum of each side would be 79.




Wednesday 20 March 2019

Maths Puzzle: 'Round Goes the Gossip

Continuing the thread of Math-E-Magic puzzles (I'm slowing down for various reasons, but let's continue anyway), I came across this puzzler which has taken me a while to solve.  In fact, I couldn't find the best solution, and had to consult the answers (yes, so sue me!).

The puzzle goes like this (and it has various forms):

There are six busybodies in town who like to share information.  Whenever one of them calls another, by the end of the conversation they both know everything that the other one knew beforehand.  One day, each of the six picks up a juicy piece of gossip.  What is the minimum number of phone calls required before all six of them know all six of these tidbits?

I pondered and sketched for a few days, before checking the answer.  The best I could achieve was nine, but the answer page starts, "The answer is eight."  So I went back to my diagrams and tables, but still couldn't get it down to eight - which was unfortunate, because I was most of the way there.  Here, then, is the official answer, and I'll point out what I missed and how I needed an extra phone call.


Firstly, label the six gossips A,B,C, D,E and F.  Then divide them into two groups - A-B and D-F.  (I did this after a few stalled trials of my own).  A talks to B and then C; D talks to E and then F.  These are conversations 1,2 and 3,4 shown below.
At this point, C and A both know A, B and .  Similarly, F and D both know D,E and F.  One conversation between C and F will mean that those two gossips will know everything, and be ready to pass this back to the rest of their teams.  What I missed is that A and D both know everything, and one conversation will complete their knowledge.  So, since I only used C and F's knowledge, it took me two further conversations (each), so the total went from five up to nine (C-B, C-A; F-E and F-D).  It's much more efficient to have A and D speak directly.

Conversations 7 and 8 are C-B (bringing B to completion) and F-E (bringing E to completion).

In general terms, for a puzzle like this (according to the answers), if you have n busybodies, then you will require 2n-4 conversations to have everybody share all the information.

Friday 15 March 2019

Maths Puzzle: Top Score

If a bunch of positive integers adds up to 20, what is the greatest possible product of those numbers?
There are two strategies to try here:  use the largest numbers and multiply them together, or grab a bundle of smaller numbers and multiply those together instead.


1.  Large numbers
10+10 = 20
10 * 10 = 100

9+9+2 = 20
9 * 9 * 2 = 162


A reasonable start.  Let's try some more at the other end of the scale - the smaller numbers.

2.  Small numbers


5 * 5 * 5 * 5 = 625
4 * 4 * 4 * 4 * 4 = 1024

2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 = 1024

Moving towards the smaller numbers has definitely yielded larger products, but we've identifed a maximum between 4^5 and 2^10.  There may be a winner between the two.

Indeed, 2 * 3^6 gives...

3 * 3 * 3 * 3 * 3 *3 * 2 = 1458

...which is the highest total product of digits which sum to 20.


Tuesday 12 March 2019

Maths Puzzle: 1/a + 1/b + 1/c = 1

Another quick puzzle from Math E Magic (by Raymond Blum, Adam Hart-Davis, Bob Longe and Derrick Niederman).

"Find three distinct integers, a, b and c, such that 1/a + 1/b + 1/c = 1".


Firstly:  does one of 1/a, 1/b or 1/c have to be 1/2?


Yes.  Without 1/2, the largest number we can obtain is 1/3 + 1/4 + 1/5 = 47/60 (0.78333).  So the first number has to be 2.


Now, what do we obtain by trying 1/2 + 1/3 + 1/4 (the next simplest solution)?

Answer:  13/12.  So we're going to need something a little smaller.  1/2 + 1/4 plus anything else is going to be too small, so we'll progress with 1/2 + 1/3.


1/2 + 1/3 = 5/6, which immediately highlights the simple solution, that 1/2 + 1/3 + 1/6 = 1, since 1/2 = 3/6 and 1/3 = 2/6.

This was in the trickier section of the Mathemagic book, and it appealed to me as it can be solved by logic and reason, instead of pure trial and error (which, in my view, is what "hard" sometimes means in maths puzzle books :-) )

Sunday 10 March 2019

Maths Puzzle: Square Inheritance: a2-b2 = b2-c2

Here's the next question in the Math-E-Magic series of puzzles and problems.  This question is taken from the harder section towards the back of the book (I was breaking us all in gently with my previous posts).  I'll paraphrase the problem text, which is taken from "A Square Deal," on page 190.

A man has a piece of land he wants to leave to his three children.  To his first child, he leaves an L-shaped piece of land, comprising the whole plot except a square that has been cut out of the north-east (top-right) corner.  To his second child, he leaves this middle section, except for a smaller square that is taken from the corner of the plot - this smaller square goes to his third child.

The first child gets the area shown in yellow; the second child gets the area shown in pink, and the third child gets the area shown in blue.  The squares have sides a, b and c, as shown.  The diagram is not to scale.
The one constraint is that the first two children must receive land which has the same total area.  There are many solutions to this problem, but the question is: can you identify the simplest solution with the smallest numbers for the sides a, b and c?

Firstly, let's express the question mathematically:

The first child receives the area a2 - b2.  The second child receives the area b2-c2.  These two areas are the same, hence a2 - b=  b2-cand we must exclude the obvious b=0 and a = -c.

Trial and error will work here, but there are a number of tips that you can use to find one solution.  Notice that Pythagorean triples (a2 + b=  c2) are no help; we're solving a different puzzle here.

Tip:  a and b are going to be closer together than b and c.  Rearranging our puzzle expression a2 - b=  b2-c2  gives us a2  =  2b2-cand if a2 > 2b2 then there is no solution; b must be greater than a/2.

Starting with the simplest numbers (as suggested in the question), I found a solution:  a = 7, b = 5 and c =1, which has the convenient feature of probably being the simplest since c=1.

7*7 - 5*5 = 49 - 25 = 24
5*5 - 1*1 = 25 - 1 = 24

QED

With these values, the two children get an area equal to 24 square units,while the third child gets the remaining one square unit.  Total = 24 + 24 + 1 = 49.

Having found my own solution, I checked the answers in the book.  Interestingly (and controversially) the Math-E-Magic answers section has this to say:

"The proper dimensions are as shown [a = 14, b= 10, c=2].  There is no solution if the smallest square is only one mile on each side.  There is however, a solution where the smallest square has a side of two.  THe plots of the second and third child each measure 96 square miles, and the total are of the father's plot was 196 square miles."


Interestingly, the authors overlooked the simplest solution I found, in the same way as I overlooked theirs.  I'll get in touch with them and let them know :-)  Also, it's worth noting that my solution (a=7,b=5,c=1) is obtained by halving their solution (a=14,b=10, c=2) - this applies to all integer multiples (a=21, b=15, c=3 is another solution, as is a=28, b=20, c=4, and so on).

Here's a list of the solutions that I identified - it's not exhaustive, but it's what I could find in about 30 minutes of trial and improvement:


a=7, b=5, c=1 (the simplest), and all other multiples of these (14,10,2;  21,15,3; 28,20,4, etc.).
a=17,b=13,c=7
a=23,b=17,c=7


Two final notes on my solutions:

- In their simplest form, all of the variables are prime numbers.  This could be just coincidence, but I've not found a solution which contains non-prime numbers (in the simplest form).
- I was very surprised (although I probably shouldn't be) to find two solutions with c=7.






Wednesday 6 March 2019

Analysis is Easy, Interpretation Less So

Every time we open a spreadsheet, or start tapping a calculator (yes, I still do), or plot a graph, we start analysing data.  As analysts, it is probably most of what we do all day.  It's not necessarily difficult - we just need to know which data points to analyse, which metrics we divide by each other (do you count exit rate per page view, or per visit?) and we then churn out columns and columns of spreadsheet data.  As online or website analysts, we plot the trends over time, or we compare pages A, B and C, and we write the result (so we do some reporting at the end as well).
Analysis. Apparently.

As business analysts, it's not even like we have complicated formulae for our metrics - we typically divide X by Y to give Z, expressed to two decimal places, or possibly as a percentage.  We're not 
calculating acceleration due to gravity by measuring the period of a pendulum (although it can be done), with square roots, fractions, and square roots of fractions.

Analysis - dare I say it - is easy.

What follows is the interpretation of the data, and this can be a potential minefield, especially when you're presenting to stakeholders. If analysis is easy, then sometimes interpretation can really be difficult.

For example, let's suppose revenue per visit went up by 3.75% in the last month.  This is almost certainly a good thing - unless it went up by 4% in the previous month, and 5% in the same month last year.  And what about the other metrics that we track?  Just because revenue per visit went up, there are other metrics to consider as well.  In fact, in the world of online analysis, we have so many metrics that it's scary - and so accurate interpretation becomes even more important.


Okay, so the average-time-spent-on-page went up by 30 seconds (up from 50 seconds to 1 minute 20).  Is that good?  Is that a lot?  Well, more people scrolled further down the page (is that a good thing - is it content consumption or is it people getting well and truly lost trying to find the 'Next page' button?) and the exit rate went down.  

Are people going back and forth trying to find something you're unintentionally hiding?  Or are they happily consuming your content and reading multiple pages of product blurb (or news articles, or whatever)?  Are you facilitating multiple page consumption (page views per visit is up), or are you sending your website visitors on an online wild goose chase (page views per visit is up)?  Whichever metrics you look at, there's almost always a negative and positive interpretation that you can introduce.


This comes back, in part, to the article I wrote last month - sometimes two KPIs is one too many.  It's unlikely that everything on your site will improve during a test.  If it does, pat yourself on the back, learn and make it even better!  But sometimes - usually - there will be a slight tension between metrics that "improved" (revenue went up), metrics that "worsened" (bounce rate went up) and metrics that are just open to anybody's interpretation (time on page; scroll rate; pages viewed per visit; usage of search; the list goes on).  In these situations, the metrics which are open to interpretation need to be viewed together, so that they tell the same story, viewed from the perspective of the main KPIs.  For example, if your overall revenue figures went down, while time on page went up, and scroll rate went up, then you would propose a causal relationship between the page-level metrics and the revenue data:  people had to search harder for the content, but many couldn't find it so gave up.


On the other hand, if your overall revenue figures went up, and time on page increased and exit rate increased (for example), then you would conclude that a smaller group of people were spending more time on the page, consuming content and then completing their purchase - so the increased time on page is a good thing, although the exit rate needs to be remedied in some way.  The interpretation of the page level data has to be in the light of the overall picture - or certainly with reference to multiple data points.  


I've discussed average time on page before.  A note that I will have to expand on sometime:  we can't track time on page for people who exit the page.  It's just not possible with standard tags.


So:  analysis is easy, but interpretation is hard and is open to subjective viewpoints.  Our task as experienced, professional analysts is to make sure that our interpretation is in line with the analysis, and is as close to all the data points as possible, so that we tell the right story.

Monday 4 March 2019

Maths Puzzle: Sugar Cubes (orders of magnitude)

Continuing the current series of puzzles taken from Math-E-Magic, here's one which tests understanding of orders of magnitude.

Sugar Cubes
The Big Sugar Corporation wants to persude people to use lumps of sugar, or sugar cubes; so they run a puzzle competition and the first person to achieve correct answers to all three questions wins a lifetime supply of sugar.  It's not the healthiest competition, but here we go.

You have been sent one million cubes of sugar; each cube is just half an inch long, wide and high.

1.  Suppose the 1,000,000 sugar cubes arrive packed into one giant cube.  Where would you store it?  Garage? Warehouse? Under the table?

2.  Suppose you lay the 1,000,000 sugar cubes out on the ground in a single square layer.  How much area would you need?  A tennis court?  A football field?  An entire car park?



3.  Suppose you stacked the sugar cubes (if you were able to play this sweet Jenga) into a single tower 1,000,000 cubes high.  How far would it reach?  As high as a house? Skyscraper? Mountain?  To the Moon?

Let's do some maths.

1.  If we form a cube from the little sugar cubes, then each side of the cube will need to be the cube-root of 1,000,000 cubes long.  The cube root of a million is 100, since 100 cubed = 100 x 100 x 100 = 1000000

Each cube is a quarter of an inch long (we started in imperial measurements, so we'll stay there for now), and since 100 x 0.25 = 25, then the cube will be 25 inches long, wide and high.  Under the kitchen table will do fine.  (25 inches is approx. 60 cm.).

2.  To form a square from the sugar cubes, each side will have a length equal to the square root of 1,000,000 and that's 1,000.  1,000 x 0.25 inches = 250 inches, or nearly 21 feet.  A square with sides of 21 feet would fit into a medium-sized garden, or about six car park spaces.  A tennis court is 27 feet wide (for singles) and 63 feet long, so it would fit comfortably in half of a tennis court (from the baseline to the net).  In fact, the service line (the area which marks the two service boxes) is exactly 21 feet from the net and parallel to it.

3.  One million sugar cubes, eventually stacked one on top of the other, would be 250,000 inches (a quarter inch multiplied by a million).  250,000 inches is 20,800 feet, or 6,944 yards, which is just under four miles.  That won't reach the moon (250,000 miles away), it's more like a small mountain.

Gobally, the top 100 mountains are all above 23,000 feet, but we are still talking around the scale of a mountain.

The highest mountain in the UK is Ben Nevis, which stands at 4,411 feet.
The tallest in Europe is Mount Korab in Albania, which is 9,068 feet.
Sugarloaf Mountain in Brazil is 15,000 feet (396 metres).
Our sugar mountain, at 20,800 feet, is certainly a respectable mountain.


--

Incidentally, if you were (in some way) able to stack the sugar cubes at the rate of one a second for a million seconds, that would be 277 hours, or 11.5 days.  If you stacked them at the rate of one a minute (which it may be as you start climbing an adjacent mountain), then you'd be going for almost two years.