Compare four integers, return word based on maximum
Jelly, 2 bytes
Takes input as [d,c,b,a]
. Returns a list of Booleans.
Ṁ=
Try it online!
Ṁ
Maximum
=
equal to (implies the other argument is the original argument; vectorises)
R, 17 bytes
max(a<-scan())==a
Try it online!
Returns a vector of booleans. Since this output has been confirmed, this is preferable over numerical output, as that one is almost twice longer:
R, 33 bytes
sum(2^which(max(a<-scan())==a)/2)
Try it online!
APL (Dyalog Unicode), 4 bytesSBCS
Anonymous tacit prefix function. Takes [a,b,c,d]
as argument. Returns a bit-Boolean array.*
⌈/=⌽
Try it online!
⌈/
Does the maximum of the argument
=
equal (vectorises)
⌽
the reverse of the argument?
* Note that APL stores arrays of Booleans using one bit per value, so this does indeed return a 4-bit word, despite the display form being 0 0 1 0
.