Wednesday, 30 January 2013

Another slip of the tongue

A cracker from a continuity announcer this afternoon:

"At 2:15, Patrick Malahide stars as Albert Speer, or prisoner number five as he was known throughout his twenty years in Spandau Ballet"

I think Speer played the saxaphone.

Sunday, 27 January 2013

Enigma 49

New Scientist magazine's Enigma #49 problem can be solved with a bit of number theory. Generalising the problem to finding a number whose square has the same last N digits as itself:

z= z mod 10N  →  z(z-1) = 0 mod 10N. One factor of z(z-1) is odd, the other even. The even factor is a multiple of 2N.

For a solution other than 0 or 1, the odd factor of z(z-1) must be a multiple of 5N (if the even factor is a multiple of 5 it is a multiple of 10, so the odd factor is congruent to 1 or 9 mod 10 and therefore not a multiple of 5, so the even factor is a multiple of 10N).

So the solution is one of
a)  z=2Nx,    z-1=5Ny
b) z-1=2Nx,   z=5Ny

Solutions to the Diophantine equation 2Nx+ 5Ny=1  produce the solutions
a) z=2N(x mod 5N)
b) z=5N(y mod 2N)

So, some Python code. Function egcd is a standard recursive implementation of the Extended Euclidean Algorithm to find solutions to a linear Diophantine equation (and the gcd as a by-product).

def egcd(a,b):
  if b == 0:
    return [1,0,a]
  else:
    x,y,g = egcd(b, a%b)
    return [y, x - (a//b)*y, g] 

for N in range(1,40):

  x,y,g = egcd(5**N, 2**N)
  print "N =",N, sorted([(x%2**N)*5**N, (y%5**N)*2**N])

Friday, 4 January 2013

A slip of the tongue

This had me laughing for several minutes.

"Squawk"
Matt Ridley talking on "The Value of Culture" on Radio 4 this morning (about 6 mins 30 sec in from the start):

"I live in a culture called science which is a tribe, but that tribe has no particular place in the world, but yet it is just as narrow as if it were a particular New Guinea group of people who killed birds of paradise with blowtorches"

Monday, 17 December 2012

New Scientist Enigma 1728

This week's Enigma puzzle was interesting enough to publish an analysis.

This diagram shows the dynamics of the situation. $V_j$ is Jack's speed, $V_k$ is Ken's speed. $g$ is their initial goal line separation.



Defining $D$ as the distance between Joe and Ken, we will try to find the minimum of $D^2$ and hence the minimum of $D$

$D^2 = (g-V_j t cos\theta)^2 + t^2(V_k - V_j sin\theta)^2 $

$D^2 = g^2 - 2 g V_j t cos\theta +(V_j^2 + V_k^2)t^2 - 2 V_j V_k t^2 sin\theta$           ..............(1)

The minimum occurs when:

                    $\frac{\partial{D^2}}{\partial \theta}$ $= 2gt V_j sin\theta - 2 V_j V_k t^2cos\theta =0$                               .................(2)

                    $\frac{ \partial{D^2}}{\partial{t}}$ $= -2g V_j cos\theta +2t(V_j^2 + V_k^2) - 4t V_j V_k sin\theta =0$ ...............(3)

From (2), 
$t=$ $\frac{g}{V_k}$ $tan\theta$                                                  ..............................(4)

Substituting (4) into (3):
$ -2g V_j cos\theta +2\frac{g}{V_k} (V_j^2 + V_k^2)\frac{sin\theta}{cos\theta} - 4g V_j\frac{sin^2\theta}{cos\theta} =0$           .....................(5)

Defining $s=sin\theta$ and multiplying (5) through by $\frac{- cos\theta}{2gV_j}$ :

$ (1-s^2)-(\frac{V_j}{V_k}+\frac{V_k}{V_j})s+2s^2= (s-\frac{V_j}{V_k})(s-\frac{V_k}{V_j}) = 0$ 


If $V_j < V_k$, this quadratic has one solution satisfying $s\lt1$, namely $s=\frac{V_j}{V_k}$

so 

$sin\theta=$$\frac{V_j}{V_k}$ and $t=$ $\frac{g}{\sqrt{1-V_j^2/V_k^2}}$

Substituting these into (1)  gives:

$D^2 = $$\frac{g^2}{V_k^2}$$(V_k^2-V_j^2)$

so

$D = g\sqrt{1 - V_j^2/V_k^2}$        ............................... (6)

Substituting the values $g=25ft, V_j=12mph, V_k=12.5mph$ into (6) gives the answer to the puzzle.

The notable aspect of this analysis is that to minimise the distance between them when $V_j \lt V_k$, Joe runs at an angle $\theta$ where $sin\theta=\frac{V_j}{V_k}$. When $V_j \gt V_k$, Joe would run at an angle $\theta$ where $sin\theta=\frac{V_k}{V_j}$ in order to intercept Ken.



Wednesday, 17 October 2012

Who owns the zebra?

I was prompted to add a Python code solution to the classic Zebra puzzle after working on two logic puzzles on the web that have a similar form: Sunday Times Teaser 2606 and New Scientist Enigma 1430.

The code to solve the Zebra Puzzle adds one category (house colour, nationality, drink, smoke, pet) at a time, filtering as much as possible at each step, in order to minimise the number of combinations that need to be checked:

Sunday, 14 October 2012

Malham Tarn to Arncliffe

Another Sunday with decent weather, though not as sunny as last weekend. I drove up to Malham Tarn and parked at Street Gate. The parking area was a bit soft after the recent rain, but not too bad.

Click to see the interactive map

I started walking north east from Street Gate in a chilly easterly wind,  towards a ford where a number of streams join to form an area of water. The ford looks worse than it is, and there are strategically placed rocks that allow it to be negotiated without getting your feet wet. Walking east from the ford and following the path as it ascends to the north, at the summit views of Littondale appeared in the distance.
The path from Street Gate to Arncliffe Cote wasn't as obvious on earlier OS maps, but has been marked as a footpath on more recent maps.  There are always highland cattle in this area, who seem to like posing to have their photo taken. Following the path downhill, fine views of Cote Gill appeared as I walked towards Arncliffe Cote. 

Looking down to Littondale
It was clouding over as I got towards Arncliffe Cote and I couldn't decide which route to take. I had originally planned to walk across to Kettlewell, (purple route on map), but this option is better on a  sunny Summer's day, so I opted to walk through Hawkswick village and then followed  a farm track north west up the hillside. This provides great views up and down Littondale.

Littondale
Through a gate on the farm track there is a small stone building, possibly used by game shooting parties. The path forks at this point, the left fork following the contour west, but I took the right fork climbing to the north. After a few hundred metres, this crosses the broad path that runs between Arncliffe and Kettlewell, which I followed back down to Arncliffe village and the Falcon Inn.

Cowside Beck from Monk's Road
The Falcon is a great traditional country pub that serves Timothy Taylor beer from a jug filled directly from the barrel. After a pint of beer, I set off back to Malham Tarn on the Monk's Road. The views over Cowside Beck are spectacular here.

Following the Monk's Road, Middle House Farm is reached. It is possible to walk directly to Street Gate from here, but it's worth the detour to view Malham Tarn.

From Malham Tarn, a track leads directly to Street Gate.


 
Middle House Farm
Malham Tarn

Thursday, 11 October 2012

Can I have a P please, Bob?

Click to play Hex

Your aim is to build a chain of red cells linking the left and right hand sides. The computer is trying to build a blue chain linking top and bottom.

Click the screen shot to play a game: