[Question]
  [
## Task
You are playing [Hangman](https://en.wikipedia.org/wiki/Hangman_(game)), and your opponent uses a simple but effective strategy: Each turn, from the remaining letters, they guess the letter that appears most frequently across all possible words. When multiple letters appear with the same maximum frequency, your opponent selects randomly among them.
That is, your opponent knows which dictionary (list of words) you've chosen your word from, and has computed a table showing how many times each letter of the alphabet appears in this dictionary. Your opponent always chooses letters with higher frequency counts before letters with lower frequency counts.
Your goal is to write a program that will select a word that maximizes their average number of guesses.
This is code golf.
## Input / Output
The input will be a list of words in any convenient format, per standard site IO rules (comma delimited string, array, lines of a file, etc).
The output will be a single word from that list that maximizes your opponent's average number of guesses. If there is more than one such word, you may return any one of them.
## Worked Example
If the input word list is:
```
one
wont
tee
```
The letter frequency table will be:
```
┌─┬─┬─┬─┬─┐
│e│t│o│n│w│
├─┼─┼─┼─┼─┤
│3│2│2│2│1│
└─┴─┴─┴─┴─┘
```
Your opponent will always guess `e` first, since it occurs most frequently. Their second, third, and fourth guesses will be split randomly among the letters `t`, `o`, and `n`, and `w` will always be guessed last.
Thus the word `wont` will always be completed last, on the 5th guess, and is the sole correct answer for this word list.
## Notes
* Words will contain only the 26 letters `a` through `z`.
* If you want, you can use the uppercase alphabet instead.
* When there is more than one correct answer, you may return any of them. If you want, you can return all of them, but this is not required.
## Test Cases
Each test case consists of two lines:
1. An input word list of space-separated words.
2. The expected output. This will be a single word when there is only one correct answer, and a space-separated list when there is more than one. Note that your program only needs to return one correct answer when there are multiple correct answers.
```
one wont tee
wont
aaa bbb ccc
aaa bbb ccc
oneword
oneword
thee lee
thee
tee lee
tee lee
three eon one holt
three holt
xeon threes eon one holt
threes
xeon threes eon one holt apple mango george any fine
fine
```
  
[Answer]
# [Python 2](https://docs.python.org/2/), 60 bytes
```
lambda l:min(l,key=lambda x:sorted(map(`l`.count,set(x)))+l)
```
[Try it online!](https://tio.run/##hZDRaoUwDIbv8xS5bJkc2C4F32RwTlqjltW21Ir69C6KO3BgYxdN/nz9k5SmrQwxfOxd87l7Gk1L6OvRBeWrL96aC631FHPhVo2U1MM/bjbOoVQTF7Vqrd@83pfBecb3GtCFVGGci8Q7NphpuQuai9K3KXknufoXAqbsQsFOCdAy8hy4x8C4ROGFGQ4BQERojEFr7YsG8S4xt88MZWBGL42HkPKnurLgLJKj7JI1Q/TlQqeE9bg5wfSLafrbgJSSfM1IoY/Yc8w9I4UNOxcYziAPRzJorD0OkAH4Bg "Python 2 – Try It Online")
### Explanation
The idea is much like every other answer. In every word, we compute the frequency of each character. Then we take the word whose least frequent character occurs most often.
In the code, we sort the array as opposed to finding the minimum. Here is an example to show how this works: `Input: thee lee baa`. For each word, we compute a frequency table (duplicates are ignored): `[(1, 1, 4), (1, 4), (1, 2)]`. After sorting, the lexiocgraphically smallest list is `(1, 1, 4)`, therefore the answer is `thee`.
There is also an edge case to consider: `Input: a bc`, which gives the following frequency table: `[(1), (1, 1)]`. The lexicographically smallest list would be `(1)`, which is incorrect since the second list contains more `1`s. I'll leave out the specifics of how the code resolves this issue
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~25~~ ~~16~~ ~~13~~ ~~11~~ ~~13~~ 12 bytes
-3 thanks to @pxeger
-2 thanks to @ovs
+2 for bug fix (for input `acb abc cb` and `aa ab bcc bcc`)
-1 for another bug fix, noticed by @ovs
```
ΣISÐ¢WQÏ¢O}θ
```
[Try it online!](https://tio.run/##yy9OTMpM/f//3GLP4MMTDi0KDzzcf2iRf@25Hf//RyslJiYlJScnK@koKKWkgBixAA "05AB1E – Try It Online")
# Legacy version, 10 bytes, thanks to [@ovs](https://codegolf.stackexchange.com/users/64121/ovs)
```
ΣIS.m¢O(}н
```
[Try it online!](https://tio.run/##MzBNTDJM/f//3GLPYL3cQ4v8NWov7P3/P1qpIjU/T0lHQakkoyg1tRjEggrk56WCqIz8nBIQnVhQkAMWyE3MS88HMdJT84vSwUKJeZUgKi0TqCUWAA "05AB1E (legacy) – Try It Online")
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~35~~ ~~33~~ ~~28~~ ~~27~~ 20 bytes
-2 bytes from shuffling things around
-5 bytes from @Traws' improvement
-1 byte from @bstrat's improvement
-7 bytes from new approach
```
{*>+/'x#=/&/\#'=,/x}
```
[Try it online!](https://ngn.codeberg.page/k#eJyNkG1PwjAQx9/fp7gMI6BA1RdituAXwSVso3sIo51rkS1EP7t37SAhUeOb3sP/f9f2l4enu9d7Me5GK3Er3kbj1Ux0nwA2PN2s+682zBGxizZ6F002eVLVURf1UTuN2bOeBFrJIAqOWlkKVspgOlSxk5MkoX6apnRmWcYqt1ic8exRt1uSzpkfsqXkpbXf5qo48sqVwP1hoHWC1Movo7PUtfXj7cXXeYNrmb/85r8D9J2mqbncJ6rQFAup24IbierpzCvlHutiDCCgtLYxoRCZ3spC1/nC2CTbyS4raYNcZHov3g/S2EorI54elw/LpUjlVn5U9bzXh3bOPrptrpuGXqKsM708A1CFzB6JDHACQLCR6COxv8phIH6JwJiRyLqEynM1RHAMkAAgX8OfH1ouBSaFntMPJvO7AR1AdPjQw0NChwwM+PgGnMPXrg==)
Modeled after [@xash's J answer](https://codegolf.stackexchange.com/a/217079/98547).
* `#'=,/x` build a dictionary mapping characters to the number of times they appear across the entire input
* `=/&/\` identify the least frequent character(s)
* `+/'x#` sum up the number of times the most infrequent characters appear in each word of the input
* `*>` filter the input down to the first word with the most infrequent character(s)
[Answer]
# [Stax](https://github.com/tomtheisen/stax), ~~20 18 10~~ 9 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
·╦Eà3ΩQù»
```
[Run and debug it](https://staxlang.xyz/#p=facb458533ea5197af&i=%5B%22one%22,+%22wont%22,+%22tee%22%5D%0A%5B%22aaa%22,%22bbb%22,%22ccc%22%5D%0A%5B%22oneword%22%5D%0A%5B%22thee%22,%22lee%22%5D%0A%5B%22tee%22,%22lee%22%5D%0A%5B%22three%22,%22eon%22,%22one%22,%22holt%22%5D%0A%5B%22xeon%22,%22threes%22,%22eon%22,%22one%22,%22holt%22%5D%0A%5B%22xeon%22,%22threes%22,%22eon%22,%22one%22,%22holt%22,%22apple%22,%22mango%22,%22george%22,%22any%22,%22fine%22%5D&m=2)
~~Explanation coming next year™.~~ Happy new Year!
-8 bytes from recursive using the surprisingly fitting `multi-anti-mode` builtin.
-1 more byte from recursive with an insane compression hack.
Replacing `H` from [this version](https://staxlang.xyz/#c=%24%7C%21x%7Bn%7C%26%25oH&i=%5B%22one%22,+%22wont%22,+%22tee%22%5D%0A%5B%22aaa%22,%22bbb%22,%22ccc%22%5D%0A%5B%22oneword%22%5D%0A%5B%22thee%22,%22lee%22%5D%0A%5B%22tee%22,%22lee%22%5D%0A%5B%22three%22,%22eon%22,%22one%22,%22holt%22%5D%0A%5B%22xeon%22,%22threes%22,%22eon%22,%22one%22,%22holt%22%5D%0A%5B%22xeon%22,%22threes%22,%22eon%22,%22one%22,%22holt%22,%22apple%22,%22mango%22,%22george%22,%22any%22,%22fine%22%5D&m=2) with `E`(a lower codepoint), results in -1 byte due to packing magic.
## Explanation
```
$|!x{n|&%oE
$           join the input together
 |!         get the rarest characters(anti-mode)
   x        push the input again
    {    o  and order by the following:
     n|&    intersect with the anti-mode 
        %   and take the length
          E push all the elements onto stack
            implicitly print the last element
```
[Answer]
# [J](http://jsoftware.com/), 32 bytes
```
{.@\:(~.(#~<./=])#/.~)@;+/@e."1>
```
[Try it online!](https://tio.run/##jYyxCsIwEEB3vyK0Q1vUVNe0lYDg5OSscGm8JkpNSg1UEfrrMe3i6nDw3r3j7j6iSUMqRhKyIhvCwqwp2Z@OB/@h/MzSkabxWNK8umRxTseMF8ucI422O58tVMVQasuLZqGINQiDNQ4cYlAhBNR1DVLKYGWog@2vAZ1GhHa@cT/SfWC0BqY32rYuLF@Tz@X5bwLRdS3CQxhlQaHtFYIwb2huBv0X "J – Try It Online")
* `;` words razed to letters
* `#/.~` number of occurrences of each letter
* `~.` the letters deduplicated
* `(#~<./=])` take only the most infrequent letters
* `+/@e."1>` how many of these letters occur in each word?
* `{.@\:` sort the words based on the amount and return the first one (the one with most infrequent letters)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 38 bytes
```
ＷＳ⊞υι≔Ｅβ№⪫υωιη≔ＥυＬΦ⌕Ａη⌊Φηλ№ι§βλζ§υ⌕ζ⌈ζ
```
[Try it online!](https://tio.run/##VY5BagMxDEX3PoWXMkxPkNUQKCQ0EOgJ3ESxBR558NjNdC7vSA1ZZCMJvc@TLtGXS/ap93ukhBYOPLf6XQtxAOfsuS0R2mDJ7cy4LBQYTn6Gn8Huc@MKx0ys/O40IyW@BwV9IYca4ZNSxSKNr2NKEAd7IqapTS8im@RU8TTTYMd64Cuuek2Jsk30Z3muwgvKBXXCJkK//gs3ze56XzGzqbEgLkbHzGhiTtX4eU5oJs8hm4C5BDSe/8yNJNA/ftMD "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
ＷＳ⊞υι
```
Input the words.
```
≔Ｅβ№⪫υωιη
```
Get frequencies for all of the letters.
```
≔ＥυＬΦ⌕Ａη⌊Φηλ№ι§βλζ
```
Find the letters with the lowest positive frequencies, then for each word count how many of those letters are contained.
```
§υ⌕ζ⌈ζ
```
Output the word with the highest count.
Previous 84-byte longhand solution:
```
ＷＳ⊞υι≔υθ≔Ｅβ№⪫υωιη≔Ｅυ⁰ζＷ⌈η«≔⌕ＡηιεＦε§≔ηκ⁰ＵＭε§βκ≔ＥθΦκ¬№εμδＵＭζ⁺κ⎇§δλＬεＬΦε№§θλμ≔δθ»§υ⌕ζ⌈ζ
```
[Try it online!](https://tio.run/##XZBNbsMgEIXX4RQsQaJS911ZkSKlaipL7QVoPAEUDDaGxnHVs7uDf5q0GzTMfG/e0xy1DEcv7ThetLFA2d41Kb7FYJxinNMydZolQQ1/IkXXGeXyr739DrJhH4JufXKRPXszzS88K/DRf0EcPWJ3wO5id5C9qVPNNHp9kc3C7oyrCmuZzmsEBeQ3Jx8oA05npIh7V0GfiXNeigAabH1dS1cxEHQFMNuZ5/FdjFbQnbERAkPtq49sTo@qmvMcu/q3bxC0tKnL@DsEJ8OVrfsrQS0qXsCpqDHfb7k4wHqbVdDOgsnpPlg1n/WblHj7G55y1jnCeqthEo5jD96RqANAR3LpHRDtbSSyaSwQTK48UeCDAiLdlZwMAuPDp/0B "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
ＷＳ⊞υι
```
Input the words.
```
≔υθ
```
Make a copy of the list. The letters will be removed from these words as they are guessed.
```
≔Ｅβ№⪫υωιη
```
Get frequencies for all of the letters.
```
≔Ｅυ⁰ζ
```
Start off with 0 guesses for all of the words.
```
Ｗ⌈η«
```
Repeat while there are still letters to guess.
```
≔⌕Ａηιε
```
Find the positions of the most frequent letters.
```
Ｆε§≔ηκ⁰
```
Remove them from the list of frequencies.
```
ＵＭε§βκ
```
Get the letter characters at those positions.
```
≔ＥθΦκ¬№εμδ
```
Make a temporary copy of the words with all of those letters removed.
```
ＵＭζ⁺κ⎇§δλＬεＬΦε№§θλμ
```
For words which still have some letters left, count all of the letters as guesses, otherwise just count the number of matching letters. This is the minimum number of guesses rather than the average but the sort order is the same.
```
≔δθ
```
Update the list of words with the removed letters.
```
»§υ⌕ζ⌈ζ
```
Print the word that took the most guesses.
[Answer]
# [R](https://www.r-project.org/), ~~111~~ 110 bytes
-1 byte thanks to Giuseppe
```
function(s)s[which.max(colSums(outer(names(x<-table(unlist(strsplit(s,""))))[x==min(x)],s,Vectorize(grepl))))]
```
[Try it online!](https://tio.run/##nY4xbsMwDEX3niLQRANuT1CfokCXIIOs0LYAiTREGlZ6eUeSg3avhk/i8ZFQOqbhmDZy6plAOrnui3fLR7QZHIevLQrwppiAbESB/PmudgwIGwUvCqJJ1uBL0xvTlXfNwxA9Qe5uvfTf6JST/0GYE66hCrdjAgeGCU1vFGvuTFqW39rAWlvQOI4lnXMnr/rO6W5eki5tMZTsflFqDJlKnucXDn@Hc5tcTlFq9wLNvfxDLtWua2ggWpq5NjNymhuy9Khl8lR/eTwB "R – Try It Online")
Computes the table of number of occurrences of each letter, then the vector of letter(s) which occur the least often. These rare letters will be tried last (in random order), so we pick the word which maximises the number of distinct rare letters.
If there are several optimal words, this returns the first one. We can return all of them [at a cost of 1 byte](https://tio.run/##nY4xbsMwDEX3nCLQRAPKDepTFOgSZJBV2hEgk4Yow3Iu71Jy0O7V8Ek8PhJKx9gf40o@ByYQu/ee4@c6C/CaMQG5GQXKxy27ISKsFINkkJxkiUEba0yn7176fg4EpXtYsV/oM6fwQpgSLrEKct/VcAX27nGM4MEwobEmY82NKeudSxs45xQNw6DpvT951TdO3@Yt5WdbjJrdL0qNIZPmef7J8e9waZPrKUrt3qC513/IWt2yxAZmRxPXZkJOU0OO9lrGQPWXxw8).
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~60~~ 56 bytes
```
#~MaximalBy~Union/*Map[c=Counts[Join@@#]]/*Count[Min@c]&
```
[Try it online!](https://tio.run/##jY7BaoRAEETvfkWjsAdJ2C/YINlbQAhITuKhp9PqgHbL2GF3CfHXzcwmhxxzaKhXVTQ1o408o3nCvT/txVbj1c84Pd@2N/Eqx7LGpaXTWT/E1vZFvVRV0XXH8u60dWTqDvtr8JGKx6e@Oo8YkIzDGouHqmwsZkOzTN62hlC2zyxXYbioGBhz/pDliAjOOSCihDG@aHhPMs5jmH5a9keOIQKrQHo16mTJvSbjHq3/zgCXZWKYUQaFgTUMDCg36L38TgN04IjS5dnX/g0 "Wolfram Language (Mathematica) – Try It Online")
Input a list of character lists.
[Answer]
# [Ruby 2.7](https://www.ruby-lang.org/), 61 bytes
```
->w{w.min_by{_1.chars.uniq.map{|c|(w*"").count c}.sort<<1e9}}
```
[Try it online!](https://tio.run/##hZDfSsUwDIfvfYpQEFSw4KVw5ouISBqzP7A1O21HHduefa5zPUdB8KKQX76vIcQNZlzLYn18iVPUXWPfzTjNfvaaanReD7Y56w77aab5Lj4oda9JBhuAFu3FhdPpiZ@XZe2hfL2NSixDlA0HZvUGRQEqRXVzcEQEYwwQ0YG3zoVuv6O4j4PklGmomaG9zE3xyn6jn6R2G2OxkHarpQ2HtJfZ@kzCrvq/3G/yrw3Y9y1Dh7YSqFhcxYB2hLKxebW9vF4D0IAhSi/fw6j1Cw "Ruby – Try It Online")
Expects an array of words. Outputs the one with most rarest chars. TIO uses an older version of Ruby, whereas in Ruby 2.7, we've numbered parameters, which saves two bytes.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-m`](https://codegolf.meta.stackexchange.com/a/14339/), 29 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
Ë¬x@¬Ê/U¬èX p
VíU nÏÎ-XgÃÎg1
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LW0&code=CsuseECsyi9VrOhYIHAKVu1VIG7Pzi1YZ8POZzE&input=WwpbIm9uZSIsIndvbnQiLCJ0ZWUiXSwKWyJhYWEiLCJiYmIiLCJjY2MiXSwKWyJvbmV3b3JkIl0sClsidGhlZSIsImxlZSJdLApbInRlZSIsImxlZSJdLApbInRocmVlIiwiZW9uIiwib25lIiwiaG9sdCJdLApbInhlb24iLCJ0aHJlZXMiLCJlb24iLCJvbmUiLCJob2x0Il0sClsieGVvbiIsInRocmVlcyIsImVvbiIsIm9uZSIsImhvbHQiLCJhcHBsZSIsIm1hbmdvIiwiZ2VvcmdlIiwiYW55IiwiZmluZSJdCl0KCgpbd29udCwKYWFhIGJiYiBjY2MsCm9uZXdvcmQsCnRoZWUsCnRlZSBsZWUsCnRocmVlIGhvbHQsCnRocmVlcywKZmluZQpd)
Not a great answer but a bit different approach.
`Ë¬x@¬Ê/U¬èX p` \$\to\$ map each word by summing the weight of each letter.  
* Weight is number of all letters divided by occurrences of letter raised to a power (\$2\$) we can increase the power to get a more precise output at the cost of one byte.
`VíU nÏÎ-XgÃÎg1` \$\to\$ sorts the input based on weights
[Answer]
# [R](https://www.r-project.org/), 100 bytes
```
function(s,S=colSums)s[order(S(t(a<-matrix(sapply(letters,grepl,s),,26))*(b=S(a))!=min(b[b>0])))][1]
```
[Try it online!](https://tio.run/##nZAxbsMwDEX3niLVRAYqkGbIFOcSHg0PlCI7BmTSkBQkOb0ryUG7d/kkHp8IQmEdmnW4s02TMETdNlZ8e58jxk7C1QVoIQGdv2ZKYXpCpGXxL/AuJReiHoNbvI6o9fGEuAfTtECIn808MZjOXA49Ivbdd78OYEEJO6VVciUfwkkhftQBEWVkjMlprd140R/5CvWW0q0@9DnxF4XKnHDObf1N/N/iZ53sNjGW7g2qu/uHnGv5hApm4lFKMzoJY0XEr1KGicuV6w8 "R – Try It Online")
**How?** - ungolfed version:
```
f=function(s){
a<-sapply(letters,grepl,s)  # a = matrix indicating which letters (columns) are present in which words (rows)
a<-matrix(a,,26)            # (force 'a' as a matrix in case there was only one word in the input)
b<-colSums(a)               # b = for each letter, the count of the words that it is in
c<-t(a)*b                   # c = replace 'TRUE' elements of 'a' with the word counts from 'b'
d<-colSums(c==min(b[b>0]))  # d = the number of different letters in each word with the lowest overall nonzero word count
s[which.max(d)]             # output the (first) word that maximises d
}
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 15 bytes
```
.Mms/L.m/sQbsQZ
```
[Try it online!](https://tio.run/##K6gsyfj/X883t1jfRy9XvzgwqTgw6v//aKWK1Pw8JR0FpZKMotTUYhALKpCflwqiMvJzSkB0YkFBDlggNzEvPR/ESE/NL0oHCyXmVYKotEygllgA "Pyth – Try It Online")
]