Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,13 @@
$c = New-Object Net.WebClient
$words = -split ($c.DownloadString('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'))
$top_anagrams = $words `
| ForEach-Object {
$_ | Add-Member -PassThru NoteProperty Characters `
(-join (([char[]] $_) | Sort-Object))
} `
| Group-Object Characters `
| Group-Object Count `
| Sort-Object Count `
| Select-Object -First 1
$top_anagrams.Group | ForEach-Object { $_.Group -join ', ' }

View file

@ -0,0 +1,43 @@
$Timer = [System.Diagnostics.Stopwatch]::StartNew()
$uri = 'http://wiki.puzzlers.org/pub/wordlists/unixdict.txt'
$words = -split [Net.WebClient]::new().DownloadString($uri)
$anagrams = @{}
$maxAnagramCount = 0
foreach ($w in $words)
{
# Sort the characters in the word into alphabetical order
$chars=[char[]]$w
[array]::sort($chars)
$orderedChars = [string]::Join('', $chars)
# If no anagrams list for these chars, make one
if (-not $anagrams.ContainsKey($orderedChars))
{
$anagrams[$orderedChars] = [Collections.Generic.List[String]]::new()
}
# Add current word as an anagram of these chars,
# in a way which keeps the list available
($list = $anagrams[$orderedChars]).Add($w)
# Keep running score of max number of anagrams seen
if ($list.Count -gt $maxAnagramCount)
{
$maxAnagramCount = $list.Count
}
}
foreach ($entry in $anagrams.GetEnumerator())
{
if ($entry.Value.Count -eq $maxAnagramCount)
{
[string]::join('', $entry.Value)
}
}