Autogram checker: Difference between revisions

m
fix letter count to skip spaces
(→‎{{header|J}}: marked incorrect)
m (fix letter count to skip spaces)
Line 135:
charcounts = counter(s)
stillneedmention = Dict(p[1] => isletter(p[1]) || p[1] != ' ' && countpunctuation ? p[2] : 0 for p in charcounts)
len = lengthcount(isletter, s)
s = " " * replace(s, r"^\.(?:employs|composed|contains)" => "")
for mention in split(s, r"\s*,|:\s*")
Line 143:
numfromtext == 0 && continue
c = mention[begin+spos:end]
if c == "letters" && numfromtext != len # verify a total letter count
verboseif &&numfromtext println("The!= totallen letter count (should# beverify $len)a istotal incorrect.")letter count
verbose && println("The total letter count (should be 291$len) is incorrect.")
return false
end
continue
end
ch = contains(c, "comma") ? ',' : contains(c, "apostrophe") ? '\'' : contains(c, "hyphen") ? '-' : Char(c[1])
Line 187 ⟶ 190:
Test phrase 4 is a valid autogram.
 
Test phrase 5 is not a valid autogram.
The total letter count (should be 291) is incorrect.
Test phrase 5 is not a valid autogram.
 
Test phrase 6 is a valid autogram.
4,105

edits