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:

Tuesday 9 October 2012

Anagrams

Find anagrams of a phrase or a person's name using my anagrams program.

Click the screen shot to run the anagrams program.

Click to run the anagrams program
Here are some examples (which will give away when I wrote the code)
"I nudist chinaman"
"America blast pall"
"Be sow hugger"
"Damns USA hides!"
"Italy born"
"A blond asian, me"
"W, he bugs Gore"
"Ugh, sewer gob"

"I model bananas"
"I rat nobly"
"Muddler of Lands"
And a new one:
"My, I'm rotten"

Sunday 7 October 2012

Troutbeck, Ill Bell, Stony Cove Pike, Wansfell Pike

Click for the interactive map
A superb sunny day, just right for a day in the Lake District, so up to car park of The Queen's Arms at Townhead, on the road from Windermere to Patterdale. There are a few parking spaces in a  lay-by before the pub, but these are quickly taken on a sunny Sunday.

I started by walking back down the road to Limefitt Park, walking through the site (there is a right of way), past the on-site pub to a footpath heading north east for 200m, then doubling back south on a footpath for 400m, then north east again to pick up Garburn Road.

Ill Bell in the distance
A few sections of this track have suffered from the heavy rain of the summer, and have been washed away. Following the Garburn Road north east for 2km to a junction, east leads to Kentmere, but I followed the path north to the roller coaster of three summits: Yoke, Ill Bell and Froswick, giving fantastic views to the west of the main body of the Lake District summits, including Scafell Pike, and views to the east of Kentmere Resevoir.

I carried on to the Beacon at Thornthwaite Crag, a popular place for a lunch break, overlooking Racecourse Hill and High Street. Normally on a Sunday there are a dozen or more people resting here, but today surprisingly there were only three other people.

After lunch, I headed west down a steep descent to the hause at Threshthwaite Mouth and a steep ascent back up again, to Stony Cove Pike. It's hard to discern the summit of this peak, but on the summit I met a family with a boy of about five years old, who excitedly told me that he had just climbed his first mountain.
Kentmere Resevoir


Looking back towards Ill Bell
I followed the path south to the Kirkstone Pass Inn, always a popular pub at Sunday lunchtime, and had an excellent pint of the locally brewed bitter,Tirrel Old Faithful, sitting outside in the sunshine.

I then headed down "The Struggle" for 400m to pick up a footpath heading south. I have never found a satisfactory route for the next section. The aim is to get onto the path that leads to Wansfell Pike. Following the path from The Struggle for about 1km, I then headed east up the hillside, to the western flank of Idle Hill, to pick up the path that heads south then veers west to Wansfell Pike. There are pleasant views overlooking Ambleside here, and I had a final rest on the summit before taking the path east to pick up Nanny Lane, back to the main road and the Queen's Arms car park.



Saturday 6 October 2012

Using LaTeX in Blogger

Many thanks to Jimmy Touma for demonstrating how to use LaTeX within Blogger.
http://badphysicist.blogspot.co.uk/2012/09/latex-in-blogger.html

Now that I have got it working, I might have a go at rewriting my previous posts using LaTeX.

Friday 5 October 2012

Python implementation of Wheel Factorisation

Here is a description of a Python implementation of Wheel Factorisation to find prime numbers.  The goal is to see how quickly π(n), the number of primes ≤ n, can be calculated for values up to π(1011) using  wheel factorisation, comparing various wheel sizes.

Using the optimum wheel size, π(1011) can be calculated in under 12 minutes.

Miller Rabin Primality Testing

In the course of developing C code to run a Miller Rabin primality test, I came across two variants of the test. Most web sites describe the same test, but Wikipedia includes an additional test, essentially identifying a square root of 1 (mod n) that is not equal to $\pm 1 \,\,(mod \,\,n)$ .

I ran a few experiments how useful this variant was in practice, concluding that the additional test is of no practical benefit.