I before E except after C: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: use unix_dict() and make it p2js compatible)
Line 2,705: Line 2,705:
The plausibility of 'E before I when preceded by C' is False
The plausibility of 'E before I when preceded by C' is False
The plausibility of the phrase 'I before E except after C' is False
The plausibility of the phrase 'I before E except after C' is False
</pre>
==={{header|Alternative Implementation 2}}===
A single pass through the wordlist using the regex engine.
<lang Powershell>$webResult = Invoke-WebRequest -Uri http://wiki.puzzlers.org/pub/wordlists/unixdict.txt -UseBasicParsing

$cie, $cei, $_ie, $_ei = 0, 0, 0, 0

[regex]::Matches($webResult.Content, '.(ie|ei)').foreach{
if ($_.Value -eq 'cie') { $cie+=2 }
elseif ($_.Value -eq 'cei') { $cei++ }
elseif ($_.Value[1] -eq 'i' ) { $_ie++ }
else { $_ei+=2 }
}

"I before E when not preceded by C is plausible: $($_ie -gt $_ei)"
"E before I when preceded by C is plausible: $($cei -gt $cie)"
"I before E, except after C is plausible: $(($_ie -gt $_ei) -and ($cei -gt $cie))"</lang>
{{out}}
<pre>
I before E when not preceded by C is plausible: True
E before I when preceded by C is plausible: False
I before E, except after C is plausible: False
</pre>
</pre>