6
\$\begingroup\$

Welcome to BBC Casting. We need a program that we can use to select a new actor to play The Doctor on Doctor Who. In the spirit of the show, your program will perform a regeneration from one actor's name to the next.

We will test your program by running through the 13 names of actors who have already played The Doctor and then run it another 13 times. We will pass the output from one call as the input to the next in a loop.

Detailed Requirements

  • Your program will take a string as its only input and output a single string. It must not store any state between calls or use any additional resources outside of the program.
  • If the input is your starting string, your program must return "William Hartnell", the first name on the list.
    • You should select and document any string you wish to use as the starting string, as long as it isn't the name of a listed actor. My example below uses an empty string.
  • If the input string is an actor's name (other than the last), your program must return the next name on the list following the name inputted.
  • For any other inputs, behavior of your program is undefined.
  • The list of actors below is incomplete. You must complete the list by selecting 13 more names of actors you feel would be good at playing The Doctor.
    • Each extra name must be of a professional actor with an IMDB page.
    • The extra names returned by your program must be the actors' names exactly as listed on IMDB, including case, accents and diacritics.
    • The completed list of 26 actors must be 26 distinct individuals with distinct names.
  • You may interpret input and output according to the constraints of your language's execution environment. (Parameters, quotes, end-of-lines, stdin/out, encoding etc.)
  • Shortest conforming program wins. Normal code-golf rules apply.
  • You may use someone else's list of actors. If you do, give appropriate credit and share the glory. (Finding a list of actors that would compress well might be part of the challenge.)

The first half of the list of names is as follows. These strings must be output exactly as shown, preserving case including the extra capital letter in "McCoy" and "McGann".

William Hartnell
Patrick Troughton
Jon Pertwee
Tom Baker
Peter Davison
Colin Baker 
Sylvester McCoy
Paul McGann
John Hurt
Christopher Eccleston
David Tennant
Matt Smith
Peter Capaldi

For example:

YourProgram("") returns "William Hartnell".
YourProgram("William Hartnell") returns "Patrick Troughton".
YourProgram("Patrick Troughton") returns "Jon Pertwee".
/* 10 more. */
YourProgram("Peter Capaldi") returns "Pauley Perrette".
YourProgram("Pauley Perrette") returns "Nathan Fillion".
/* 12 more. */
\$\endgroup\$
5
  • 3
    \$\begingroup\$ So, for clarity, the challenge is finding the next value in an array by its preceding value? \$\endgroup\$
    – ricdesi
    Feb 25, 2016 at 20:08
  • \$\begingroup\$ @ncdesi - Exactly. Expressing that array in as few characters as possible would probably be the hard bit. (Also, you don't have to use an array.) \$\endgroup\$
    – billpg
    Feb 25, 2016 at 20:10
  • 7
    \$\begingroup\$ Too bad we can't just fill the second half of the list with 13 "David Tennant". \$\endgroup\$
    – Geobits
    Feb 25, 2016 at 20:20
  • 1
    \$\begingroup\$ Yb, Ak, MC, Vv, Eu, Re, Ei, Ek, Gu, As, Yt, Os, and Ku are IMDb actors with at least one acting role not as themselves. \$\endgroup\$
    – Lynn
    Feb 25, 2016 at 22:30
  • 1
    \$\begingroup\$ Post-mortem discussion of this question on the meta site: meta.codegolf.stackexchange.com/q/9813/20793 \$\endgroup\$
    – billpg
    Aug 11, 2016 at 17:29

1 Answer 1

2
\$\begingroup\$

Python 2, 340 bytes

#coding:L1
import zlib;r=zlib.decompress("x5mÂ@¯Â 8]c]u×Xã-q1H5½ýRãþ#÷O³PÌsÆ=¹IºÁÑêx¼*~W=¿ñX,èÆ{v6ø¢§<⦩Yô³é¦üäǼݥ¦NAs+Ò5(´£96ÉÃë}»eJ9>3óz8²*©ãÜ¡+âÃG®¡;å^pY\nÁ|þ7Ü9¿\"®ICmYXqÁʽ$f,g¶3yÞ!ZéûfÇñÑTU¶ Û\r[M8̨põ)ËåÂxïѬLÂÜlßÜ\nwI×+nX`£åep;·ûÃVÿ À]b").split('.');print r[r.index(input())+1]

The encoding is Latin-1 (aka ISO-8859-1). That first line is important because Python 2 doesn't like non-ASCII characters in files by default (and using Python 3 wouldn't help, because it expects UTF-8 by default, along with loads of other issues).

Takes quoted input (single and double both work), with the initial input as the empty string ('').

The strategy I used was constructing a list of period-separated names (starting with an empty string) and compressing it with zlib (which gave better results over both shoco and lzma). This program decompresses that list, splits it on periods, and outputs the element in the list that follows the input.

I didn't use any real strategy with choosing the next 13 actors, other than picking living British actors (sorry, Alan Rickman, you would've been great) that I liked who haven't played a Doctor yet. The rationale was, the character distribution in the first 13 names is fairly random (as far as names go), so it's unlikely (in my opinion) that 13 more names could be picked that would make a significant difference in compressed size.

For reference, the list I used (with an extra linebreak to separate the new actors):

William Hartnell
Patrick Troughton
Jon Pertwee
Tom Baker
Peter Davison
Colin Baker
Sylvester McCoy
Paul McGann
John Hurt
Christopher Eccleston
David Tennant
Matt Smith
Peter Capaldi

Emma Watson
Patrick Stewart
Ian McKellen
Benedict Cumberbatch
Tom Hiddleston
Sean Connery
Hugh Laurie
Daniel Radcliffe
Rupert Grint
Gary Oldman
Simon Pegg
Keira Knightley
Liam Neeson
\$\endgroup\$
6
  • 2
    \$\begingroup\$ You could use the thirteen living actors with the shortest names to save a few bytes? \$\endgroup\$
    – A Simmons
    Feb 25, 2016 at 21:08
  • \$\begingroup\$ That was my thinking too, @ASimmons. Little did I know how perfect a 14th Doctor Ray Park would make. It's a shame Jude Law will have to replace him in 2023. \$\endgroup\$
    – ricdesi
    Feb 25, 2016 at 21:09
  • \$\begingroup\$ @ASimmons I'm not interested in combing IMDB pages to find 13 British actors with short names. I'll stick with the list I chose. To be fair, the challenge doesn't state anywhere that the Doctor must be played by a British (well, British, Scottish, or Welsh) actor (though that is the case in reality). \$\endgroup\$
    – user45941
    Feb 25, 2016 at 21:11
  • 2
    \$\begingroup\$ Nice work. I'd be interested to see if 13 Peters with similar surnames to the first 13 could bring a significant improvement. \$\endgroup\$
    – billpg
    Feb 25, 2016 at 21:16
  • 1
    \$\begingroup\$ In any case, I can't be the only one who thinks that Li Li, Xu Xu, Qi Qi, and the other Qi Qi would all do a really good job as the Doctor? \$\endgroup\$
    – A Simmons
    Feb 25, 2016 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.