Compare four integers, return word based on maximumSum of indices of second least significant bitImplement...

How would we write a misogynistic character without offending people?

Skis versus snow shoes - when to choose which for travelling the backcountry?

Can you 'upgrade' leather armor to studded leather armor without purchasing the new armor directly?

Reason Why Dimensional Travelling Would be Restricted

If nine coins are tossed, what is the probability that the number of heads is even?

Why does the author believe that the central mass that gas cloud HCN-0.009-0.044 orbits is smaller than our solar system?

What is the difference between throw e and throw new Exception(e)?

What type of postprocessing gives the effect of people standing out

Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?

Which aircraft had such a luxurious-looking navigator's station?

Second-rate spelling

What do the pedals on grand pianos do?

What is the wife of a henpecked husband called?

Why proton concentration is divided by 10⁻⁷?

What's the difference between a cart and a wagon?

CBP Reminds Travelers to Allow 72 Hours for ESTA. Why?

I am on the US no-fly list. What can I do in order to be allowed on flights which go through US airspace?

How to tighten battery clamp?

Is there any relevance to Thor getting his hair cut other than comedic value?

Does music exist in Panem? And if so, what kinds of music?

Are small insurances worth it

What is better: yes / no radio, or simple checkbox?

It took me a lot of time to make this, pls like. (YouTube Comments #1)

Waiting for the gravy at a dinner table



Compare four integers, return word based on maximum


Sum of indices of second least significant bitImplement bit-wise matrix multiplicationExtraction of BitsImplement almost-equals for IEEE numbersBit Manipulator/ReaderMapping between integer and pronounceable wordIs it a strong word?Take one to make oneAlternating bit smearingOutput a binary path from a number













5












$begingroup$


This function should take four integer inputs (a,b,c,d) and return a binary word based on which values equal the maximum of the four.



The return value will be between 1 and 0xF.



For example:



a = 6, b = 77, c = 1, d = 4



returns 2 (binary 0010; only 2nd-least significant bit is set corresponding to b being sole max value)



a = 4, b = 5, c = 10, d = 10



returns 0xC (binary 1100; 3rd- and 4th-least significant bits set corresponding to c and d equaling max value)



a = 1, b = 1, c = 1, d = 1



returns 0xF (binary 1111; all four bits set because all values equal the max)



Here is a simple implementation:



int getWord(int a, int b, int c, int d)
{
int max = a;
int word = 1;
if (b > max)
{
max = b;
word = 2;
}
else if (b == max)
{
word |= 2;
}
if (c > max)
{
max = c;
word = 4;
}
else if (c == max)
{
word |= 4;
}
if (d > max)
{
word = 8;
}
else if (d == max)
{
word |= 8;
}
return word;
}


return value can be string of 0's and 1's, bool / bit vector, or integer










share|improve this question









New contributor




Mr Anderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$








  • 2




    $begingroup$
    I have a solution in a golfing language, which uses the builtins Reverse, Maximum, Equality-check, Join, Convert from binary to integer, Convert from integer to hexadecimal. Does this means my score is 1 due to the Equality-check? I have the feeling this is too much focused on regular languages, and even for those it's not 100% clear what the scoring for let's say a Maximum-builtin.. :S
    $endgroup$
    – Kevin Cruijssen
    17 hours ago








  • 1




    $begingroup$
    I would suggest you try to: 1. change this question to code-golf, which only care about the number of bytes. 2. or, restrict to some certain language (certain version of compiler/interpreter please), and list all statements and operators allowed, and how to score them.
    $endgroup$
    – tsh
    17 hours ago






  • 4




    $begingroup$
    1 is a better option, IMO. I think this makes a perfectly good code-golf question and I can't see any benefit that would come from restricting the languages available for answers
    $endgroup$
    – senox13
    16 hours ago






  • 2




    $begingroup$
    I updated my question to remove the criteria. Let me know it it's still unclear
    $endgroup$
    – Mr Anderson
    16 hours ago






  • 4




    $begingroup$
    Should I output a decimal number? Or may I output 4 binary digits instead?
    $endgroup$
    – tsh
    16 hours ago
















5












$begingroup$


This function should take four integer inputs (a,b,c,d) and return a binary word based on which values equal the maximum of the four.



The return value will be between 1 and 0xF.



For example:



a = 6, b = 77, c = 1, d = 4



returns 2 (binary 0010; only 2nd-least significant bit is set corresponding to b being sole max value)



a = 4, b = 5, c = 10, d = 10



returns 0xC (binary 1100; 3rd- and 4th-least significant bits set corresponding to c and d equaling max value)



a = 1, b = 1, c = 1, d = 1



returns 0xF (binary 1111; all four bits set because all values equal the max)



Here is a simple implementation:



int getWord(int a, int b, int c, int d)
{
int max = a;
int word = 1;
if (b > max)
{
max = b;
word = 2;
}
else if (b == max)
{
word |= 2;
}
if (c > max)
{
max = c;
word = 4;
}
else if (c == max)
{
word |= 4;
}
if (d > max)
{
word = 8;
}
else if (d == max)
{
word |= 8;
}
return word;
}


return value can be string of 0's and 1's, bool / bit vector, or integer










share|improve this question









New contributor




Mr Anderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$








  • 2




    $begingroup$
    I have a solution in a golfing language, which uses the builtins Reverse, Maximum, Equality-check, Join, Convert from binary to integer, Convert from integer to hexadecimal. Does this means my score is 1 due to the Equality-check? I have the feeling this is too much focused on regular languages, and even for those it's not 100% clear what the scoring for let's say a Maximum-builtin.. :S
    $endgroup$
    – Kevin Cruijssen
    17 hours ago








  • 1




    $begingroup$
    I would suggest you try to: 1. change this question to code-golf, which only care about the number of bytes. 2. or, restrict to some certain language (certain version of compiler/interpreter please), and list all statements and operators allowed, and how to score them.
    $endgroup$
    – tsh
    17 hours ago






  • 4




    $begingroup$
    1 is a better option, IMO. I think this makes a perfectly good code-golf question and I can't see any benefit that would come from restricting the languages available for answers
    $endgroup$
    – senox13
    16 hours ago






  • 2




    $begingroup$
    I updated my question to remove the criteria. Let me know it it's still unclear
    $endgroup$
    – Mr Anderson
    16 hours ago






  • 4




    $begingroup$
    Should I output a decimal number? Or may I output 4 binary digits instead?
    $endgroup$
    – tsh
    16 hours ago














5












5








5





$begingroup$


This function should take four integer inputs (a,b,c,d) and return a binary word based on which values equal the maximum of the four.



The return value will be between 1 and 0xF.



For example:



a = 6, b = 77, c = 1, d = 4



returns 2 (binary 0010; only 2nd-least significant bit is set corresponding to b being sole max value)



a = 4, b = 5, c = 10, d = 10



returns 0xC (binary 1100; 3rd- and 4th-least significant bits set corresponding to c and d equaling max value)



a = 1, b = 1, c = 1, d = 1



returns 0xF (binary 1111; all four bits set because all values equal the max)



Here is a simple implementation:



int getWord(int a, int b, int c, int d)
{
int max = a;
int word = 1;
if (b > max)
{
max = b;
word = 2;
}
else if (b == max)
{
word |= 2;
}
if (c > max)
{
max = c;
word = 4;
}
else if (c == max)
{
word |= 4;
}
if (d > max)
{
word = 8;
}
else if (d == max)
{
word |= 8;
}
return word;
}


return value can be string of 0's and 1's, bool / bit vector, or integer










share|improve this question









New contributor




Mr Anderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




This function should take four integer inputs (a,b,c,d) and return a binary word based on which values equal the maximum of the four.



The return value will be between 1 and 0xF.



For example:



a = 6, b = 77, c = 1, d = 4



returns 2 (binary 0010; only 2nd-least significant bit is set corresponding to b being sole max value)



a = 4, b = 5, c = 10, d = 10



returns 0xC (binary 1100; 3rd- and 4th-least significant bits set corresponding to c and d equaling max value)



a = 1, b = 1, c = 1, d = 1



returns 0xF (binary 1111; all four bits set because all values equal the max)



Here is a simple implementation:



int getWord(int a, int b, int c, int d)
{
int max = a;
int word = 1;
if (b > max)
{
max = b;
word = 2;
}
else if (b == max)
{
word |= 2;
}
if (c > max)
{
max = c;
word = 4;
}
else if (c == max)
{
word |= 4;
}
if (d > max)
{
word = 8;
}
else if (d == max)
{
word |= 8;
}
return word;
}


return value can be string of 0's and 1's, bool / bit vector, or integer







code-golf bitwise






share|improve this question









New contributor




Mr Anderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Mr Anderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 5 hours ago







Mr Anderson













New contributor




Mr Anderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 18 hours ago









Mr AndersonMr Anderson

1284




1284




New contributor




Mr Anderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Mr Anderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Mr Anderson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2




    $begingroup$
    I have a solution in a golfing language, which uses the builtins Reverse, Maximum, Equality-check, Join, Convert from binary to integer, Convert from integer to hexadecimal. Does this means my score is 1 due to the Equality-check? I have the feeling this is too much focused on regular languages, and even for those it's not 100% clear what the scoring for let's say a Maximum-builtin.. :S
    $endgroup$
    – Kevin Cruijssen
    17 hours ago








  • 1




    $begingroup$
    I would suggest you try to: 1. change this question to code-golf, which only care about the number of bytes. 2. or, restrict to some certain language (certain version of compiler/interpreter please), and list all statements and operators allowed, and how to score them.
    $endgroup$
    – tsh
    17 hours ago






  • 4




    $begingroup$
    1 is a better option, IMO. I think this makes a perfectly good code-golf question and I can't see any benefit that would come from restricting the languages available for answers
    $endgroup$
    – senox13
    16 hours ago






  • 2




    $begingroup$
    I updated my question to remove the criteria. Let me know it it's still unclear
    $endgroup$
    – Mr Anderson
    16 hours ago






  • 4




    $begingroup$
    Should I output a decimal number? Or may I output 4 binary digits instead?
    $endgroup$
    – tsh
    16 hours ago














  • 2




    $begingroup$
    I have a solution in a golfing language, which uses the builtins Reverse, Maximum, Equality-check, Join, Convert from binary to integer, Convert from integer to hexadecimal. Does this means my score is 1 due to the Equality-check? I have the feeling this is too much focused on regular languages, and even for those it's not 100% clear what the scoring for let's say a Maximum-builtin.. :S
    $endgroup$
    – Kevin Cruijssen
    17 hours ago








  • 1




    $begingroup$
    I would suggest you try to: 1. change this question to code-golf, which only care about the number of bytes. 2. or, restrict to some certain language (certain version of compiler/interpreter please), and list all statements and operators allowed, and how to score them.
    $endgroup$
    – tsh
    17 hours ago






  • 4




    $begingroup$
    1 is a better option, IMO. I think this makes a perfectly good code-golf question and I can't see any benefit that would come from restricting the languages available for answers
    $endgroup$
    – senox13
    16 hours ago






  • 2




    $begingroup$
    I updated my question to remove the criteria. Let me know it it's still unclear
    $endgroup$
    – Mr Anderson
    16 hours ago






  • 4




    $begingroup$
    Should I output a decimal number? Or may I output 4 binary digits instead?
    $endgroup$
    – tsh
    16 hours ago








2




2




$begingroup$
I have a solution in a golfing language, which uses the builtins Reverse, Maximum, Equality-check, Join, Convert from binary to integer, Convert from integer to hexadecimal. Does this means my score is 1 due to the Equality-check? I have the feeling this is too much focused on regular languages, and even for those it's not 100% clear what the scoring for let's say a Maximum-builtin.. :S
$endgroup$
– Kevin Cruijssen
17 hours ago






$begingroup$
I have a solution in a golfing language, which uses the builtins Reverse, Maximum, Equality-check, Join, Convert from binary to integer, Convert from integer to hexadecimal. Does this means my score is 1 due to the Equality-check? I have the feeling this is too much focused on regular languages, and even for those it's not 100% clear what the scoring for let's say a Maximum-builtin.. :S
$endgroup$
– Kevin Cruijssen
17 hours ago






1




1




$begingroup$
I would suggest you try to: 1. change this question to code-golf, which only care about the number of bytes. 2. or, restrict to some certain language (certain version of compiler/interpreter please), and list all statements and operators allowed, and how to score them.
$endgroup$
– tsh
17 hours ago




$begingroup$
I would suggest you try to: 1. change this question to code-golf, which only care about the number of bytes. 2. or, restrict to some certain language (certain version of compiler/interpreter please), and list all statements and operators allowed, and how to score them.
$endgroup$
– tsh
17 hours ago




4




4




$begingroup$
1 is a better option, IMO. I think this makes a perfectly good code-golf question and I can't see any benefit that would come from restricting the languages available for answers
$endgroup$
– senox13
16 hours ago




$begingroup$
1 is a better option, IMO. I think this makes a perfectly good code-golf question and I can't see any benefit that would come from restricting the languages available for answers
$endgroup$
– senox13
16 hours ago




2




2




$begingroup$
I updated my question to remove the criteria. Let me know it it's still unclear
$endgroup$
– Mr Anderson
16 hours ago




$begingroup$
I updated my question to remove the criteria. Let me know it it's still unclear
$endgroup$
– Mr Anderson
16 hours ago




4




4




$begingroup$
Should I output a decimal number? Or may I output 4 binary digits instead?
$endgroup$
– tsh
16 hours ago




$begingroup$
Should I output a decimal number? Or may I output 4 binary digits instead?
$endgroup$
– tsh
16 hours ago










16 Answers
16






active

oldest

votes


















6












$begingroup$


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)






