# The ten hundred most common words

This question is written because "Thing Explainer" is fun to read, and gave me an idea.

Write "stuff that makes computer do things" that reads/takes a set of letters, numbers and things like this "#%|? and returns True / 1 if all words are part of this set.

If all words are not part of that set, return the words that were not a part of it.

This website can be considered correct in all cases. The rules are written to follow the specs on that site.

# Examples:

Truthy:

The code should return a truthy value if the entire text above the first horizontal line is pasted as input.

The following lines should return a truthy value (input is separated by ###)

This returns "Hello, World!"
###
tHiS rEtUrNs TrUe...
###
Thing Explainer is a book written by a man.
The man writes books with simple words.
###
This set of stuff "#!^{>7( must return true


Falsey:

In the following examples, input and output are separated by ***. Different test cases are separated by ###.

This code doesn't return "Hello, World!"
***
code
###
tHiS rEtUrN"s false...
***
s
false


More detailed rules:

• You can use this to test your code.
• Non-letters are interpreted as spaces by the code, except for words like 'wasn't'. The words with apostrophes that returns true are included in the list
• For instance: foo123bar should return foo and bar, since they are not part of the list, and 123 can be interpreted as spaces
• The input will only contain printable ASCII code points [10, 32-126].
• Words can contain mixed case letters. See second test case.
• The list of words
• should be taken as input (STDIN, function argument or equivalent)
• can be modified (words can be separated by newline, comma etc., and you might sort the list)
• Note that you can not use this list (it's not identical)
• The output can be on any format you like
• The output can be upper, lower or mixed case (optional)
• There shall be no symbols in the output

For the record, Jonathan Allan found a strange corner case: the implementation on XKCD will actually ignore any letters after an apostrophe up to the next non-[A-Z][a-z]['] - for example find's found, and find'qazxswedc found' both return nothing, whereas find'qazx.swedc found returns swedc.

You can choose if you want to return nothing for find'qazxswedc found', or return qazxswedc. Returning qazx, swedc for find'qazx.swedc is also OK.

• Extremely Related – DJMcMayhem Sep 13 '16 at 19:15
• I'm not positive it's a dupe though. Your challenge is slightly different, since you need to return the non-simple words. And, in your favor, you actually have a normal spec written in everyday English. codegolf.stackexchange.com/questions/53323/… – DJMcMayhem Sep 13 '16 at 19:27
• For a statically typed language that cannot express a return type of Boolean or Array<String>, would returning an empty array/list be permissible? – CAD97 Sep 13 '16 at 21:05
• @CAD97 for the case where all words are simple? You can select how you want to display the truthy value, it can be an integer/string 1. An empty output is not permissible. – Stewie Griffin Sep 13 '16 at 21:22
• I'm confused by the new explanation of rules for the find'qazxswedc input. Are we or are we not supposed to split on apostrophes? For example, isn't returns true (it's in the list), but isn returns isn, since that's not on the list. From that logic, I went with "don't split on apostrophes" and so find'qazxswedc found returns find'qazxswedc. – AdmBorkBork Sep 14 '16 at 12:36

## PowerShell v3+, 105 92 bytes

param($a,$b)$x=@();-split($b-replace"[^a-zA-Z']",' ')|%{if($_-notin$a){$x+=$_}};($x,1)[!$x]


Takes simple words like $a, and words like $b. Makes helper $x. Take each word in $b and get rid of any bad not letters, then check each one |{...}. If that word is not in $a, then we add it to $x. At the end, we choose $x or 1 by not $x. That is sent out, either words or 1.

### Some words to try

PS C:\Tools\Scripts\golfing> ('This returns "Hello, World!"','tHiS rEtUrNs TrUe...','Thing Explainer is a book written by a man.
The man writes books with simple words.','This set of stuff "¤!^¤>7\ must return true'|%{"$_";(.\ten-hundred-most-common-words.ps1 (gc .\ten-hundred-most-common-words.txt)$_)})-join"n###n"
This returns "Hello, World!"
###
1
###
tHiS rEtUrNs TrUe...
###
1
###
Thing Explainer is a book written by a man.
The man writes books with simple words.
###
1
###
This set of stuff "¤!^¤>7\ must return true
###
1

PS C:\Tools\Scripts\golfing> ("This code doesn't returns Hello, World!",'tHiS rEtUrN"s false...'|%{"$_n***n"+(.\ten-hundred-most-common-words.ps1 (gc .\ten-hundred-most-common-words.txt)$_)})-join"n###n"
This code doesn't returns Hello, World!
***
code
###
tHiS rEtUrN"s false...
***
s false


# Python, 93 bytes

import re
lambda w,s:[w for w in re.sub("[^'\w]|\d|_",' ',w).split()if w.lower()not in s]or 1


All test cases are at ideone

Preprocessing of the list is to split on | and put it in a set (which I imagine is fine if pre-sorting is allowed). Input words as w and the set as s.

If that's not allowed this becomes 98 bytes with not in s becoming not in set(s).

We could preprocess it to have all permutations of upper and lower case characters too and save 8 bytes, but I think that might be going too far (that would be a huge set).