News for hackers. Stuff that matters.
Re:Array Languages vs. the Curse of the Spreadsheet by antonvs on Wednesday March 06, 2024 @05:20AM (#39614365)
Haskell:

    maximumBy (on compare length) . filter ((< 3) . length . filter (`elem` "aeiou")) $ words phrase
That returns "grasp", though, because it doesn't sort the list.
Re:Array Languages vs. the Curse of the Spreadsheet by antonvs on Wednesday March 06, 2024 @12:13PM (#39618176)
Plus, defining a few aliases for the punctuation-happy terseness-lovers among us, we can reduce the above to:

    maxBy(on cmp (#)).(((<3).(#).(el"aeiou"|=))|=)$words phrase
Re:Array Languages vs. the Curse of the Spreadsheet by leephillips on Wednesday March 06, 2024 @12:50PM (#39618638)
The problem as stated does not have a unique solution in general, as you’ve found. One Julia program for this is

`sort(split(p)[count.(r"[aeiou]", split(p)) .< 3]; by=r -> length(r))[end]`

which also returns "grasp".

But this one appeals to me more, because it doesn’t split twice:

`sort(filter(w -> count(r"[aeiou]", w) < 3, split(p)); by=r -> length(r))[end]`