share|improve this answer









$endgroup$





















    3












    $begingroup$


    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.






    share|improve this answer











    $endgroup$





















      3












      $begingroup$


      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!






      share|improve this answer











      $endgroup$





















        2












        $begingroup$

        Japt, 5



        £Â(X¶UrÈwY


        Try it!



        -4 bytes thanks to @Oliver!

        -2 bytes thanks to @Shaggy!



        Input is a 4-element array in the following format:



        [d, c, b, a]


        Output is an array of bits.






        share|improve this answer











        $endgroup$













        • $begingroup$
          Of course there is ;) There are apparently a lot of shortcuts to learn.
          $endgroup$
          – dana
          8 hours ago










        • $begingroup$
          If a boolean array is an acceptable output, this can be 7 bytes
          $endgroup$
          – Oliver
          8 hours ago










        • $begingroup$
          @Oliver, 5 bytes ;)
          $endgroup$
          – Shaggy
          4 hours ago










        • $begingroup$
          You guys are pretty good :) That's interesting how rw converts to r("w") does a reduce by repeatedly getting the max. Same with getting converted to U.m("===", ...). In any case, thanks for the tips!
          $endgroup$
          – dana
          56 mins ago



















        1












        $begingroup$

        JavaScript (ES6), 40 bytes



        Takes input as ([d,c,b,a]).





        a=>a.map(r=x=>r=r*2|x==Math.max(...a))|r


        Try it online!



        Or 30 bytes if we can return 4 Boolean values:





        a=>a.map(x=>x==Math.max(...a))


        Try it online!






        share|improve this answer











        $endgroup$





















          1












          $begingroup$


          05AB1E, 3 bytes



          ZQR


          Input as a list of [a,b,c,d], output as a list of boolean.



          Try it online or verify all test cases.



          If this output format is not allowed based on the hexadecimal that is used in the challenge description, it would be 6 bytes instead:



          ZQRJCh


          Try it online or verify all test cases.



          Explanation:





          Z    # Take the maximum of the implicit input-list
          Q # Check for each in the (implicit) input-list if it equals this value
          R # Reverse the resulting list (and output implicitly as result)

          J # Join the list of 0s and 1s to a single string
          C # Convert from binary to integer
          h # Convert from integer to hexadecimal (and output implicitly as result)





          share|improve this answer









          $endgroup$





















            1












            $begingroup$


            Perl 6, 12 bytes





            {$_ X==.max}


            Try it online!



            Anonymous code block that takes a list of integers and returns a list of booleans. If we need to return as a number, it's +4 bytes to wrap the inside of the code block with 2:[...].



            Explanation:



            {          }  # Anonymous code block
            $_ # With the input
            X== # Which values are equal
            .max # To the maximum element





            share|improve this answer









            $endgroup$





















              1












              $begingroup$


              Haskell, 47 bytes





              a#b=sum[1|b]+2*a
              foldl(#)0.(map=<<(==).maximum)


              Try it online!



              35 bytes if I can output a string



              f x=show.fromEnum.(==maximum x)=<<x


              Try it online!






              share|improve this answer











              $endgroup$





















                1












                $begingroup$


                C# (Visual C# Interactive Compiler), 39 bytes





                n=>n.Select((a,b)=>n[3-b]==n.Max()?1:0)


                Returns an IEnumerable<int>, which represent bits.



                Try it online!




                C# (Visual C# Interactive Compiler), 35 bytes





                n=>n.Select((a,b)=>n[3-b]==n.Max())


                If an IEnumerable<bool> is acceptable.



                Try it online!




                C# (Visual C# Interactive Compiler), 49 bytes





                n=>{for(int i=4;i-->0;Write(n[i]==n.Max()?1:0));}


                Prints a binary string to STDOUT.



                Try it online!






                share|improve this answer











                $endgroup$





















                  1












                  $begingroup$


                  Python 3.8 (pre-release), 67 bytes



                  Lambda function that takes in 4 integers, bit shifts the boolean result of their comparison to the maximum value with some help from Python 3.8's new assignment operator, and returns the bitwise OR of the results





                  lambda a,b,c,d:((m:=max(a,b,c,d))==d)<<3|(m==c)<<2|(m==b)<<2|(a==m)


                  Try it online!






                  share|improve this answer









                  $endgroup$













                  • $begingroup$
                    := reminds me of the old days where that was the assignment operator with Lotus Notes formula. Guess I'll have to take a look at 3.8 for old times sake :)
                    $endgroup$
                    – ElPedro
                    56 mins ago





















                  0












                  $begingroup$

                  PHP, 54 bytes





                  while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i-1;echo$r;


                  or



                  while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i;echo$r/2;


                  take input from command line arguments. Run with -nr or try them online.






                  share|improve this answer









                  $endgroup$





















                    0












                    $begingroup$

                    Here's a JS version that outputs as binary



                    update: Shorter with join, and without the lookup:




                    JavaScript (Node.js), 42 bytes





                    a=>a.map(x=>+(x==Math.max(...a))).join('')


                    Try it online!



                    Previous, with lookup, 49 bytes





                    a=>a.map(x=>[0,1][+(x==Math.max(...a))]).join('')


                    Try it online!



                    Previous, with reduce, 52 bytes:



                    a=>a.reduce((y,x)=>y+[0,1][+(x==Math.max(...a))],'')


                    Try it online!






                    fa=>a.map(x=>+(x==Math.max(...a))).join('')
                    console.log(f([ 4, 1,77, 6])) // 0010
                    console.log(f([10,10, 5, 4])) // 1100
                    console.log(f([ 1, 1, 1, 1])) // 1111








                    share|improve this answer











                    $endgroup$









                    • 1




                      $begingroup$
                      You can safely remove [0,1][...] since you're using an index that already is either $0$ or $1$.
                      $endgroup$
                      – Arnauld
                      8 hours ago










                    • $begingroup$
                      @Arnauld seems obvious now. Thanks!
                      $endgroup$
                      – Pureferret
                      7 hours ago



















                    0












                    $begingroup$


                    C# (Visual C# Interactive Compiler), 51 bytes





                    x=>{for(int m=x.Max(),i=4;i-->0;)x[i]=x[i]==m?1:0;}


                    Try it online!



                    Above is an anonymous function that outputs by modifying an argument. Output is an array of 1's and 0's.



                    Below is a recursive function that outputs an integer.




                    C# (Visual C# Interactive Compiler), 60 bytes





                    int f(int[]x,int i=3)=>i<0?0:2*f(x,i-1)|(x[i]==x.Max()?1:0);


                    Try it online!



                    Both functions take input as a 4-element array.



                    [d, c, b, a]





                    share|improve this answer











                    $endgroup$





















                      0












                      $begingroup$


                      Java (JDK), 78 bytes





                      a->{int m=a[0],w=1,p=1;for(int t:a){w=t<m?w:p|(t>m?(m=t)^m:w);p*=2;}return w;}


                      Try it online!




                      • Takes the input as an array of [a,b,c,d].






                      share|improve this answer











                      $endgroup$





















                        0












                        $begingroup$


                        Ruby, 34 bytes



                        Takes input as an array [d, c, b, a] and returns an integer.





                        ->r{r.reduce(0){|m,o|o/r.max+m*2}}


                        Try it online!






                        share|improve this answer









                        $endgroup$





















                          0












                          $begingroup$


                          Python 2, 35 bytes





                          lambda i:[int(x==max(i))for x in i]


                          Try it online!



                          Takes input in the format [d,c,b,a] as with the accepted answer from Adám so I guess it is OK.



                          Alternative for 41 if it's not...




                          Python 2, 41 bytes





                          lambda i:[int(x==max(i))for x in i][::-1]


                          Try it online!






                          share|improve this answer











                          $endgroup$













                            Your Answer





                            StackExchange.ifUsing("editor", function () {
                            return StackExchange.using("mathjaxEditing", function () {
                            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                            });
                            });
                            }, "mathjax-editing");

                            StackExchange.ifUsing("editor", function () {
                            StackExchange.using("externalEditor", function () {
                            StackExchange.using("snippets", function () {
                            StackExchange.snippets.init();
                            });
                            });
                            }, "code-snippets");

                            StackExchange.ready(function() {
                            var channelOptions = {
                            tags: "".split(" "),
                            id: "200"
                            };
                            initTagRenderer("".split(" "), "".split(" "), channelOptions);

                            StackExchange.using("externalEditor", function() {
                            // Have to fire editor after snippets, if snippets enabled
                            if (StackExchange.settings.snippets.snippetsEnabled) {
                            StackExchange.using("snippets", function() {
                            createEditor();
                            });
                            }
                            else {
                            createEditor();
                            }
                            });

                            function createEditor() {
                            StackExchange.prepareEditor({
                            heartbeatType: 'answer',
                            autoActivateHeartbeat: false,
                            convertImagesToLinks: false,
                            noModals: true,
                            showLowRepImageUploadWarning: true,
                            reputationToPostImages: null,
                            bindNavPrevention: true,
                            postfix: "",
                            imageUploader: {
                            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                            allowUrls: true
                            },
                            onDemand: true,
                            discardSelector: ".discard-answer"
                            ,immediatelyShowMarkdownHelp:true
                            });


                            }
                            });






                            Mr Anderson is a new contributor. Be nice, and check out our Code of Conduct.










                            draft saved

                            draft discarded


















                            StackExchange.ready(
                            function () {
                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180821%2fcompare-four-integers-return-word-based-on-maximum%23new-answer', 'question_page');
                            }
                            );

                            Post as a guest















                            Required, but never shown

























                            16 Answers
                            16






                            active

                            oldest

                            votes








                            16 Answers
                            16






                            active

                            oldest

                            votes









                            active

                            oldest

                            votes






                            active

                            oldest

                            votes









                            6












                            $begingroup$


                            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)






                            share|improve this answer









                            $endgroup$


















                              6












                              $begingroup$


                              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)






                              share|improve this answer









                              $endgroup$
















                                6












                                6








                                6





                                $begingroup$


                                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)






                                share|improve this answer









                                $endgroup$




                                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)







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered 14 hours ago









                                AdámAdám

                                28.9k276204




                                28.9k276204























                                    3












                                    $begingroup$


                                    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.






                                    share|improve this answer











                                    $endgroup$


















                                      3












                                      $begingroup$


                                      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.






                                      share|improve this answer











                                      $endgroup$
















                                        3












                                        3








                                        3





                                        $begingroup$


                                        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.






                                        share|improve this answer











                                        $endgroup$




                                        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.







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited 16 hours ago

























                                        answered 16 hours ago









                                        AdámAdám

                                        28.9k276204




                                        28.9k276204























                                            3












                                            $begingroup$


                                            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!






                                            share|improve this answer











                                            $endgroup$


















                                              3












                                              $begingroup$


                                              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!






                                              share|improve this answer











                                              $endgroup$
















                                                3












                                                3








                                                3





                                                $begingroup$


                                                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!






                                                share|improve this answer











                                                $endgroup$




                                                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!







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 3 hours ago

























                                                answered 15 hours ago









                                                Kirill L.Kirill L.

                                                4,9851525




                                                4,9851525























                                                    2












                                                    $begingroup$

                                                    Japt, 5



                                                    £Â(X¶UrÈwY


                                                    Try it!



                                                    -4 bytes thanks to @Oliver!

                                                    -2 bytes thanks to @Shaggy!



                                                    Input is a 4-element array in the following format:



                                                    [d, c, b, a]


                                                    Output is an array of bits.






                                                    share|improve this answer











                                                    $endgroup$













                                                    • $begingroup$
                                                      Of course there is ;) There are apparently a lot of shortcuts to learn.
                                                      $endgroup$
                                                      – dana
                                                      8 hours ago










                                                    • $begingroup$
                                                      If a boolean array is an acceptable output, this can be 7 bytes
                                                      $endgroup$
                                                      – Oliver
                                                      8 hours ago










                                                    • $begingroup$
                                                      @Oliver, 5 bytes ;)
                                                      $endgroup$
                                                      – Shaggy
                                                      4 hours ago










                                                    • $begingroup$
                                                      You guys are pretty good :) That's interesting how rw converts to r("w") does a reduce by repeatedly getting the max. Same with getting converted to U.m("===", ...). In any case, thanks for the tips!
                                                      $endgroup$
                                                      – dana
                                                      56 mins ago
















                                                    2












                                                    $begingroup$

                                                    Japt, 5



                                                    £Â(X¶UrÈwY


                                                    Try it!



                                                    -4 bytes thanks to @Oliver!

                                                    -2 bytes thanks to @Shaggy!



                                                    Input is a 4-element array in the following format:



                                                    [d, c, b, a]


                                                    Output is an array of bits.






                                                    share|improve this answer











                                                    $endgroup$













                                                    • $begingroup$
                                                      Of course there is ;) There are apparently a lot of shortcuts to learn.
                                                      $endgroup$
                                                      – dana
                                                      8 hours ago










                                                    • $begingroup$
                                                      If a boolean array is an acceptable output, this can be 7 bytes
                                                      $endgroup$
                                                      – Oliver
                                                      8 hours ago










                                                    • $begingroup$
                                                      @Oliver, 5 bytes ;)
                                                      $endgroup$
                                                      – Shaggy
                                                      4 hours ago










                                                    • $begingroup$
                                                      You guys are pretty good :) That's interesting how rw converts to r("w") does a reduce by repeatedly getting the max. Same with getting converted to U.m("===", ...). In any case, thanks for the tips!
                                                      $endgroup$
                                                      – dana
                                                      56 mins ago














                                                    2












                                                    2








                                                    2





                                                    $begingroup$

                                                    Japt, 5



                                                    £Â(X¶UrÈwY


                                                    Try it!



                                                    -4 bytes thanks to @Oliver!

                                                    -2 bytes thanks to @Shaggy!



                                                    Input is a 4-element array in the following format:



                                                    [d, c, b, a]


                                                    Output is an array of bits.






                                                    share|improve this answer











                                                    $endgroup$



                                                    Japt, 5



                                                    £Â(X¶UrÈwY


                                                    Try it!



                                                    -4 bytes thanks to @Oliver!

                                                    -2 bytes thanks to @Shaggy!



                                                    Input is a 4-element array in the following format:



                                                    [d, c, b, a]


                                                    Output is an array of bits.







                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited 58 mins ago

























                                                    answered 10 hours ago









                                                    danadana

                                                    1,241166




                                                    1,241166












                                                    • $begingroup$
                                                      Of course there is ;) There are apparently a lot of shortcuts to learn.
                                                      $endgroup$
                                                      – dana
                                                      8 hours ago










                                                    • $begingroup$
                                                      If a boolean array is an acceptable output, this can be 7 bytes
                                                      $endgroup$
                                                      – Oliver
                                                      8 hours ago










                                                    • $begingroup$
                                                      @Oliver, 5 bytes ;)
                                                      $endgroup$
                                                      – Shaggy
                                                      4 hours ago










                                                    • $begingroup$
                                                      You guys are pretty good :) That's interesting how rw converts to r("w") does a reduce by repeatedly getting the max. Same with getting converted to U.m("===", ...). In any case, thanks for the tips!
                                                      $endgroup$
                                                      – dana
                                                      56 mins ago


















                                                    • $begingroup$
                                                      Of course there is ;) There are apparently a lot of shortcuts to learn.
                                                      $endgroup$
                                                      – dana
                                                      8 hours ago










                                                    • $begingroup$
                                                      If a boolean array is an acceptable output, this can be 7 bytes
                                                      $endgroup$
                                                      – Oliver
                                                      8 hours ago










                                                    • $begingroup$
                                                      @Oliver, 5 bytes ;)
                                                      $endgroup$
                                                      – Shaggy
                                                      4 hours ago










                                                    • $begingroup$
                                                      You guys are pretty good :) That's interesting how rw converts to r("w") does a reduce by repeatedly getting the max. Same with getting converted to U.m("===", ...). In any case, thanks for the tips!
                                                      $endgroup$
                                                      – dana
                                                      56 mins ago
















                                                    $begingroup$
                                                    Of course there is ;) There are apparently a lot of shortcuts to learn.
                                                    $endgroup$
                                                    – dana
                                                    8 hours ago




                                                    $begingroup$
                                                    Of course there is ;) There are apparently a lot of shortcuts to learn.
                                                    $endgroup$
                                                    – dana
                                                    8 hours ago












                                                    $begingroup$
                                                    If a boolean array is an acceptable output, this can be 7 bytes
                                                    $endgroup$
                                                    – Oliver
                                                    8 hours ago




                                                    $begingroup$
                                                    If a boolean array is an acceptable output, this can be 7 bytes
                                                    $endgroup$
                                                    – Oliver
                                                    8 hours ago












                                                    $begingroup$
                                                    @Oliver, 5 bytes ;)
                                                    $endgroup$
                                                    – Shaggy
                                                    4 hours ago




                                                    $begingroup$
                                                    @Oliver, 5 bytes ;)
                                                    $endgroup$
                                                    – Shaggy
                                                    4 hours ago












                                                    $begingroup$
                                                    You guys are pretty good :) That's interesting how rw converts to r("w") does a reduce by repeatedly getting the max. Same with getting converted to U.m("===", ...). In any case, thanks for the tips!
                                                    $endgroup$
                                                    – dana
                                                    56 mins ago




                                                    $begingroup$
                                                    You guys are pretty good :) That's interesting how rw converts to r("w") does a reduce by repeatedly getting the max. Same with getting converted to U.m("===", ...). In any case, thanks for the tips!
                                                    $endgroup$
                                                    – dana
                                                    56 mins ago











                                                    1












                                                    $begingroup$

                                                    JavaScript (ES6), 40 bytes



                                                    Takes input as ([d,c,b,a]).





                                                    a=>a.map(r=x=>r=r*2|x==Math.max(...a))|r


                                                    Try it online!



                                                    Or 30 bytes if we can return 4 Boolean values:





                                                    a=>a.map(x=>x==Math.max(...a))


                                                    Try it online!






                                                    share|improve this answer











                                                    $endgroup$


















                                                      1












                                                      $begingroup$

                                                      JavaScript (ES6), 40 bytes



                                                      Takes input as ([d,c,b,a]).





                                                      a=>a.map(r=x=>r=r*2|x==Math.max(...a))|r


                                                      Try it online!



                                                      Or 30 bytes if we can return 4 Boolean values:





                                                      a=>a.map(x=>x==Math.max(...a))


                                                      Try it online!






                                                      share|improve this answer











                                                      $endgroup$
















                                                        1












                                                        1








                                                        1





                                                        $begingroup$

                                                        JavaScript (ES6), 40 bytes



                                                        Takes input as ([d,c,b,a]).





                                                        a=>a.map(r=x=>r=r*2|x==Math.max(...a))|r


                                                        Try it online!



                                                        Or 30 bytes if we can return 4 Boolean values:





                                                        a=>a.map(x=>x==Math.max(...a))


                                                        Try it online!






                                                        share|improve this answer











                                                        $endgroup$



                                                        JavaScript (ES6), 40 bytes



                                                        Takes input as ([d,c,b,a]).





                                                        a=>a.map(r=x=>r=r*2|x==Math.max(...a))|r


                                                        Try it online!



                                                        Or 30 bytes if we can return 4 Boolean values:





                                                        a=>a.map(x=>x==Math.max(...a))


                                                        Try it online!







                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited 15 hours ago

























                                                        answered 16 hours ago









                                                        ArnauldArnauld

                                                        77.6k694325




                                                        77.6k694325























                                                            1












                                                            $begingroup$


                                                            05AB1E, 3 bytes



                                                            ZQR


                                                            Input as a list of [a,b,c,d], output as a list of boolean.



                                                            Try it online or verify all test cases.



                                                            If this output format is not allowed based on the hexadecimal that is used in the challenge description, it would be 6 bytes instead:



                                                            ZQRJCh


                                                            Try it online or verify all test cases.



                                                            Explanation:





                                                            Z    # Take the maximum of the implicit input-list
                                                            Q # Check for each in the (implicit) input-list if it equals this value
                                                            R # Reverse the resulting list (and output implicitly as result)

                                                            J # Join the list of 0s and 1s to a single string
                                                            C # Convert from binary to integer
                                                            h # Convert from integer to hexadecimal (and output implicitly as result)





                                                            share|improve this answer









                                                            $endgroup$


















                                                              1












                                                              $begingroup$


                                                              05AB1E, 3 bytes



                                                              ZQR


                                                              Input as a list of [a,b,c,d], output as a list of boolean.



                                                              Try it online or verify all test cases.



                                                              If this output format is not allowed based on the hexadecimal that is used in the challenge description, it would be 6 bytes instead:



                                                              ZQRJCh


                                                              Try it online or verify all test cases.



                                                              Explanation:





                                                              Z    # Take the maximum of the implicit input-list
                                                              Q # Check for each in the (implicit) input-list if it equals this value
                                                              R # Reverse the resulting list (and output implicitly as result)

                                                              J # Join the list of 0s and 1s to a single string
                                                              C # Convert from binary to integer
                                                              h # Convert from integer to hexadecimal (and output implicitly as result)





                                                              share|improve this answer









                                                              $endgroup$
















                                                                1












                                                                1








                                                                1





                                                                $begingroup$


                                                                05AB1E, 3 bytes



                                                                ZQR


                                                                Input as a list of [a,b,c,d], output as a list of boolean.



                                                                Try it online or verify all test cases.



                                                                If this output format is not allowed based on the hexadecimal that is used in the challenge description, it would be 6 bytes instead:



                                                                ZQRJCh


                                                                Try it online or verify all test cases.



                                                                Explanation:





                                                                Z    # Take the maximum of the implicit input-list
                                                                Q # Check for each in the (implicit) input-list if it equals this value
                                                                R # Reverse the resulting list (and output implicitly as result)

                                                                J # Join the list of 0s and 1s to a single string
                                                                C # Convert from binary to integer
                                                                h # Convert from integer to hexadecimal (and output implicitly as result)





                                                                share|improve this answer









                                                                $endgroup$




                                                                05AB1E, 3 bytes



                                                                ZQR


                                                                Input as a list of [a,b,c,d], output as a list of boolean.



                                                                Try it online or verify all test cases.



                                                                If this output format is not allowed based on the hexadecimal that is used in the challenge description, it would be 6 bytes instead:



                                                                ZQRJCh


                                                                Try it online or verify all test cases.



                                                                Explanation:





                                                                Z    # Take the maximum of the implicit input-list
                                                                Q # Check for each in the (implicit) input-list if it equals this value
                                                                R # Reverse the resulting list (and output implicitly as result)

                                                                J # Join the list of 0s and 1s to a single string
                                                                C # Convert from binary to integer
                                                                h # Convert from integer to hexadecimal (and output implicitly as result)






                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered 15 hours ago









                                                                Kevin CruijssenKevin Cruijssen

                                                                39.4k560203




                                                                39.4k560203























                                                                    1












                                                                    $begingroup$


                                                                    Perl 6, 12 bytes





                                                                    {$_ X==.max}


                                                                    Try it online!



                                                                    Anonymous code block that takes a list of integers and returns a list of booleans. If we need to return as a number, it's +4 bytes to wrap the inside of the code block with 2:[...].



                                                                    Explanation:



                                                                    {          }  # Anonymous code block
                                                                    $_ # With the input
                                                                    X== # Which values are equal
                                                                    .max # To the maximum element





                                                                    share|improve this answer









                                                                    $endgroup$


















                                                                      1












                                                                      $begingroup$


                                                                      Perl 6, 12 bytes





                                                                      {$_ X==.max}


                                                                      Try it online!



                                                                      Anonymous code block that takes a list of integers and returns a list of booleans. If we need to return as a number, it's +4 bytes to wrap the inside of the code block with 2:[...].



                                                                      Explanation:



                                                                      {          }  # Anonymous code block
                                                                      $_ # With the input
                                                                      X== # Which values are equal
                                                                      .max # To the maximum element





                                                                      share|improve this answer









                                                                      $endgroup$
















                                                                        1












                                                                        1








                                                                        1





                                                                        $begingroup$


                                                                        Perl 6, 12 bytes





                                                                        {$_ X==.max}


                                                                        Try it online!



                                                                        Anonymous code block that takes a list of integers and returns a list of booleans. If we need to return as a number, it's +4 bytes to wrap the inside of the code block with 2:[...].



                                                                        Explanation:



                                                                        {          }  # Anonymous code block
                                                                        $_ # With the input
                                                                        X== # Which values are equal
                                                                        .max # To the maximum element





                                                                        share|improve this answer









                                                                        $endgroup$




                                                                        Perl 6, 12 bytes





                                                                        {$_ X==.max}


                                                                        Try it online!



                                                                        Anonymous code block that takes a list of integers and returns a list of booleans. If we need to return as a number, it's +4 bytes to wrap the inside of the code block with 2:[...].



                                                                        Explanation:



                                                                        {          }  # Anonymous code block
                                                                        $_ # With the input
                                                                        X== # Which values are equal
                                                                        .max # To the maximum element






                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered 15 hours ago









                                                                        Jo KingJo King

                                                                        24.2k357124




                                                                        24.2k357124























                                                                            1












                                                                            $begingroup$


                                                                            Haskell, 47 bytes





                                                                            a#b=sum[1|b]+2*a
                                                                            foldl(#)0.(map=<<(==).maximum)


                                                                            Try it online!



                                                                            35 bytes if I can output a string



                                                                            f x=show.fromEnum.(==maximum x)=<<x


                                                                            Try it online!






                                                                            share|improve this answer











                                                                            $endgroup$


















                                                                              1












                                                                              $begingroup$


                                                                              Haskell, 47 bytes





                                                                              a#b=sum[1|b]+2*a
                                                                              foldl(#)0.(map=<<(==).maximum)


                                                                              Try it online!



                                                                              35 bytes if I can output a string



                                                                              f x=show.fromEnum.(==maximum x)=<<x


                                                                              Try it online!






                                                                              share|improve this answer











                                                                              $endgroup$
















                                                                                1












                                                                                1








                                                                                1





                                                                                $begingroup$


                                                                                Haskell, 47 bytes





                                                                                a#b=sum[1|b]+2*a
                                                                                foldl(#)0.(map=<<(==).maximum)


                                                                                Try it online!



                                                                                35 bytes if I can output a string



                                                                                f x=show.fromEnum.(==maximum x)=<<x


                                                                                Try it online!






                                                                                share|improve this answer











                                                                                $endgroup$




                                                                                Haskell, 47 bytes





                                                                                a#b=sum[1|b]+2*a
                                                                                foldl(#)0.(map=<<(==).maximum)


                                                                                Try it online!



                                                                                35 bytes if I can output a string



                                                                                f x=show.fromEnum.(==maximum x)=<<x


                                                                                Try it online!







                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited 9 hours ago

























                                                                                answered 9 hours ago









                                                                                Sriotchilism O'ZaicSriotchilism O'Zaic

                                                                                35.2k10159369




                                                                                35.2k10159369























                                                                                    1












                                                                                    $begingroup$


                                                                                    C# (Visual C# Interactive Compiler), 39 bytes





                                                                                    n=>n.Select((a,b)=>n[3-b]==n.Max()?1:0)


                                                                                    Returns an IEnumerable<int>, which represent bits.



                                                                                    Try it online!




                                                                                    C# (Visual C# Interactive Compiler), 35 bytes





                                                                                    n=>n.Select((a,b)=>n[3-b]==n.Max())


                                                                                    If an IEnumerable<bool> is acceptable.



                                                                                    Try it online!




                                                                                    C# (Visual C# Interactive Compiler), 49 bytes





                                                                                    n=>{for(int i=4;i-->0;Write(n[i]==n.Max()?1:0));}


                                                                                    Prints a binary string to STDOUT.



                                                                                    Try it online!






                                                                                    share|improve this answer











                                                                                    $endgroup$


















                                                                                      1












                                                                                      $begingroup$


                                                                                      C# (Visual C# Interactive Compiler), 39 bytes





                                                                                      n=>n.Select((a,b)=>n[3-b]==n.Max()?1:0)


                                                                                      Returns an IEnumerable<int>, which represent bits.



                                                                                      Try it online!




                                                                                      C# (Visual C# Interactive Compiler), 35 bytes





                                                                                      n=>n.Select((a,b)=>n[3-b]==n.Max())


                                                                                      If an IEnumerable<bool> is acceptable.



                                                                                      Try it online!




                                                                                      C# (Visual C# Interactive Compiler), 49 bytes





                                                                                      n=>{for(int i=4;i-->0;Write(n[i]==n.Max()?1:0));}


                                                                                      Prints a binary string to STDOUT.



                                                                                      Try it online!






                                                                                      share|improve this answer











                                                                                      $endgroup$
















                                                                                        1












                                                                                        1








                                                                                        1





                                                                                        $begingroup$


                                                                                        C# (Visual C# Interactive Compiler), 39 bytes





                                                                                        n=>n.Select((a,b)=>n[3-b]==n.Max()?1:0)


                                                                                        Returns an IEnumerable<int>, which represent bits.



                                                                                        Try it online!




                                                                                        C# (Visual C# Interactive Compiler), 35 bytes





                                                                                        n=>n.Select((a,b)=>n[3-b]==n.Max())


                                                                                        If an IEnumerable<bool> is acceptable.



                                                                                        Try it online!




                                                                                        C# (Visual C# Interactive Compiler), 49 bytes





                                                                                        n=>{for(int i=4;i-->0;Write(n[i]==n.Max()?1:0));}


                                                                                        Prints a binary string to STDOUT.



                                                                                        Try it online!






                                                                                        share|improve this answer











                                                                                        $endgroup$




                                                                                        C# (Visual C# Interactive Compiler), 39 bytes





                                                                                        n=>n.Select((a,b)=>n[3-b]==n.Max()?1:0)


                                                                                        Returns an IEnumerable<int>, which represent bits.



                                                                                        Try it online!




                                                                                        C# (Visual C# Interactive Compiler), 35 bytes





                                                                                        n=>n.Select((a,b)=>n[3-b]==n.Max())


                                                                                        If an IEnumerable<bool> is acceptable.



                                                                                        Try it online!




                                                                                        C# (Visual C# Interactive Compiler), 49 bytes





                                                                                        n=>{for(int i=4;i-->0;Write(n[i]==n.Max()?1:0));}


                                                                                        Prints a binary string to STDOUT.



                                                                                        Try it online!







                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited 8 hours ago

























                                                                                        answered 8 hours ago









                                                                                        Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                        1,438123




                                                                                        1,438123























                                                                                            1












                                                                                            $begingroup$


                                                                                            Python 3.8 (pre-release), 67 bytes



                                                                                            Lambda function that takes in 4 integers, bit shifts the boolean result of their comparison to the maximum value with some help from Python 3.8's new assignment operator, and returns the bitwise OR of the results





                                                                                            lambda a,b,c,d:((m:=max(a,b,c,d))==d)<<3|(m==c)<<2|(m==b)<<2|(a==m)


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$













                                                                                            • $begingroup$
                                                                                              := reminds me of the old days where that was the assignment operator with Lotus Notes formula. Guess I'll have to take a look at 3.8 for old times sake :)
                                                                                              $endgroup$
                                                                                              – ElPedro
                                                                                              56 mins ago


















                                                                                            1












                                                                                            $begingroup$


                                                                                            Python 3.8 (pre-release), 67 bytes



                                                                                            Lambda function that takes in 4 integers, bit shifts the boolean result of their comparison to the maximum value with some help from Python 3.8's new assignment operator, and returns the bitwise OR of the results





                                                                                            lambda a,b,c,d:((m:=max(a,b,c,d))==d)<<3|(m==c)<<2|(m==b)<<2|(a==m)


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$













                                                                                            • $begingroup$
                                                                                              := reminds me of the old days where that was the assignment operator with Lotus Notes formula. Guess I'll have to take a look at 3.8 for old times sake :)
                                                                                              $endgroup$
                                                                                              – ElPedro
                                                                                              56 mins ago
















                                                                                            1












                                                                                            1








                                                                                            1





                                                                                            $begingroup$


                                                                                            Python 3.8 (pre-release), 67 bytes



                                                                                            Lambda function that takes in 4 integers, bit shifts the boolean result of their comparison to the maximum value with some help from Python 3.8's new assignment operator, and returns the bitwise OR of the results





                                                                                            lambda a,b,c,d:((m:=max(a,b,c,d))==d)<<3|(m==c)<<2|(m==b)<<2|(a==m)


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$




                                                                                            Python 3.8 (pre-release), 67 bytes



                                                                                            Lambda function that takes in 4 integers, bit shifts the boolean result of their comparison to the maximum value with some help from Python 3.8's new assignment operator, and returns the bitwise OR of the results





                                                                                            lambda a,b,c,d:((m:=max(a,b,c,d))==d)<<3|(m==c)<<2|(m==b)<<2|(a==m)


                                                                                            Try it online!







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered 2 hours ago









                                                                                            senox13senox13

                                                                                            1115




                                                                                            1115












                                                                                            • $begingroup$
                                                                                              := reminds me of the old days where that was the assignment operator with Lotus Notes formula. Guess I'll have to take a look at 3.8 for old times sake :)
                                                                                              $endgroup$
                                                                                              – ElPedro
                                                                                              56 mins ago




















                                                                                            • $begingroup$
                                                                                              := reminds me of the old days where that was the assignment operator with Lotus Notes formula. Guess I'll have to take a look at 3.8 for old times sake :)
                                                                                              $endgroup$
                                                                                              – ElPedro
                                                                                              56 mins ago


















                                                                                            $begingroup$
                                                                                            := reminds me of the old days where that was the assignment operator with Lotus Notes formula. Guess I'll have to take a look at 3.8 for old times sake :)
                                                                                            $endgroup$
                                                                                            – ElPedro
                                                                                            56 mins ago






                                                                                            $begingroup$
                                                                                            := reminds me of the old days where that was the assignment operator with Lotus Notes formula. Guess I'll have to take a look at 3.8 for old times sake :)
                                                                                            $endgroup$
                                                                                            – ElPedro
                                                                                            56 mins ago













                                                                                            0












                                                                                            $begingroup$

                                                                                            PHP, 54 bytes





                                                                                            while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i-1;echo$r;


                                                                                            or



                                                                                            while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i;echo$r/2;


                                                                                            take input from command line arguments. Run with -nr or try them online.






                                                                                            share|improve this answer









                                                                                            $endgroup$


















                                                                                              0












                                                                                              $begingroup$

                                                                                              PHP, 54 bytes





                                                                                              while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i-1;echo$r;


                                                                                              or



                                                                                              while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i;echo$r/2;


                                                                                              take input from command line arguments. Run with -nr or try them online.






                                                                                              share|improve this answer









                                                                                              $endgroup$
















                                                                                                0












                                                                                                0








                                                                                                0





                                                                                                $begingroup$

                                                                                                PHP, 54 bytes





                                                                                                while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i-1;echo$r;


                                                                                                or



                                                                                                while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i;echo$r/2;


                                                                                                take input from command line arguments. Run with -nr or try them online.






                                                                                                share|improve this answer









                                                                                                $endgroup$



                                                                                                PHP, 54 bytes





                                                                                                while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i-1;echo$r;


                                                                                                or



                                                                                                while($i<4)$argv[++$i]<max($argv)||$r+=1<<$i;echo$r/2;


                                                                                                take input from command line arguments. Run with -nr or try them online.







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered 8 hours ago









                                                                                                TitusTitus

                                                                                                13.2k11238




                                                                                                13.2k11238























                                                                                                    0












                                                                                                    $begingroup$

                                                                                                    Here's a JS version that outputs as binary



                                                                                                    update: Shorter with join, and without the lookup:




                                                                                                    JavaScript (Node.js), 42 bytes





                                                                                                    a=>a.map(x=>+(x==Math.max(...a))).join('')


                                                                                                    Try it online!



                                                                                                    Previous, with lookup, 49 bytes





                                                                                                    a=>a.map(x=>[0,1][+(x==Math.max(...a))]).join('')


                                                                                                    Try it online!



                                                                                                    Previous, with reduce, 52 bytes:



                                                                                                    a=>a.reduce((y,x)=>y+[0,1][+(x==Math.max(...a))],'')


                                                                                                    Try it online!






                                                                                                    fa=>a.map(x=>+(x==Math.max(...a))).join('')
                                                                                                    console.log(f([ 4, 1,77, 6])) // 0010
                                                                                                    console.log(f([10,10, 5, 4])) // 1100
                                                                                                    console.log(f([ 1, 1, 1, 1])) // 1111








                                                                                                    share|improve this answer











                                                                                                    $endgroup$









                                                                                                    • 1




                                                                                                      $begingroup$
                                                                                                      You can safely remove [0,1][...] since you're using an index that already is either $0$ or $1$.
                                                                                                      $endgroup$
                                                                                                      – Arnauld
                                                                                                      8 hours ago










                                                                                                    • $begingroup$
                                                                                                      @Arnauld seems obvious now. Thanks!
                                                                                                      $endgroup$
                                                                                                      – Pureferret
                                                                                                      7 hours ago
















                                                                                                    0












                                                                                                    $begingroup$

                                                                                                    Here's a JS version that outputs as binary



                                                                                                    update: Shorter with join, and without the lookup:




                                                                                                    JavaScript (Node.js), 42 bytes





                                                                                                    a=>a.map(x=>+(x==Math.max(...a))).join('')


                                                                                                    Try it online!



                                                                                                    Previous, with lookup, 49 bytes





                                                                                                    a=>a.map(x=>[0,1][+(x==Math.max(...a))]).join('')


                                                                                                    Try it online!



                                                                                                    Previous, with reduce, 52 bytes:



                                                                                                    a=>a.reduce((y,x)=>y+[0,1][+(x==Math.max(...a))],'')


                                                                                                    Try it online!






                                                                                                    fa=>a.map(x=>+(x==Math.max(...a))).join('')
                                                                                                    console.log(f([ 4, 1,77, 6])) // 0010
                                                                                                    console.log(f([10,10, 5, 4])) // 1100
                                                                                                    console.log(f([ 1, 1, 1, 1])) // 1111








                                                                                                    share|improve this answer











                                                                                                    $endgroup$









                                                                                                    • 1




                                                                                                      $begingroup$
                                                                                                      You can safely remove [0,1][...] since you're using an index that already is either $0$ or $1$.
                                                                                                      $endgroup$
                                                                                                      – Arnauld
                                                                                                      8 hours ago










                                                                                                    • $begingroup$
                                                                                                      @Arnauld seems obvious now. Thanks!
                                                                                                      $endgroup$
                                                                                                      – Pureferret
                                                                                                      7 hours ago














                                                                                                    0












                                                                                                    0








                                                                                                    0





                                                                                                    $begingroup$

                                                                                                    Here's a JS version that outputs as binary



                                                                                                    update: Shorter with join, and without the lookup:




                                                                                                    JavaScript (Node.js), 42 bytes





                                                                                                    a=>a.map(x=>+(x==Math.max(...a))).join('')


                                                                                                    Try it online!



                                                                                                    Previous, with lookup, 49 bytes





                                                                                                    a=>a.map(x=>[0,1][+(x==Math.max(...a))]).join('')


                                                                                                    Try it online!



                                                                                                    Previous, with reduce, 52 bytes:



                                                                                                    a=>a.reduce((y,x)=>y+[0,1][+(x==Math.max(...a))],'')


                                                                                                    Try it online!






                                                                                                    fa=>a.map(x=>+(x==Math.max(...a))).join('')
                                                                                                    console.log(f([ 4, 1,77, 6])) // 0010
                                                                                                    console.log(f([10,10, 5, 4])) // 1100
                                                                                                    console.log(f([ 1, 1, 1, 1])) // 1111








                                                                                                    share|improve this answer











                                                                                                    $endgroup$



                                                                                                    Here's a JS version that outputs as binary



                                                                                                    update: Shorter with join, and without the lookup:




                                                                                                    JavaScript (Node.js), 42 bytes





                                                                                                    a=>a.map(x=>+(x==Math.max(...a))).join('')


                                                                                                    Try it online!



                                                                                                    Previous, with lookup, 49 bytes





                                                                                                    a=>a.map(x=>[0,1][+(x==Math.max(...a))]).join('')


                                                                                                    Try it online!



                                                                                                    Previous, with reduce, 52 bytes:



                                                                                                    a=>a.reduce((y,x)=>y+[0,1][+(x==Math.max(...a))],'')


                                                                                                    Try it online!






                                                                                                    fa=>a.map(x=>+(x==Math.max(...a))).join('')
                                                                                                    console.log(f([ 4, 1,77, 6])) // 0010
                                                                                                    console.log(f([10,10, 5, 4])) // 1100
                                                                                                    console.log(f([ 1, 1, 1, 1])) // 1111








                                                                                                    fa=>a.map(x=>+(x==Math.max(...a))).join('')
                                                                                                    console.log(f([ 4, 1,77, 6])) // 0010
                                                                                                    console.log(f([10,10, 5, 4])) // 1100
                                                                                                    console.log(f([ 1, 1, 1, 1])) // 1111





                                                                                                    fa=>a.map(x=>+(x==Math.max(...a))).join('')
                                                                                                    console.log(f([ 4, 1,77, 6])) // 0010
                                                                                                    console.log(f([10,10, 5, 4])) // 1100
                                                                                                    console.log(f([ 1, 1, 1, 1])) // 1111






                                                                                                    share|improve this answer














                                                                                                    share|improve this answer



                                                                                                    share|improve this answer








                                                                                                    edited 8 hours ago

























                                                                                                    answered 9 hours ago









                                                                                                    PureferretPureferret

                                                                                                    543726




                                                                                                    543726








                                                                                                    • 1




                                                                                                      $begingroup$
                                                                                                      You can safely remove [0,1][...] since you're using an index that already is either $0$ or $1$.
                                                                                                      $endgroup$
                                                                                                      – Arnauld
                                                                                                      8 hours ago










                                                                                                    • $begingroup$
                                                                                                      @Arnauld seems obvious now. Thanks!
                                                                                                      $endgroup$
                                                                                                      – Pureferret
                                                                                                      7 hours ago














                                                                                                    • 1




                                                                                                      $begingroup$
                                                                                                      You can safely remove [0,1][...] since you're using an index that already is either $0$ or $1$.
                                                                                                      $endgroup$
                                                                                                      – Arnauld
                                                                                                      8 hours ago










                                                                                                    • $begingroup$
                                                                                                      @Arnauld seems obvious now. Thanks!
                                                                                                      $endgroup$
                                                                                                      – Pureferret
                                                                                                      7 hours ago








                                                                                                    1




                                                                                                    1




                                                                                                    $begingroup$
                                                                                                    You can safely remove [0,1][...] since you're using an index that already is either $0$ or $1$.
                                                                                                    $endgroup$
                                                                                                    – Arnauld
                                                                                                    8 hours ago




                                                                                                    $begingroup$
                                                                                                    You can safely remove [0,1][...] since you're using an index that already is either $0$ or $1$.
                                                                                                    $endgroup$
                                                                                                    – Arnauld
                                                                                                    8 hours ago












                                                                                                    $begingroup$
                                                                                                    @Arnauld seems obvious now. Thanks!
                                                                                                    $endgroup$
                                                                                                    – Pureferret
                                                                                                    7 hours ago




                                                                                                    $begingroup$
                                                                                                    @Arnauld seems obvious now. Thanks!
                                                                                                    $endgroup$
                                                                                                    – Pureferret
                                                                                                    7 hours ago











                                                                                                    0












                                                                                                    $begingroup$


                                                                                                    C# (Visual C# Interactive Compiler), 51 bytes





                                                                                                    x=>{for(int m=x.Max(),i=4;i-->0;)x[i]=x[i]==m?1:0;}


                                                                                                    Try it online!



                                                                                                    Above is an anonymous function that outputs by modifying an argument. Output is an array of 1's and 0's.



                                                                                                    Below is a recursive function that outputs an integer.




                                                                                                    C# (Visual C# Interactive Compiler), 60 bytes





                                                                                                    int f(int[]x,int i=3)=>i<0?0:2*f(x,i-1)|(x[i]==x.Max()?1:0);


                                                                                                    Try it online!



                                                                                                    Both functions take input as a 4-element array.



                                                                                                    [d, c, b, a]





                                                                                                    share|improve this answer











                                                                                                    $endgroup$


















                                                                                                      0












                                                                                                      $begingroup$


                                                                                                      C# (Visual C# Interactive Compiler), 51 bytes





                                                                                                      x=>{for(int m=x.Max(),i=4;i-->0;)x[i]=x[i]==m?1:0;}


                                                                                                      Try it online!



                                                                                                      Above is an anonymous function that outputs by modifying an argument. Output is an array of 1's and 0's.



                                                                                                      Below is a recursive function that outputs an integer.




                                                                                                      C# (Visual C# Interactive Compiler), 60 bytes





                                                                                                      int f(int[]x,int i=3)=>i<0?0:2*f(x,i-1)|(x[i]==x.Max()?1:0);


                                                                                                      Try it online!



                                                                                                      Both functions take input as a 4-element array.



                                                                                                      [d, c, b, a]





                                                                                                      share|improve this answer











                                                                                                      $endgroup$
















                                                                                                        0












                                                                                                        0








                                                                                                        0





                                                                                                        $begingroup$


                                                                                                        C# (Visual C# Interactive Compiler), 51 bytes





                                                                                                        x=>{for(int m=x.Max(),i=4;i-->0;)x[i]=x[i]==m?1:0;}


                                                                                                        Try it online!



                                                                                                        Above is an anonymous function that outputs by modifying an argument. Output is an array of 1's and 0's.



                                                                                                        Below is a recursive function that outputs an integer.




                                                                                                        C# (Visual C# Interactive Compiler), 60 bytes





                                                                                                        int f(int[]x,int i=3)=>i<0?0:2*f(x,i-1)|(x[i]==x.Max()?1:0);


                                                                                                        Try it online!



                                                                                                        Both functions take input as a 4-element array.



                                                                                                        [d, c, b, a]





                                                                                                        share|improve this answer











                                                                                                        $endgroup$




                                                                                                        C# (Visual C# Interactive Compiler), 51 bytes





                                                                                                        x=>{for(int m=x.Max(),i=4;i-->0;)x[i]=x[i]==m?1:0;}


                                                                                                        Try it online!



                                                                                                        Above is an anonymous function that outputs by modifying an argument. Output is an array of 1's and 0's.



                                                                                                        Below is a recursive function that outputs an integer.




                                                                                                        C# (Visual C# Interactive Compiler), 60 bytes





                                                                                                        int f(int[]x,int i=3)=>i<0?0:2*f(x,i-1)|(x[i]==x.Max()?1:0);


                                                                                                        Try it online!



                                                                                                        Both functions take input as a 4-element array.



                                                                                                        [d, c, b, a]






                                                                                                        share|improve this answer














                                                                                                        share|improve this answer



                                                                                                        share|improve this answer








                                                                                                        edited 7 hours ago

























                                                                                                        answered 10 hours ago









                                                                                                        danadana

                                                                                                        1,241166




                                                                                                        1,241166























                                                                                                            0












                                                                                                            $begingroup$


                                                                                                            Java (JDK), 78 bytes





                                                                                                            a->{int m=a[0],w=1,p=1;for(int t:a){w=t<m?w:p|(t>m?(m=t)^m:w);p*=2;}return w;}


                                                                                                            Try it online!




                                                                                                            • Takes the input as an array of [a,b,c,d].






                                                                                                            share|improve this answer











                                                                                                            $endgroup$


















                                                                                                              0












                                                                                                              $begingroup$


                                                                                                              Java (JDK), 78 bytes





                                                                                                              a->{int m=a[0],w=1,p=1;for(int t:a){w=t<m?w:p|(t>m?(m=t)^m:w);p*=2;}return w;}


                                                                                                              Try it online!




                                                                                                              • Takes the input as an array of [a,b,c,d].






                                                                                                              share|improve this answer











                                                                                                              $endgroup$
















                                                                                                                0












                                                                                                                0








                                                                                                                0





                                                                                                                $begingroup$


                                                                                                                Java (JDK), 78 bytes





                                                                                                                a->{int m=a[0],w=1,p=1;for(int t:a){w=t<m?w:p|(t>m?(m=t)^m:w);p*=2;}return w;}


                                                                                                                Try it online!




                                                                                                                • Takes the input as an array of [a,b,c,d].






                                                                                                                share|improve this answer











                                                                                                                $endgroup$




                                                                                                                Java (JDK), 78 bytes





                                                                                                                a->{int m=a[0],w=1,p=1;for(int t:a){w=t<m?w:p|(t>m?(m=t)^m:w);p*=2;}return w;}


                                                                                                                Try it online!




                                                                                                                • Takes the input as an array of [a,b,c,d].







                                                                                                                share|improve this answer














                                                                                                                share|improve this answer



                                                                                                                share|improve this answer








                                                                                                                edited 2 hours ago

























                                                                                                                answered 13 hours ago









                                                                                                                Olivier GrégoireOlivier Grégoire

                                                                                                                9,18511944




                                                                                                                9,18511944























                                                                                                                    0












                                                                                                                    $begingroup$


                                                                                                                    Ruby, 34 bytes



                                                                                                                    Takes input as an array [d, c, b, a] and returns an integer.





                                                                                                                    ->r{r.reduce(0){|m,o|o/r.max+m*2}}


                                                                                                                    Try it online!






                                                                                                                    share|improve this answer









                                                                                                                    $endgroup$


















                                                                                                                      0












                                                                                                                      $begingroup$


                                                                                                                      Ruby, 34 bytes



                                                                                                                      Takes input as an array [d, c, b, a] and returns an integer.





                                                                                                                      ->r{r.reduce(0){|m,o|o/r.max+m*2}}


                                                                                                                      Try it online!






                                                                                                                      share|improve this answer









                                                                                                                      $endgroup$
















                                                                                                                        0












                                                                                                                        0








                                                                                                                        0





                                                                                                                        $begingroup$


                                                                                                                        Ruby, 34 bytes



                                                                                                                        Takes input as an array [d, c, b, a] and returns an integer.





                                                                                                                        ->r{r.reduce(0){|m,o|o/r.max+m*2}}


                                                                                                                        Try it online!






                                                                                                                        share|improve this answer









                                                                                                                        $endgroup$




                                                                                                                        Ruby, 34 bytes



                                                                                                                        Takes input as an array [d, c, b, a] and returns an integer.





                                                                                                                        ->r{r.reduce(0){|m,o|o/r.max+m*2}}


                                                                                                                        Try it online!







                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered 50 mins ago









                                                                                                                        iamnotmaynardiamnotmaynard

                                                                                                                        91349




                                                                                                                        91349























                                                                                                                            0












                                                                                                                            $begingroup$


                                                                                                                            Python 2, 35 bytes





                                                                                                                            lambda i:[int(x==max(i))for x in i]


                                                                                                                            Try it online!



                                                                                                                            Takes input in the format [d,c,b,a] as with the accepted answer from Adám so I guess it is OK.



                                                                                                                            Alternative for 41 if it's not...




                                                                                                                            Python 2, 41 bytes





                                                                                                                            lambda i:[int(x==max(i))for x in i][::-1]


                                                                                                                            Try it online!






                                                                                                                            share|improve this answer











                                                                                                                            $endgroup$


















                                                                                                                              0












                                                                                                                              $begingroup$


                                                                                                                              Python 2, 35 bytes





                                                                                                                              lambda i:[int(x==max(i))for x in i]


                                                                                                                              Try it online!



                                                                                                                              Takes input in the format [d,c,b,a] as with the accepted answer from Adám so I guess it is OK.



                                                                                                                              Alternative for 41 if it's not...




                                                                                                                              Python 2, 41 bytes





                                                                                                                              lambda i:[int(x==max(i))for x in i][::-1]


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$
















                                                                                                                                0












                                                                                                                                0








                                                                                                                                0





                                                                                                                                $begingroup$


                                                                                                                                Python 2, 35 bytes





                                                                                                                                lambda i:[int(x==max(i))for x in i]


                                                                                                                                Try it online!



                                                                                                                                Takes input in the format [d,c,b,a] as with the accepted answer from Adám so I guess it is OK.



                                                                                                                                Alternative for 41 if it's not...




                                                                                                                                Python 2, 41 bytes





                                                                                                                                lambda i:[int(x==max(i))for x in i][::-1]


                                                                                                                                Try it online!






                                                                                                                                share|improve this answer











                                                                                                                                $endgroup$




                                                                                                                                Python 2, 35 bytes





                                                                                                                                lambda i:[int(x==max(i))for x in i]


                                                                                                                                Try it online!



                                                                                                                                Takes input in the format [d,c,b,a] as with the accepted answer from Adám so I guess it is OK.



                                                                                                                                Alternative for 41 if it's not...




                                                                                                                                Python 2, 41 bytes





                                                                                                                                lambda i:[int(x==max(i))for x in i][::-1]


                                                                                                                                Try it online!







                                                                                                                                share|improve this answer














                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer








                                                                                                                                edited 48 mins ago

























                                                                                                                                answered 3 hours ago









                                                                                                                                ElPedroElPedro

                                                                                                                                3,4831023




                                                                                                                                3,4831023






















                                                                                                                                    Mr Anderson is a new contributor. Be nice, and check out our Code of Conduct.










                                                                                                                                    draft saved

                                                                                                                                    draft discarded


















                                                                                                                                    Mr Anderson is a new contributor. Be nice, and check out our Code of Conduct.













                                                                                                                                    Mr Anderson is a new contributor. Be nice, and check out our Code of Conduct.












                                                                                                                                    Mr Anderson is a new contributor. Be nice, and check out our Code of Conduct.
















                                                                                                                                    If this is an answer to a challenge…




                                                                                                                                    • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                                    • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                                      Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                                    • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                                                                    More generally…




                                                                                                                                    • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                                    • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                                                                                                    draft saved


                                                                                                                                    draft discarded














                                                                                                                                    StackExchange.ready(
                                                                                                                                    function () {
                                                                                                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180821%2fcompare-four-integers-return-word-based-on-maximum%23new-answer', 'question_page');
                                                                                                                                    }
                                                                                                                                    );

                                                                                                                                    Post as a guest















                                                                                                                                    Required, but never shown





















































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown

































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown







                                                                                                                                    Popular posts from this blog

                                                                                                                                    Why does my Macbook overheat and use so much CPU and energy when on YouTube?Why do so many insist on using...

                                                                                                                                    How to prevent page numbers from appearing on glossaries?How to remove a dot and a page number in the...

                                                                                                                                    Puerta de Hutt Referencias Enlaces externos Menú de navegación15°58′00″S 5°42′00″O /...