32
6
Objective
From Wikipedia :
A recursive acronym is an acronym that refers to itself in the expression for which it stands.
Your goal is to check if a string is a recursive acronym.
- The acronym is the first word
- Words are not case sensitive, separated with a single space.
- The given string does not contain any punctuation nor apostrophe.
- Only the first letter of each word can be part of the acronym.
You must also give the function words. For simplicity, every word can be considered as a function word.
Example
f("RPM Package Manager") => { true, [] }
f("Wine is not an emulator") => { true, ["an"] }
f("GNU is not Unix") => { true, ["is"] }
f("Golf is not an acronym") => { false }
f("X is a valid acronym") => { true, ["is","a","valid","acronym"] }
You can give a full program or a function.
The input string can be taken from STDIN or as a function argument.
Output result can be true/false, 0/1, yes/no...
The function words list (any format of list is valid) must be given if and only if this is a recursive acronym (even if the list is empty). You do not have to preserve capitalization of the function words.
Winning criteria
This is a code-golf, shortest code wins.
4Do we have to preserve capitalization of the function words? – algorithmshark – 2014-05-26T14:07:20.407
1Is it acceptable to have a list of strings accompanying a False value, or no? – undergroundmonorail – 2014-05-26T14:24:33.573
Nevermind, found the place where you said it wasn't. :P – undergroundmonorail – 2014-05-26T14:35:34.450
1Since the word list itself encodes the boolean value by its presence, may we omit the boolean? – John Dvorak – 2014-05-26T14:56:23.350
1@JanDvorak, no, you have to specify the boolean. – Michael M. – 2014-05-26T15:29:33.603
1@algorithmshark, no, I've edited the question. – Michael M. – 2014-05-26T15:31:04.317
5Hurd stands for Hird of Unix-Replacing Daemons. Hird stands for Hurd of Interfaces Representing Depth. Why the examples here don't understand that, and claim those aren't recursive acronyms? – Konrad Borowski – 2014-05-26T17:33:01.793
3@xfix, wikipedia states that those are mutually recursive acronyms. – Michael M. – 2014-05-26T18:05:37.870
The answer you want cannot tell whether the string is a recursive acronym. It may tell whether the string may be a recursive acronym. For example, with the input string "FBI buried intelligence", the answer would tell that FBI is a recursive acronym. But FBI is neither recursive nor an acronym. – Nicolas Barbulesco – 2014-05-30T13:30:13.117
RPM is not an acronym. – Nicolas Barbulesco – 2014-05-30T13:30:46.897