RosettaCodeData/Task/I-before-E-except-after-C/Icon/i-before-e-except-after-c-1.icon
Ingy döt Net 776bba907c Sync
2013-10-27 22:24:23 +00:00

19 lines
678 B
Text

import Utils # To get the FindFirst class
procedure main(a)
showCounts := "--showcounts" == !a
totals := table(0)
phrases := ["cei","cie","ei","ie"] # Longer phrases first
ff := FindFirst(phrases)
every map(!&input) ?
while totals[2(tab(ff.locate()), ff.moveMatch(), move(-1))] +:= 1
eiP := totals["cei"] > 2* totals["cie"]
ieP := (totals["ie"]+totals["cei"]) > 2* totals["ei"]
write("phrase is ",((\ieP & \eiP),"plausible")|"not plausible")
write("ie is ",(\ieP,"plausible")|"not plausible")
write("ei is ",(\eiP,"plausible")|"not plausible")
if \showCounts then every write(phrase := !phrases,": ",totals[phrase])
end