9
\$\begingroup\$

There are currently nine feature length films in the core Fast & Furious/The Fast and the Furious media franchise, a series of films about bald men scowling and driving cars very fast. The names of the films, as can be seen, follow a completely logical and sensible convention:

  • The Fast and the Furious
  • 2 Fast 2 Furious
  • The Fast and the Furious: Tokyo Drift
  • Fast & Furious
  • Fast Five
  • Fast & Furious 6
  • Furious 7
  • The Fate of the Furious
  • F9

I'm a Hollywood producer working on the new, tenth Fast & Furious film, and I'm struggling to find a title which hasn't yet been used. Please write me a piece of code - as short as possible - which takes in my input string, and returns a truthy value if any of the following are true:

  1. the input string is already an existing Fast & Furious film title
  2. the input string differs from an existing Fast & Furious film title only by replacing an existing number with ten or 10
  3. the input string differs from an existing Fast & Furious film title only by replacing & with and (or vice versa).

For instance, all of these strings would return a truthy value:

  • The Fast and the Furious (matches check 1)
  • The Fast & the Furious (matches check 3)
  • Fast and Furious 10 (matches checks 2 and 3)
  • 10 Fast 2 Furious (matches check 2)
  • Furious Ten (matches check 2)
  • F10 and FTEN (match check 2)

And all of these strings would return a falsy value:

  • The Fast or The Furious
  • Fast Times at Ridgemont High
  • Fast/Furious 10
  • Too Fast Too Furious
  • Ten Furious
  • Fast Ten Furious
  • The Fast and the Furious: Kyoto Cruise

Fate of the Furious, as a pun, is obviously a tricky case. Unless you're very driven, you don't need to support puns, just exact text matches. If you can create a new Fast & Furious film title which is a pun, please share.

Clarifications

  • The matching is not case-sensitive, so the input string can be in lowercase. The film company design team will work out how to depict your title on the posters anyway, and the answer is 'in red, with speedy lines'.
  • I've clarified that the numbering match should only be true if an existing number in the title has been replaced with the string 10 or ten.
\$\endgroup\$
10
  • 4
    \$\begingroup\$ Welcome to Code Golf and nice first question! For future reference, we recommend using the Sandbox to get feedback on challenge ideas before posting them to main. We require all questions to have an objective winning criteria to be scored. I'd suggest [code-golf] (shortest code), and that you should add some falsey test cases \$\endgroup\$ Commented May 1, 2021 at 19:27
  • \$\begingroup\$ If matching numbering by english is required, this will need a bit more clarification on what exactly counts as a number and what doesn't. For example, is forty nine a number, or only forty-nine; is it one hundred or a hundred or does just hundred suffice, etc. I think it might not be a bad idea to just make it so "differs by numbering" needs to only handle numbers as digits, since all of the original titles just have digits too. \$\endgroup\$ Commented May 1, 2021 at 19:30
  • 1
    \$\begingroup\$ Is this case-sensitive or can we perhaps take the input in, say, lowercase? \$\endgroup\$ Commented May 1, 2021 at 19:32
  • \$\begingroup\$ @hyper-neutrino Ah, if only that were true! 'Fast Five' is the exception. I am however happy to specify that only the digits 1-9 need to be checked. \$\endgroup\$ Commented May 1, 2021 at 19:33
  • 4
    \$\begingroup\$ As it stands, test case Fast and Furious 10 (matches checks 2 and 3) appears inconsistent with the rules. This is derived from Fast & Furious 6 by changing a number AND by substituting & -> and but checks 2 and 3 (as written) say ONLY one change (not both.) \$\endgroup\$ Commented May 1, 2021 at 22:21

1 Answer 1

1
\$\begingroup\$

Python 3, 190 bytes

lambda a:re.match("(the '!the %(: tokyo drift)?|(2# ' (2# %|'!%|' (five#|'!% (6#|% (7#|the fate of the %|f(9#)$".translate({33:" (and|&) ",35:"|10|ten)",39:"fast",37:"furious"}),a) import re 

Try it online!

A very naive attempt at this.

\$\endgroup\$
3
  • \$\begingroup\$ This is super! It doesn't match 'F10', which I've now added into the truthy values section as it's a special case without whitespace. \$\endgroup\$ Commented May 1, 2021 at 20:00
  • \$\begingroup\$ @lowercasename it matches f10 since i assume lowercase; is that alright or should i special case capital F here? \$\endgroup\$ Commented May 1, 2021 at 20:02
  • \$\begingroup\$ Oh, my mistake! You're completely fine! \$\endgroup\$ Commented May 1, 2021 at 20:09

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.