Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
35
Task/Semordnilap/PowerShell/semordnilap.psh
Normal file
35
Task/Semordnilap/PowerShell/semordnilap.psh
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
function Reverse-String ([string]$String)
|
||||
{
|
||||
[char[]]$output = $String.ToCharArray()
|
||||
[Array]::Reverse($output)
|
||||
$output -join ""
|
||||
}
|
||||
|
||||
[string]$url = "http://www.puzzlers.org/pub/wordlists/unixdict.txt"
|
||||
[string]$out = ".\unixdict.txt"
|
||||
|
||||
(New-Object System.Net.WebClient).DownloadFile($url, $out)
|
||||
|
||||
[string[]]$file = Get-Content -Path $out
|
||||
|
||||
[hashtable]$unixDict = @{}
|
||||
[hashtable]$semordnilap = @{}
|
||||
|
||||
foreach ($line in $file)
|
||||
{
|
||||
if ($line.Length -gt 1)
|
||||
{
|
||||
$unixDict.Add($line,"")
|
||||
}
|
||||
|
||||
[string]$reverseLine = Reverse-String $line
|
||||
|
||||
if ($reverseLine -notmatch $line -and $unixDict.ContainsKey($reverseLine))
|
||||
{
|
||||
$semordnilap.Add($line,$reverseLine)
|
||||
}
|
||||
}
|
||||
|
||||
$semordnilap
|
||||
|
||||
"`nSemordnilap count: {0}" -f ($semordnilap.GetEnumerator() | Measure-Object).Count
|
||||
Loading…
Add table
Add a link
Reference in a new issue