| Bytes | Lang | Time | Link |
|---|---|---|---|
| 084 | Tcl | 181222T092330Z | david |
| 017 | Raku Perl 6 rakudo | 241213T164017Z | xrs |
| 034 | AWK | 241112T190309Z | xrs |
| 033 | ARBLE | 240902T055508Z | ATaco |
| 007 | UiuaSBCS | 240829T060733Z | Europe20 |
| 026 | Zsh | 240817T113257Z | roblogic |
| 003 | Japt h | 171220T140948Z | Shaggy |
| 006 | Uiua | 231117T222201Z | chunes |
| 033 | Noulith | 231118T012553Z | bigyihsu |
| 002 | Thunno 2 | 230616T171318Z | The Thon |
| 007 | Factor | 221013T030326Z | chunes |
| 002 | Vyxal | 221013T025125Z | DialFros |
| 7064 | Lua | 181222T084835Z | cyclamin |
| 021 | Kotlin | 181221T195319Z | snail_ |
| 015 | jq r | 181221T192012Z | user4180 |
| 071 | sed 4.2.2 rz | 180108T183342Z | user4180 |
| 004 | Pyth | 171220T135126Z | Mr. Xcod |
| 009 | Attache | 180325T143104Z | Conor O& |
| 063 | C++ gcc | 180324T081151Z | Karl Nap |
| 036 | dc | 171220T162015Z | cab404 |
| 044 | Bash | 171221T033421Z | user1775 |
| 007 | Add++ | 180307T214833Z | caird co |
| 031 | R + pryr | 171220T103847Z | NofP |
| 016 | APL | 171221T054008Z | rmoro |
| 057 | SNOBOL4 CSNOBOL4 | 171221T164256Z | Giuseppe |
| 013 | Coconut | 180210T125120Z | ovs |
| 024 | Perl | 180211T222433Z | Ton Hosp |
| 020 | V | 171223T115304Z | oktupol |
| 069 | Prolog SWI | 171220T113224Z | Emigna |
| 024 | APL NARS | 180108T105824Z | user5898 |
| 3642 | EXCEL | 171220T113031Z | pbeentje |
| 041 | Javascript ES5 | 171221T173102Z | Jack |
| 069 | PHP | 171223T031329Z | Krzysiu |
| 040 | Google Sheets | 180102T192707Z | Taylor R |
| 059 | PHP | 180102T105048Z | Titus |
| 168 | Imperative Tampio | 171220T112747Z | fergusq |
| 020 | Ruby | 171222T084616Z | G B |
| 003 | 05AB1E | 171227T185432Z | Emigna |
| 035 | Haskell | 171220T104448Z | totallyh |
| 023 | Python | 171220T102025Z | Neil |
| 004 | Jelly | 171224T033857Z | user2027 |
| 022 | Scratch 2.0 | 171224T051153Z | Mustache |
| 003 | Husk | 171223T224011Z | ბიმო |
| 032 | Common Lisp | 171223T191515Z | Renzo |
| 008 | J | 171220T115143Z | Galen Iv |
| 019 | Stacked | 171222T232525Z | Conor O& |
| 029 | F# .NET Core | 171222T162225Z | Aaron M. |
| 030 | Röda | 171220T113629Z | fergusq |
| 160 | Scratch | 171222T025158Z | fede s. |
| 125 | C++ | 171221T151744Z | Toby Spe |
| 045 | Bash | 171221T150518Z | nxnev |
| 110 | Racket | 171220T155024Z | Daniel L |
| 038 | JavaScript Node.js | 171220T102652Z | LiefdeWe |
| 5770 | Java 8 | 171221T065434Z | Christop |
| 038 | Funky | 171220T225532Z | ATaco |
| 024 | MY | 171220T222312Z | Adalynn |
| 072 | PHP | 171220T214921Z | Alan Ond |
| 073 | Rust | 171220T204848Z | Håv |
| 038 | Perl 5 | 171220T202111Z | Xcali |
| 024 | Julia 0.6 | 171220T194214Z | LukeS |
| 011 | APL+WIN | 171220T191752Z | Graham |
| 029 | Mathematica | 171220T190340Z | LegionMa |
| 033 | Octave | 171220T145800Z | Luis Men |
| nan | 171220T180213Z | Brad Gil | |
| 067 | Java OpenJDK 8 | 171220T150904Z | Lucy Ste |
| 055 | Standard ML MLton | 171220T144513Z | Laikoni |
| 009 | K oK | 171220T111656Z | mkst |
| 024 | PowerShell | 171220T134414Z | AdmBorkB |
| 009 | APL Dyalog Unicode | 171220T124246Z | Adá |
| nan | C# | 171220T102105Z | LiefdeWe |
| 054 | Swift | 171220T105606Z | Endenite |
Tcl, 93 84 bytes
Second proc lost its return thx to @sergiol
proc c a\ b {expr [string le $a]<[string le $b]}
proc L l {lindex [lsort -c c $l] 0}
Quite disappointed by the score, should/could be better. Thought about this one-proc version:
proc L l {
set m [lmap e $l {regsub -all . $e 1}]
return [lindex $l [lsearch $m [expr max([join $m ,])]]]
}
but it's longer. See also @sergiol 2nd comment to another single-proc version.
Raku (Perl 6) (rakudo), 17 bytes
{@_.max: *.chars}
{@_. # split list
max: # find the max of each
*.chars} # based on num of chars
AWK, -F '' -vRS=" " 34 bytes
{NF-1>length(x)&&x=$0}END{print x}
To test:
awk -F "" -vRS=" " '{NF-1>length(x)&&x=$0}END{print x}' <<< "tiny small bigger biggest"
{NF-1> # length of current word
length(x) # length of longest
&&x=$0} # set longest
END{print x} # print when done
ARBLE, 33 bytes
a/select(1+lt(len(b),len(c)),b,c)
a/select(1+lt(len(b),len(c)),b,c)
a/ -- Fold the first input over the given function
select(1+ ,b,c) -- If the condition is 1, return the second argument. Otherwise, return the first.
lt(len(b),len(c)) -- Is the length of the first argument less than the length of the second
Actually surprised how hard this was for ARBLE, as it doesn't have a maxby or sort function.
UiuaSBCS, 9 7 bytes
⊏⊢⍖≡◇⧻.
Both the input and output is □ boxed. Does not work on empty arrays.
Explanation
Code | Desc | Stack
⊏⊢⍖≡◇⧻. | | {"tiny" "small" "bigger" "biggest"}
≡◇⧻. | array of lengths | {"tiny" "small" "bigger" "biggest"} [4 5 6 7]
⍖ | index of descending sort | {"tiny" "small" "bigger" "biggest"} [3 2 1 0]
⊢ | first element | {"tiny" "small" "bigger" "biggest"}
⊏ | select that index | ⌜biggest⌟
Zsh, 28 26 bytes
for i;<<<$i>$i;ls -S|sed q
Write each argument (<<<$i) to a file also named (>$i). List directory (ls -S) sorted by size. Take the top result.
A direct port of the bash solution is 29 bytes:
for b;(($#b>$#a))&&a=$b;<<<$a
Japt -h, 5 3 bytes
ÔñÊ
Reverse, sort by length and output the last element.
Alternatively ...
Japt -g, 3 bytes
üÊÌ
Sort & group by length, get the last element and output the first element.
Noulith, 33 bytes
\l->l find\w->w.len==max(l map len)
Explanation
\l-> # lambda, taking in a list of strings
l find # find in `l`...
\w-> # some word `w` such that...
w.len # the length of `w`...
== # is equal to...
max(l map len) # the longest `w` in `l`
Lua, 70 64 bytes
function f(a,...)x=...and f(...)return x and#x>#a and x or a end
x is set to the second argument if that is falsy, otherwise the longest of the second argument and up. The function returns x if it is truthy and longer than the first argument, else the first argument.
No type-checking, so works not only for a sequence of strings, but for sequences containing tables, or anything with a __len metamethod that returns a number. For instance f("tiny", {1, 2, 3, 4, 5}, debug.setmetatable(6, { __len = function (self) return self end })) returns 6.
This technically breaks the rule of operating on an array (in Lua, a table) because it operates on an argument list, but operating on a table seemed more complicated (table.sort is not stable). A table can be unpacked into the function: f(table.unpack { 'oh', 'one', 'two' }).
jq -r, 19 15 bytes
Golfed 4 bytes after learning min_by is a builtin.
min_by(-length)
(Without -r the output string is surrounded with "s.)
sed 4.2.2 -rz, 71 72 83 bytes
h
:
s/^.//gm
/[^\n]{2}/t
:b
/^\n/{s/.//
x
s/^[^\n]*.//
x}
tb
x
s/\n.*//
-ruses extended regular expressions, in other words, allows golifer syntax as we are able to save several\s-zputs all lines of input into one "line", so that they would be processed at the same time rather than the normal cyclic processing.
This was a fun challenge seeing as sed did not have any builtin sort functions. The program works as follows:
- copy the pattern space into the hold space
- find the position of the longest line by repeatedly removing the first character from every line until we are remaining with line(s) with only a single character, this first of these is at the position of the longest line
to find which line this position corresponds to, we repeatedly
- remove the first line of the pattern space and hold space until we encounter a non-newline character on the first line of the pattern space
- now that the corresponding line is at the top of the hold space, we remove the other lines
- the contents of the buffer is printed at the end of the program
Pyth, 4 bytes
h.Ml
Explanation
h.Ml | Program
h.MlZQ | With implicit variables filled in
-------+--------------------------------------------------------------------
h | First element of
.M Q | The list of elements from the input list with the maximal value for
lZ | The length of the element
Attache, 9 bytes
MaxBy&:`#
This is simply bonding the size operator (`#) to the left of MaxBy. This is equivalent to:
f[x] := MaxBy[Size, x]
...which selects the first element with the largest size in x.
C++ (gcc), 65 63 bytes
Accepts any container of std::string and returns via reference.
[](auto&c,auto&r){r=c[0];for(auto x:c)r=x.size()>r.size()?x:r;}
If you are tolerant to output, there is a 58 byte solution which alters the input list and copies the longest string to the first element:
[](auto&c){for(auto x:c)c[0]=x.size()>c[0].size()?x:c[0];}
dc, 39 38 36 bytes
0sl[slssdd]sG[dZdll!>Gooz0<M]dsMxlsp
Edit: -1 byte, filling up empty space by 'd' instead
Edit: -2 bytes, thanks @brhfl for suggestion!
Add++, 7 bytes
L,bU«bL
More interesting, 32 byte version:
L,vbU§bLdbLBkÞ{g}@
D,g,@,bLBK=
How they work
L, ; Create a lambda function
; Example argument: [["two" "one" "abc" "no"]]
bU ; Evaluate as list; STACK = ['two' 'one' 'abc' 'no']
«bL ; Take the value with the max length; STACK = ['two']
And the 32 byte version:
L, ; Create a lambda function
; Example argument: ['["two" "one" "no"]']
vbU ; Evaluate; STACK = ['two' 'one' 'no']
§bL ; Sort by length; STACK = ['no' 'two' 'one']
dbLBk ; Save length; STACK = ['no' 'two' 'one'] REGISTER = 3
Þ{g} ; Filter by 'g'; STACK = ['two' 'one']
@ ; Reverse; STACK = ['one' 'two']
; Implicitly return the top element: 'two'
D,g,@, ; Create a function 'g'
; Example argument: ['two']
bL ; Length; STACK = [3]
BK= ; Equal to register; STACK = [1]
R + pryr, 31 bytes
[-2 bytes thanks to Scrooble]
pryr::f(x[order(-nchar(x))][1])
R, 33 bytes
function(x)x[order(-nchar(x))][1]
APL -- 23 16 bytes
a←{((⍴¨⍵)⍳(⌈/(⍴¨⍵)))⌷⍵}
Thanks to everyone for all of your great suggestions and encouragement!
a←{⍵⌷⍨(⍴¨⍵)⍳⌈/⍴¨⍵}
Usage:
a 'duck' 'duck' 'goose'
'goose'
Explanation:
gets length of each vector of characters (string) then uses maximum as an index. I just started APL 20 min ago so I am sorry if this is a stupid way to do it.
(edited for clarity)
SNOBOL4 (CSNOBOL4), 63 57 bytes
I M =LT(SIZE(M),SIZE(X)) X
X =INPUT :S(I)
OUTPUT =M
END
Input is on stdin and output on stdout.
Roughly translates to the following pseudocode:
while input exists
x = input
if length(m) < length(x)
m = x
end
return m
Perl, 24 bytes
Includes +1 for p
Give words as lines on STDIN
perl -pe '$;[y///c]//=$_}{$_=pop@'
one
two
no
^D
V, 27 23 21 20 bytes
Í./_
ÚGYu/"
uYHVGp
Explanation:
Í./_ In every line, replace every character by _
Ú Sort alphabetically. Cursor ends up in first line
GY Go to last line, copy it
u Undo sort
/" Search for string in register " (the one that was just copied). Non-printable character is <C-r>
u Undo replace, go to last cursor position. Non-printable character is <C-o> (thanks, Cows quack)
Y Copy line
HVG Go to first line, select all lines until last line
p Paste copied line into selection
Hexdump:
00000000: cd2e 2f5f 0ada 4759 752f 1222 0a75 0f59 ../_..GYu/.".u.Y
00000010: 4856 4770 HVGp
Prolog (SWI), 98 92 72 69 bytes
The top level predicate is *.
X/Y:-atom_length(X,Y).
[A]*A.
[A,B|L]*Z:-A/X,B/Y,Y>X,[B|L]*Z;[A|L]*Z.
Explanation
The first row defines the dyadic predicate / to be a short for atom_length/2which is true if the first argument's length is the second argument. This saves us 3 bytes over using atom_length twice.
Our main predicate is defined as the dyadic * where the first argument is a list and the second argument the longest element of that list.
The second row is our base case which states that the longest element of a one element list is that element.
The third row states that for a list with at least 2 elements, the longest element is:
If the length of the second element is longer than the first element, the longest element is in the list without the first element.
Otherwise the longest element is in the list without the second element.
APL NARS, 10 chars, 24 bytes
{⍵[↑⍒⍴¨⍵]}
note in the test, that: 'uno' it is not one array of array, so the array of correct deep is ,⊂'uno' instead
⎕fmt ,⊂'uno'
┌1─────┐
│┌3───┐│
││ uno││
│└────┘2
└∊─────┘
so in the test g fail for 'uno'
g←{⍵[↑⍒⍴¨⍵]}
g 'uno'
u
but not fail for the correct type of input
g ,⊂'uno'
uno
g 'uno' 'quattro' 'cinque'
quattro
⎕fmt g ,⊂''
┌───┐
│┌0┐│
││ ││
│└¯┘2
└∊──┘
if the community think this is one too much big limitation: than there is the 18 chars solution
{1=≡⍵:⍵⋄∊⍵[↑⍒⍴¨⍵]}
that evade the problem in the first test calculate the deep of input
f←{1=≡⍵:⍵⋄∊⍵[↑⍒⍴¨⍵]}
f 'uno'
uno
f 'uno' 'quattro' 'cinque'
quattro
The problem of the input type of one Char in Apl as 'a' (it is consider from interpreter one char). We can transform that in one array of array of char, or one type list of arrays of deep 2 write ,⊂,'a'; so g ,⊂,'a' should return the correct answer of type array of array length 1
EXCEL, 36 42 bytes
=INDEX(A:A,MATCH(MAX(LEN(A:A)),LEN(A:A),))
Entered as an array formula (ctrl-shift-enter). The input array should be entered in column A.
The formula returns the first match with maximum length.
Depending on your region settings, substitute , with ;; the code length remains unchanged.
Of the 16 languages listed here, English function names are the shortest for this formula.
Explanation:
= - return
INDEX( ) - the item of
A:A - the input
, - at
MATCH( ) - the position of
, - the first exact match of
MAX( ) - the maximum of
LEN( ) - the array of lengths of
A:A - the input
, - in
LEN( ) - the array of lengths of
A:A - the input
Javascript ES5, 41 bytes
Since there was already a solution using sort...
a=>a.reduce((x,y)=>x.length>=y.length?x:y)
PHP, 69 bytes
usort($x,function($a,$b){return strlen($b)<=>strlen($a);});echo$x[0];
Not a trick or nice golfing, just sorting array by string length and then outputting the first element.
Google Sheets, 40 Bytes
Anonymous worksheet function that takes input from range A:A and outputs to the calling cell
=Index(A:A,Match(Max(Len(A:A)),Len(A:A),
PHP, 59 bytes
while($n=strlen($s=$argv[++$i]))$n>$e&&$e=$n+!$r=$s;echo$r;
takes words as separate command line arguments. Run with -nr or try it online.
Imperative Tampio, 168 bytes
Listan x on riippuen siitä,onko sen ensimmäisen alkion pituus suurempi tai yhtä suuri kuin sen jokaisen alkion pituus,joko sen ensimmäinen alkio tai sen hännän x.
Ungolfed:
Listan pisin alkio on riippuen siitä, onko sen
ensimmäisenalkion pituus suurempi tai yhtä suuri kuin sen jokaisen alkion pituus, joko
- sen
ensimmäinenalkio tai- sen hännän pisin alkio.
The only golfing opportunity this has is to replace pisin alkio (meaning "the longest element") with x.
Translation:
The longest item in a list is, depending on whether the length of the first item is greater or equal to the length of each element in the list, either
- the first item in the list, or
- the longest item in the tail of the list.
Haskell, 35 bytes
-3 bytes thanks to Zgarb.
foldl1(!)
a!b|(a<$a)<(a<$b)=b|1<2=a
I like this code. You know why? Because Haskell supports much more elegant solutions with functions from random libraries.
maximumBy(compare`on`length).reverse
That's friggin' readable! Except, it's not valid.
import Data.List
import Data.Function
maximumBy(compare`on`length).reverse
If it weren't for the imports, this would've been a perfect submission to get all the upvotes. :P
(Also, this uses one golfing tip and it uses a fold.)
Jelly, 4 bytes
LÐṀḢ
Maximum (ÐṀ) by length (L). Take Head (Ḣ).
Jelly, 4 bytes
ṚLÞṪ
Reverse. Sort by length. Take tail (last element).
Scratch 2.0, 22 blocks
Accepts input by pressing see inside on the project page and manually adding and removing items from list.
Project here. Flash required to run and view, apologies.
All blocks were counted including nested ones. Not sure how I'd count bytes with this language unless you want the length of the JSON.
Husk, 3 bytes
►L↔
Explanation
↔ -- reverse the list (such that the first gets picked in case of a tie)
►L -- find maximum by length
J, 19, 11, 10 8 bytes
0{>\:#@>
Thanks to streetster for the hint!
-1 byte thanks to FrownyFrog!
-2 bytes thanks to Conor O'Brien
How it works:
( #@>) - unbox each string and find its length
\: - sort down the list of strings according to the lengths
0{:: - take and unbox the first string
Stacked, 19 bytes
[:$#'"!:MAX index#]
Explanation
[:$#'"!:MAX index#]
[ ] anonymous function, takes input as list of strings
:$ "! on each member:
#' get the length
index get the index of...
:MAX the maximum length
# and obtain the respective member in the array.
Alternatives
19 bytes: [[#'\#'-]sortby 0#]
24 bytes: [$#'"!:sorted index#_1#]
F# (.NET Core), 29 bytes
Seq.maxBy <| fun s->s.Length
Explanation
Through partial application of Seq.maxBy, returns a function (string seq -> string)
Röda, 30 bytes
{enum|[[#_,-_,_1]]|max|_|tail}
Explanation:
{
enum| /* For each element, push its index to the stream */
[[#_,-_,_1]]| /* For each element and index, push [length, -index, element] */
max| /* Find the greatest element */
_| /* Flat the list in the stream */
tail /* Return the last item in the stream */
}
Alternative 30 bytes:
{enum|[[#_,-_,_1]]|max|[_[2]]}
Scratch 27 17 170 160
It expects a global (attached to all sprites, to be more precise) list of strings called mylist. After clicking the green flag, the longest word will be left in the variable w.
I think this is the link
when gf clicked
set[w]to(item[1]of[mylist
set[i]to[0
repeat(length of[mylist
change[i]by(1
set[m]to(item(i)of[mylist
if<(m)>(w)>then
set[w]to(m
end
end
stop[all
Counting as per this meta.
C++, 125 bytes
Accepts input as a pair of iterators; returns an iterator to the longest string. The array must not be empty (i.e. the iterators must be different).
#include<algorithm>
template<class I>I f(I a,I b){return std::max_element(a,b,[](auto&a,auto&b){return a.size()<b.size();});}
Demo
#include <string>
#include <iostream>
#include <iterator>
int main()
{
std::string strings[] = { "Programming", "Puzzles", "and", "Code", "Golf" };
std::cout << *f(std::begin(strings), std::end(strings)) << std::endl;
}
The definition of std::max_element() guarantees that
If several elements in the range are equivalent to the greatest element, returns the iterator to the first such element.
Racket, 160 bytes 110 bytes
Try it online! First time contributing, advice appreciated!
(define(m a)(if(>(length a)1)(if(>=(string-length(car a))(string-length(m(cdr a))))(car a)(m(cdr a)))(car a)))
Ungolfed
(define (m a)
(if (> (length a) 1)
(if (>= (string-length (car a)) (string-length (m (cdr a))))
(car a)
(m (cdr a))
)
(car a)
)
)
Updated solution based on feedback
Java 8, 57 bytes (70 bytes)
By the power of streams, my java answer shall be the shortest
Arrays.stream(a).max(Comparator.comparing(String::length))
Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.
Thanks to LukeStevens for pointing out to use lambdas to be more golfy.
w->Arrays.stream(w).max(Comparator.comparing(String::length)).get()
Funky, 38 bytes
a=>a[(v=a::map@#)::find(math.max...v)]
Explained
a=>a[(v=a::map@#)::find(math.max...v)]
a::map@# $ Create a list of the lengths of the input's strings.
v= $ And assign it to v.
( )::find( ) $ Find the first index in this list that equals...
math.max...v $ The largest value of v, eg. the length of the longest string.
a[ ] $ Get the value at that position.
MY, 24 bytes
1ω74ǵ'ƒ⇹(ω74ǵ'ƒ⇹(⍐=⍸@ω@←
How?
1ω74ǵ'ƒ⇹(ω74ǵ'ƒ⇹(⍐=⍸@ω@←
← = Output ...
ω = ... the input ...
@ = ... at ...
1 @ = ... the first ...
⍸ = ... truthy index of ...
ω74ǵ'ƒ⇹( = ... the length of each element of the input's ...
= = ... equality with ...
ω74ǵ'ƒ⇹(⍐ = ... the maximum length.
PHP, 72 bytes
array_reduce($a,function($c,$i){return (strlen($i)>strlen($c))?$i:$c;});
Rust, 73 bytes
|mut x:Vec<String>|{x.sort_by(|a,b|b.len().cmp(&a.len()));x[0].clone()}
Very simple code, that can probably be golfed at least a little more. The fact that i had to use String instead of &str, just for the return value, bugs me alot. (I could have used a .to_string() method, but that wouldve added 2 bytes.)
APL+WIN, 11 bytes
s[↑⍒∊⍴¨s←⎕]
Prompts for screen input in the form 'abc' 'defg' hijklm'
Mathematica, 29 bytes
#&@@#~MaximalBy~StringLength&
Pure function. Takes a list of strings as input and returns a string as output. #~MaximalBy~StringLength finds the longest strings in the list and #&@@ selects the first instance.
Octave, 33 bytes
@(x)x{[~,p]=max(cellfun(@nnz,x))}
Input is a cell array of strings.
Explanation
cellfun(@nnz,x) applies the nnz function (number of nonzeros) to each string in the input array x. For ASCII strings, nnz is equivalent to numel (number of elements), but shorter. The result is a numeric array with the string lengths.
Then, [~,]=max(...) gives the index of the first maximum in the array of string lengths. The result is used as a curly-brace index into x to obtain the corresponding string.
Java (OpenJDK 8), 67 bytes
Another submission in my favourite language! (read: the only one I know).
This doesn't work with an empty array, but that's fine.
Golfed
w->{for(String y:w)if(y.length()>w[0].length())w[0]=y;return w[0];}
Ungolfed
for(String y:w) // Loops through all Strings
if(y.length()>w[0].length()) // If the String is longer than the first String
w[0]=y; // Store it as the first string.
return w[0]; // Return the first String.
Standard ML (MLton), 55 bytes
fun&(s::r)=foldl(fn(%,$)=>if size% >size$then%else$)s r
Try it online! Example usage: & ["abc","de","fgh"] yields "abc".
Ungolfed:
fun step (current, longest) =
if size current > size longest
then current
else longest
fun longestString (start :: list) = foldl step start list
| longestString nil = raise Empty
K (oK), 9 bytes
*x@>#:'x:
Example:
*x@>#:'x:("edur";"oot";"taht")
"edur"
Explanation
*x@>#:'x: / solution
x: / store input in variable x
#:' / count (#:) each (')
> / sort descending
x@ / apply indices to x
* / take the first one
Notes:
Undeleted as this is classed as non-trivial, despite being basically 5 steps (would be if written as the function {*x@>#:'x}).
PowerShell, 24 bytes
($args[0]|sort l* -d)[0]
Takes input $args[0], pipes that to Sort-Object based on length in -descending order. Then takes the [0]th one thereof. Since sort is stable, this takes the first element in case of a tie.
APL (Dyalog Unicode), 9 bytesSBCS
⊢⊃⍨∘⊃∘⍒≢¨
⊢ from the argument,
⊃⍨ pick the element with the index which is the
⊃ first of the
⍒ indices in descending order of the
≢¨ lengths of each
