I'm a lazy but efficient person, as many of you probably are as well. So, whenever I'm doing something I want to do it with minimal effort. Which is why I'm asking you to solve this problem for me.
What I have here is a document of sorts. On every line of this document is a single word or short phrase. The document is not sorted, but that's ok I know where everything is. I could use some help finding things faster, and for that I need a second list. This is where you come in. For every line of text in this document, I need some identifier. Something I can CTRL+F, but it can't be longer than absolutely necessary for getting that one result.
(blank) an apple spiderman 3 7pm pick up laundry tequila fake mustache dishes on wednesday banana biscuits (blank)
I'm going to repeat myself here, to make sure we're on the same page:
- The input is an unformatted text file containing a list of items, separated by line breaks. I have it here in .txt format, it's called "STUFF.TXT"
- The first and last line of the document are empty. Every other line contains an entry of length >0.
- The file contains only alfanumeric characters (all lower case), spaces, and line breaks.
- Desired output is a list of identifiers, in the same order as my original list.
- I don't want more than one search word for every list item. If there are multiple answers, pick one, I don't care which. In the above example I picked 'ap' for
an apple, but you could have picked 'n ', ' a', 'pp', 'pl' or 'le'. Not 'an', because that's in
- I can assure you, the file is never empty, and it never contains duplicates.
- If necessary, you can match on the line terminator. But that's a last resort only to be used when there's no other way to distinguish between list items (e.g. 'apple' and 'apples').
Standard loopholes are not allowed. Also, this is code golf so shortest code wins.
One more example:
(blank) ban any king bean yen rake raki bar (blank)
And its output: