RosettaCodeData/Task/I-before-E-except-after-C/PowerShell/i-before-e-except-after-c-2.psh

30 lines
826 B
Text
Raw Permalink Normal View History

2014-04-02 16:56:35 +00:00
$Web = New-Object -TypeName Net.Webclient
2019-09-12 10:33:56 -07:00
$Words = $web.DownloadString('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt')
2014-04-02 16:56:35 +00:00
$IE = $EI = $CIE = $CEI = @()
$Clause1 = $Clause2 = $MainClause = $false
foreach ($Word in $Words.split())
{
switch ($Word)
{
2017-09-23 10:01:46 +02:00
{$_ -like '*cei*'} {$CEI += $Word; break}
{$_ -like '*cie*'} {$CIE += $Word; break}
{$_ -like '*ie*'} {$IE += $Word}
{$_ -like '*ei*'} {$EI += $Word}
2014-04-02 16:56:35 +00:00
}
}
if ($IE.count -gt $EI.count * 2)
{$Clause1 = $true}
"The plausibility of 'I before E when not preceded by C' is $Clause1"
2015-11-18 06:14:39 +00:00
if ($CEI.count -gt $CIE.count * 2)
2014-04-02 16:56:35 +00:00
{$Clause2 = $true}
2015-11-18 06:14:39 +00:00
"The plausibility of 'E before I when preceded by C' is $Clause2"
2014-04-02 16:56:35 +00:00
if ($Clause1 -and $Clause2)
{$MainClause = $True}
"The plausibility of the phrase 'I before E except after C' is $MainClause"