Some sharks, dolphins, and whales get in line to get tickets for the opera...
Since the sharks are an unruly bunch, they can't be in line before or after a dolphin:
How many ways do they have of forming a line consisting of ten sea creatures?
Inspiration: Brian Charlesworth
Image credit: https://www.pinterest.com http://www.istockphoto.com/ https://cliparts.zone
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Let S n , D n and W n denote the number of lines of length n ending with a Shark, with a Dolphin and with a Whale respectively. In this notation, it is evident the answer we seek is S 1 0 + D 1 0 + W 1 0 .
Now the three recurrence relations arise:
(1) S n + 1 = S n + W n
(2) D n + 1 = D n + W n
(3) W n + 1 = S n + D n + W n
because, in words, while a whale can be 'put on the end' of any previous line, a shark cannot be put on the end of a whale line, and a whale cannot be put on the end of a shark line.
Now, it helps to also define Σ n = S n + D n + W n , so we are looking for Σ 1 0 . Adding together our recursion relations (1), (2) and (3):
S n + 1 + D n + 1 + W n + 1 = 2 S n + 2 D n + 3 W n
Σ n + 1 = 2 ( S n + D n + W n ) + W n
Σ n + 1 = 2 Σ n + W n
Since W n + 1 = S n + D n + W n = Σ n , W n = Σ n − 1 so
Σ n + 1 = 2 Σ n + Σ n − 1 , thus Geoff's recurrence relation is derived. It is left to find base cases Σ 1 = 3 and Σ 2 = 7 to work up to Σ 1 0 = 8 1 1 9 , using artithmetic or a quick piece of code e.g
def sum(n):
if n==1:
return 3
if n==2:
return 7
else:
return 2*s(n-1) + s(n-2)
print(s(10))
...
>>>8119
Cool... I was trying to think of a good way to show it, and you hit the nail right on the head!
Log in to reply
I hope the notation and explanations are clear. Thanks for the great problem!
Problem Loading...
Note Loading...
Set Loading...
A partial solution...
The answer is found using the following recursion relation:
Let N n be the number of ways that n sea creatures could form this line:
Using this relation,
N 1 0 = 8 1 1 9
To see how this recurrence relation is derived see Arthur's solution below...