Detect Anagrams

"""
    detect_anagrams(subject, candidates)
A function that checks if a list of words
is an [Anagram](https://en.wikipedia.org/wiki/Anagram) or not of a subject word.

is the original word = subject
is list of words to be compared if they are an anagram of `subject` = candidates

```
julia> subject = "listen"
julia> candidates = ["inlets", "enlists", "google", "banana"]
julia> detect_anagrams(subject, candidates)
1-element Vector{String}:
 "inlets"
```

Contributed By:- [Soc V. E.](https://github.com/ReneganRonin)
Based on my exercism's Julia track problem solution on [Anagrams](https://exercism.io/my/solutions/0a1d39faa5694624b7750be3ebf6c974).

Instructions:

An anagram is a rearrangement of letters to form a new word. Given a word and a list of candidates, select the sublist of anagrams of the given word.
Given "listen" and a list of candidates like "enlists" "google" "inlets" "banana" the program should return a list containing "inlets".

Inspired by the [Extreme Startup game](https://github.com/rchatley/extreme_startup)
"""
function detect_anagrams(subject, candidates)
    function condition(i)
        return sort(collect(lowercase(subject))) == sort(collect(lowercase(i)))
    end
    collection = collect(
        word for word in candidates if lowercase(word) != lowercase(subject)
    )
    return filter(condition, collection)
end
Algerlogo

Β© Alger 2022

About us

We are a group of programmers helping each other build new things, whether it be writing complex encryption programs, or simple ciphers. Our goal is to work together to document and model beautiful, helpful and interesting algorithms using code. We are an open-source community - anyone can contribute. We check each other's work, communicate and collaborate to solve problems. We strive to be welcoming, respectful, yet make sure that our code follows the latest programming guidelines.