+ 6
CHALLENGE : Find the longest word in a sentence.
For example - INPUT :- I am a programmer OUTPUT :- programmer Any language is welcome...
24 Answers
+ 11
JavaScript:
alert(prompt("").split(" ").reduce(function(a, b) { return b.length < a.length ? a : b; }, ""));
+ 9
What happenz if input is "Hello world"?
+ 5
Question: If several words are the same length, which one must be returned? All of them? First one? 🤔
+ 4
My try in Ruby:
https://code.sololearn.com/cqir56AU8zR7/#rb
+ 3
Yes
+ 3
Here is my try:
https://code.sololearn.com/c8Mp71QEJi7s/?ref=app
+ 2
Words are any sequences of any characters right?
+ 2
my practice on python https://code.sololearn.com/ciwnB5loDoBo/#py
tested with: "am i a programmer? subvocalize"
output: subvocalize
+ 2
Is this OK?
https://code.sololearn.com/coiQ6feKx7CJ/?ref=app
+ 1
Find all longest words with filter , ; [ ] : " '
https://code.sololearn.com/WRv4AZ9A7EQQ/?ref=app
+ 1
I returned a list of all the words of the longest length (so if input is "Hello World" it would return ["Hello", "World"].
So, here's my try:
https://code.sololearn.com/cX381CeM75hr/?ref=app
+ 1
java implementation
https://code.sololearn.com/c0nYoK6V7We2/?ref=app
0
I think both words should be outputted then... Or what do u think..??
0
@venkat
can you please tell me how to limit the input for an integer type in python
0
Perl:
print [(sort{length($b)<=>length($a)} split(/\s/,'The longest word will print'))]->[0];
Output: longest
0
https://code.sololearn.com/cqqHHWI9Kh8o/?ref=app
prints longest words in a sentence