|
|
|
|
|
by llmzero
839 days ago
|
|
Just for fun, a solution in language j to the problem of selecting the longest word with less than 3 vowels. solution =: >@:{.@:(\: #&>)@:(((+/@:(e.&'aeiou') <: 2:) # ])&.>)@:;: Example solution 'yes, today you are reading something that is not so easy to grasp' the result is: today Ruby : frase.split.select{|x| x.count("aeiou")<3}.sort_by(&:length).last
=> "today" Edited: Added a comparison with Ruby. It seems Ruby here is easier to read and to compose. |
|
The enumerable module of Ruby provides many methods that can be easily implemented in J. Just to show one of them
For example the list.max_by(&:length) is (# max_by)