Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Anagrams/Julia/anagrams.julia
Normal file
16
Task/Anagrams/Julia/anagrams.julia
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
url = "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"
|
||||
wordlist = open(readlines, download(url))
|
||||
|
||||
wsort(word::AbstractString) = join(sort(collect(word)))
|
||||
|
||||
function anagram(wordlist::Vector{<:AbstractString})
|
||||
dict = Dict{String, Set{String}}()
|
||||
for word in wordlist
|
||||
sorted = wsort(word)
|
||||
push!(get!(dict, sorted, Set{String}()), word)
|
||||
end
|
||||
wcnt = maximum(length, values(dict))
|
||||
return collect(Iterators.filter((y) -> length(y) == wcnt, values(dict)))
|
||||
end
|
||||
|
||||
println.(anagram(wordlist))
|
||||
Loading…
Add table
Add a link
Reference in a new issue