Find words which contains more than 3 e vowels: Difference between revisions
Content added Content deleted
(→{{header|jq}}: regex-free solution) |
|||
Line 698: | Line 698: | ||
{{works with|jq}} |
{{works with|jq}} |
||
'''Works with gojq, the Go implementation of jq''' |
'''Works with gojq, the Go implementation of jq''' |
||
===Using regular expressions=== |
|||
<lang jq>inputs |
<lang jq>inputs |
||
| select(test("[aiou]")|not) |
| select(test("[aiou]")|not) |
||
| select(test("e.*e.*e.*e"))</lang> |
| select(test("e.*e.*e.*e"))</lang> |
||
===Regex-free solution=== |
|||
<lang jq>def count(s): reduce s as $x (null; .+1); |
|||
("aiou" | explode) as $disallow |
|||
| inputs |
|||
| . as $word |
|||
| explode |
|||
| select( all(.[]; . != $disallow[]) and |
|||
count(.[] | select(. == 101)) > 3) # "e" is 101 |
|||
| $word |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
Invocation example: jq -nrR program.jq unixdict.txt |
Invocation example: jq -nrR program.jq unixdict.txt |