Am I a Rude Number?












69












$begingroup$


For a while now, I've been running into a problem when counting on my fingers, specifically, that I can only count to ten. My solution to that problem has been to count in binary on my fingers, putting up my thumb for one, my forefinger for two, both thumb and forefinger for three, etc. However, we run into a bit of a problem when we get to the number four. Specifically, it requires us to put up our middle finger, which results in a rather unfortunate gesture, which is not typically accepted in society. This type of number is a rude number. We come to the next rude number at 36, when we raise the thumb on our second hand and the middle finger of our first hand. The definition of a rude number is any number that, under this system of counting, results in us putting up only the middle finger of any hand. Once we pass 1023 (the maximum number reachable on one person, with two hands of five fingers each), assume we continue with a third hand, with additional hands added as required.



Your Task:



Write a program or function that receives an input and outputs a truthy/falsy value based on whether the input is a rude number.



Input:



An integer between 0 and 109 (inclusive).



Output:



A truthy/falsy value that indicates whether the input is a rude number.



Test Cases:



Input:    Output:
0 ---> falsy
3 ---> falsy
4 ---> truthy
25 ---> falsy
36 ---> truthy
127 ---> falsy
131 ---> truthy


Scoring:



This is code-golf, so the lowest score in bytes wins.










share|improve this question











$endgroup$








  • 42




    $begingroup$
    assume we continue with a third hand, When it comes to being rude, teamwork makes the dream work.
    $endgroup$
    – Veskah
    Feb 27 at 3:24






  • 5




    $begingroup$
    @Veskah turns out that for the bounds of the question, you only need 3 people to make any given number. Sure beats the old kind of counting on fingers.
    $endgroup$
    – Gryphon
    Feb 27 at 3:26






  • 12




    $begingroup$
    It's worse if you're British - 6 is rude too then!
    $endgroup$
    – Matthew
    Feb 27 at 7:07






  • 1




    $begingroup$
    Is it OK to take input in a different base than 10?
    $endgroup$
    – wastl
    Feb 27 at 20:08






  • 1




    $begingroup$
    5 seems fairly rude too. Not sure anyone would say "Oh she had her thumb out, that's perfectly polite"
    $endgroup$
    – ale10ander
    Mar 1 at 1:43
















69












$begingroup$


For a while now, I've been running into a problem when counting on my fingers, specifically, that I can only count to ten. My solution to that problem has been to count in binary on my fingers, putting up my thumb for one, my forefinger for two, both thumb and forefinger for three, etc. However, we run into a bit of a problem when we get to the number four. Specifically, it requires us to put up our middle finger, which results in a rather unfortunate gesture, which is not typically accepted in society. This type of number is a rude number. We come to the next rude number at 36, when we raise the thumb on our second hand and the middle finger of our first hand. The definition of a rude number is any number that, under this system of counting, results in us putting up only the middle finger of any hand. Once we pass 1023 (the maximum number reachable on one person, with two hands of five fingers each), assume we continue with a third hand, with additional hands added as required.



Your Task:



Write a program or function that receives an input and outputs a truthy/falsy value based on whether the input is a rude number.



Input:



An integer between 0 and 109 (inclusive).



Output:



A truthy/falsy value that indicates whether the input is a rude number.



Test Cases:



Input:    Output:
0 ---> falsy
3 ---> falsy
4 ---> truthy
25 ---> falsy
36 ---> truthy
127 ---> falsy
131 ---> truthy


Scoring:



This is code-golf, so the lowest score in bytes wins.










share|improve this question











$endgroup$








  • 42




    $begingroup$
    assume we continue with a third hand, When it comes to being rude, teamwork makes the dream work.
    $endgroup$
    – Veskah
    Feb 27 at 3:24






  • 5




    $begingroup$
    @Veskah turns out that for the bounds of the question, you only need 3 people to make any given number. Sure beats the old kind of counting on fingers.
    $endgroup$
    – Gryphon
    Feb 27 at 3:26






  • 12




    $begingroup$
    It's worse if you're British - 6 is rude too then!
    $endgroup$
    – Matthew
    Feb 27 at 7:07






  • 1




    $begingroup$
    Is it OK to take input in a different base than 10?
    $endgroup$
    – wastl
    Feb 27 at 20:08






  • 1




    $begingroup$
    5 seems fairly rude too. Not sure anyone would say "Oh she had her thumb out, that's perfectly polite"
    $endgroup$
    – ale10ander
    Mar 1 at 1:43














69












69








69


6



$begingroup$


For a while now, I've been running into a problem when counting on my fingers, specifically, that I can only count to ten. My solution to that problem has been to count in binary on my fingers, putting up my thumb for one, my forefinger for two, both thumb and forefinger for three, etc. However, we run into a bit of a problem when we get to the number four. Specifically, it requires us to put up our middle finger, which results in a rather unfortunate gesture, which is not typically accepted in society. This type of number is a rude number. We come to the next rude number at 36, when we raise the thumb on our second hand and the middle finger of our first hand. The definition of a rude number is any number that, under this system of counting, results in us putting up only the middle finger of any hand. Once we pass 1023 (the maximum number reachable on one person, with two hands of five fingers each), assume we continue with a third hand, with additional hands added as required.



Your Task:



Write a program or function that receives an input and outputs a truthy/falsy value based on whether the input is a rude number.



Input:



An integer between 0 and 109 (inclusive).



Output:



A truthy/falsy value that indicates whether the input is a rude number.



Test Cases:



Input:    Output:
0 ---> falsy
3 ---> falsy
4 ---> truthy
25 ---> falsy
36 ---> truthy
127 ---> falsy
131 ---> truthy


Scoring:



This is code-golf, so the lowest score in bytes wins.










share|improve this question











$endgroup$




For a while now, I've been running into a problem when counting on my fingers, specifically, that I can only count to ten. My solution to that problem has been to count in binary on my fingers, putting up my thumb for one, my forefinger for two, both thumb and forefinger for three, etc. However, we run into a bit of a problem when we get to the number four. Specifically, it requires us to put up our middle finger, which results in a rather unfortunate gesture, which is not typically accepted in society. This type of number is a rude number. We come to the next rude number at 36, when we raise the thumb on our second hand and the middle finger of our first hand. The definition of a rude number is any number that, under this system of counting, results in us putting up only the middle finger of any hand. Once we pass 1023 (the maximum number reachable on one person, with two hands of five fingers each), assume we continue with a third hand, with additional hands added as required.



Your Task:



Write a program or function that receives an input and outputs a truthy/falsy value based on whether the input is a rude number.



Input:



An integer between 0 and 109 (inclusive).



Output:



A truthy/falsy value that indicates whether the input is a rude number.



Test Cases:



Input:    Output:
0 ---> falsy
3 ---> falsy
4 ---> truthy
25 ---> falsy
36 ---> truthy
127 ---> falsy
131 ---> truthy


Scoring:



This is code-golf, so the lowest score in bytes wins.







code-golf number decision-problem






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 27 at 17:35









Glorfindel

199119




199119










asked Feb 27 at 3:21









GryphonGryphon

3,51912165




3,51912165








  • 42




    $begingroup$
    assume we continue with a third hand, When it comes to being rude, teamwork makes the dream work.
    $endgroup$
    – Veskah
    Feb 27 at 3:24






  • 5




    $begingroup$
    @Veskah turns out that for the bounds of the question, you only need 3 people to make any given number. Sure beats the old kind of counting on fingers.
    $endgroup$
    – Gryphon
    Feb 27 at 3:26






  • 12




    $begingroup$
    It's worse if you're British - 6 is rude too then!
    $endgroup$
    – Matthew
    Feb 27 at 7:07






  • 1




    $begingroup$
    Is it OK to take input in a different base than 10?
    $endgroup$
    – wastl
    Feb 27 at 20:08






  • 1




    $begingroup$
    5 seems fairly rude too. Not sure anyone would say "Oh she had her thumb out, that's perfectly polite"
    $endgroup$
    – ale10ander
    Mar 1 at 1:43














  • 42




    $begingroup$
    assume we continue with a third hand, When it comes to being rude, teamwork makes the dream work.
    $endgroup$
    – Veskah
    Feb 27 at 3:24






  • 5




    $begingroup$
    @Veskah turns out that for the bounds of the question, you only need 3 people to make any given number. Sure beats the old kind of counting on fingers.
    $endgroup$
    – Gryphon
    Feb 27 at 3:26






  • 12




    $begingroup$
    It's worse if you're British - 6 is rude too then!
    $endgroup$
    – Matthew
    Feb 27 at 7:07






  • 1




    $begingroup$
    Is it OK to take input in a different base than 10?
    $endgroup$
    – wastl
    Feb 27 at 20:08






  • 1




    $begingroup$
    5 seems fairly rude too. Not sure anyone would say "Oh she had her thumb out, that's perfectly polite"
    $endgroup$
    – ale10ander
    Mar 1 at 1:43








42




42




$begingroup$
assume we continue with a third hand, When it comes to being rude, teamwork makes the dream work.
$endgroup$
– Veskah
Feb 27 at 3:24




$begingroup$
assume we continue with a third hand, When it comes to being rude, teamwork makes the dream work.
$endgroup$
– Veskah
Feb 27 at 3:24




5




5




$begingroup$
@Veskah turns out that for the bounds of the question, you only need 3 people to make any given number. Sure beats the old kind of counting on fingers.
$endgroup$
– Gryphon
Feb 27 at 3:26




$begingroup$
@Veskah turns out that for the bounds of the question, you only need 3 people to make any given number. Sure beats the old kind of counting on fingers.
$endgroup$
– Gryphon
Feb 27 at 3:26




12




12




$begingroup$
It's worse if you're British - 6 is rude too then!
$endgroup$
– Matthew
Feb 27 at 7:07




$begingroup$
It's worse if you're British - 6 is rude too then!
$endgroup$
– Matthew
Feb 27 at 7:07




1




1




$begingroup$
Is it OK to take input in a different base than 10?
$endgroup$
– wastl
Feb 27 at 20:08




$begingroup$
Is it OK to take input in a different base than 10?
$endgroup$
– wastl
Feb 27 at 20:08




1




1




$begingroup$
5 seems fairly rude too. Not sure anyone would say "Oh she had her thumb out, that's perfectly polite"
$endgroup$
– ale10ander
Mar 1 at 1:43




$begingroup$
5 seems fairly rude too. Not sure anyone would say "Oh she had her thumb out, that's perfectly polite"
$endgroup$
– ale10ander
Mar 1 at 1:43










35 Answers
35






active

oldest

votes













1 2
next












28












$begingroup$


APL (dzaima/APL), 5 bytes





4∊32⊤


Try it online!



4∊ is 4 a member of



32⊤ to-base-32?






share|improve this answer











$endgroup$













  • $begingroup$
    s/bytes/characters though?
    $endgroup$
    – tripleee
    Feb 27 at 10:34










  • $begingroup$
    @tripleee Thanks, added.
    $endgroup$
    – Adám
    Feb 27 at 11:30



















14












$begingroup$

Regex (ECMAScript), 37 bytes



Input is in unary, as the length of a string of xs.



^((?=(x+)(2{31}x*))3)*(x{32})*x{4}$



Try it online!



^
(
(?=(x+)(2{31}x*)) # 2 = floor(tail / 32); 3 = tool to make tail = 2
3 # tail = 2
)* # Loop the above as many times as necessary to make
# the below match
(x{32})*x{4}$ # Assert that tail % 32 == 4





share|improve this answer











$endgroup$









  • 13




    $begingroup$
    I thought I knew regex, but apparently not.
    $endgroup$
    – CT Hall
    Feb 28 at 4:16



















14












$begingroup$


JavaScript (SpiderMonkey), 23 bytes





f=x=>x&&x%32==4|f(x>>5)


Try it online!



This is a trivial solution, you just want to convert to base 32 and check if there is a 4 in it.






JavaScript (SpiderMonkey), 26 bytes





x=>x.toString(32).match(4)


Try it online!



It's interesting that /4/.test(...) cost one more byte than ....match(4).






share|improve this answer











$endgroup$





















    10












    $begingroup$


    Japt, 5 bytes



    sH ø4


    Try it online!



    Explanation



          // Implicit input
    sH // To a base-H (=32) string
    ø // Contains
    4 // 4 (JavaScript interprets this as a string)





    share|improve this answer









    $endgroup$





















      8












      $begingroup$

      APL+WIN, 10 bytes



      Prompts for input of integer



      4∊(6⍴32)⊤⎕


      Noting six hands are required to represent 10^9 converts to vector of 6 elements of the base 32 representation and checks if a 4 exists in any element.






      share|improve this answer









      $endgroup$





















        7












        $begingroup$

        Ruby, 36 19 bytes





        ->n{n.to_s(32)[?4]}


        Try it online!



        Saved 17 bytes with @tsh's method.






        share|improve this answer











        $endgroup$













        • $begingroup$
          This returns true for 2207, which has a binary representation of 100010011111
          $endgroup$
          – Embodiment of Ignorance
          Feb 27 at 4:10










        • $begingroup$
          @EmbodimentofIgnorance That is the correct result, is it not? The second hand is 00100.
          $endgroup$
          – Doorknob
          Feb 27 at 4:16










        • $begingroup$
          I don't speak Ruby. But why not ->n{n.to_s(32)=~/4/}?
          $endgroup$
          – tsh
          Feb 27 at 4:19








        • 1




          $begingroup$
          @tsh because I'm not as clever as you :)
          $endgroup$
          – Doorknob
          Feb 27 at 4:23










        • $begingroup$
          Forgive me if I'm not understanding the question, but isn't the first hand of 2207 10001, the second 00111, and the third 11? None of them have their middle finger only up
          $endgroup$
          – Embodiment of Ignorance
          Feb 27 at 4:28



















        6












        $begingroup$


        Perl 6, 16 bytes





        {.base(32)~~/4/}


        Try it online!



        Checks if there is a 4 in the base 32 representation of the number. Returns either Nil as false or a Match containing a 4.



        You can prove this by the fact that $2^5 = 32$ so each digit is the state of each hand.






        share|improve this answer









        $endgroup$





















          6












          $begingroup$


          Python 2, 34 32 bytes





          f=lambda a:a%32==4or a>0<f(a/32)


          Try it online!



          2 bytes thanks to tsh






          share|improve this answer











          $endgroup$









          • 1




            $begingroup$
            :| you can edit posts, you know that right
            $endgroup$
            – ASCII-only
            Feb 27 at 7:37










          • $begingroup$
            Yes; I know. It was an accident! An accident, I tell ya!
            $endgroup$
            – Chas Brown
            Feb 27 at 8:52










          • $begingroup$
            @tsh Oh nice, forgot that shortcircuits
            $endgroup$
            – ASCII-only
            Feb 27 at 10:24



















          4












          $begingroup$


          Julia 1.0, 25 bytes





          f(n)=n%32==4||n>0<f(n>>5)


          Try it online!




          Julia 1.0, 26 bytes



          Alternative that is 1 character shorter, but 1 byte longer, too bad that takes 3 bytes in unicode.



          n->'4'∈string(n,base=32)


          Try it online!






          share|improve this answer











          $endgroup$













          • $begingroup$
            could you use n->n%32... for your first answer for 2 bytes shorter?
            $endgroup$
            – Giuseppe
            Feb 28 at 22:48










          • $begingroup$
            @Giuseppe, unfortunately no, that function is recursive.
            $endgroup$
            – Kirill L.
            Mar 1 at 7:34



















          4












          $begingroup$


          05AB1E, 5 bytes



          32B4å


          Port of @Adám's APL (dzaima/APL) answer.



          Try it online or verify all test cases.



          Explanation:





          32B    # Convert the (implicit) input to Base-32
          4å # And check if it contains a 4
          # (output the result implicitly)





          share|improve this answer









          $endgroup$









          • 1




            $begingroup$
            Too bad is 36, not 32.
            $endgroup$
            – Magic Octopus Urn
            Feb 28 at 19:51



















          4












          $begingroup$


          Catholicon, 4 bytes



          ǔ?QǑ


          Takes a number as a base-256 string.



          Try it online!



          Test suite






          share|improve this answer











          $endgroup$









          • 2




            $begingroup$
            Hm, if this is allowed, then is it allowed to accept numbers in base 32 instead?
            $endgroup$
            – recursive
            Feb 27 at 19:47










          • $begingroup$
            @recursive You can surround the numbers in << and >> and it allows for numbers greater than 255 in those, as shown in the test suite.
            $endgroup$
            – Okx
            Feb 28 at 13:11






          • 1




            $begingroup$
            It was intended as a question about the challenge but it wasn't very clear.
            $endgroup$
            – recursive
            Feb 28 at 15:44



















          4












          $begingroup$


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





          n=>{for(;n>0;n/=n%32==4?0:32);}


          Outputs by throwing an exception. The way you convert one number from decimal to another base is to divide the decimal number by that base repeatedly and take the remainder as a digit. That is what we do, and we check if any of the digits have a value of 4 in base-32;



          Try it online!






          share|improve this answer











          $endgroup$













          • $begingroup$
            27? as a bonus it doesn't output in a weird way
            $endgroup$
            – ASCII-only
            Feb 27 at 6:13






          • 1




            $begingroup$
            also what is tplig
            $endgroup$
            – ASCII-only
            Feb 27 at 6:15










          • $begingroup$
            @ASCII-only n>31 -> n>0
            $endgroup$
            – tsh
            Feb 27 at 6:17










          • $begingroup$
            25 bytes
            $endgroup$
            – Kevin Cruijssen
            Feb 27 at 12:57






          • 1




            $begingroup$
            Whether or not a program halts is not an allowed output method. Output via exception is allowed.
            $endgroup$
            – Deadcode
            Feb 28 at 22:58



















          4












          $begingroup$

          x86 Machine Code, 17 bytes



          6A 20 59 85 C0 74 09 99 F7 F9 83 FA 04 75 F4 91 C3


          The above bytes define a function that takes the number as input in the EAX register, and returns the result as a Boolean value in the EAX register (EAX == 0 if the input is not a rude number; EAX != 0 if the input is a rude number).



          In human-readable assembly mnemonics:



          ; Determines whether the specified number is a "rude" number.
          ; Input: The number to check, in EAX
          ; Output: The Boolean result, in EAX (non-zero if rude; zero otherwise)
          ; Clobbers: ECX, EDX
          IsRudeNumber:
          push 32 ; standard golfing way to enregister a constant value
          pop ecx ; / (in this case: ECX <= 32)
          CheckNext:
          test eax, eax ; if EAX == 0, jump to the end and return EAX (== 0)
          jz TheEnd ; / otherwise, fall through and keep executing
          cdq ; zero-out EDX because EAX is unsigned (shorter than XOR)
          idiv ecx ; EAX <= (EAX / 32)
          ; EDX <= (EAX % 32)
          cmp edx, 4 ; if EDX != 4, jump back to the start of the loop
          jne CheckNext ; / otherwise, fall through and keep executing
          xchg eax, ecx ; store ECX (== 32, a non-zero value) in EAX
          TheEnd:
          ret ; return, with result in EAX


          Try it online!






          share|improve this answer









          $endgroup$









          • 1




            $begingroup$
            Interesting idea to use idiv, though. I don't see any incremental improvements to this. But see my answer : 14 bytes for a shift loop that uses MOV/AND/SUB/JZ to check the low 5 bits for rudeness.
            $endgroup$
            – Peter Cordes
            Mar 4 at 0:25





















          3












          $begingroup$


          J, 12 bytes



          4 e.32#.inv]


          Try it online!






          share|improve this answer









          $endgroup$





















            3












            $begingroup$


            R, 50 48 bytes





            any(2^(0:4)%*%matrix(scan()%/%2^(0:34)%%2,5)==4)


            Try it online!



            Uses a neat matrix-based approach now (courtesy of @Giueseppe). It generates a 5x7 matrix of bits, converts this to a series of base 32 integers, and checks for any 4s.






            share|improve this answer











            $endgroup$













            • $begingroup$
              @Giuseppe Oops, completely missed that. Should work now, though disappointingly 19 bytes longer. I don't think there's an inverse function to strtoi other than for hexadecimal and octal in base R
              $endgroup$
              – Nick Kennedy
              Feb 28 at 17:45










            • $begingroup$
              48 bytes with some matrix magic. I believe the bit conversion is longer than intToBits but then we can work with ints instead of raw which ends up saving a byte -- see for instance this with intToBits
              $endgroup$
              – Giuseppe
              Feb 28 at 18:04












            • $begingroup$
              @Giuseppe it's a completely different (and neat) solution to mine - do you want me to update mine or you post your own?
              $endgroup$
              – Nick Kennedy
              Feb 28 at 18:18










            • $begingroup$
              you're free to take it. :-)
              $endgroup$
              – Giuseppe
              Feb 28 at 18:24






            • 1




              $begingroup$
              of course, porting one of the many answers that tests for the presence of a digit 4 in a base-32 number is, oh, 29 bytes.
              $endgroup$
              – Giuseppe
              Feb 28 at 22:46



















            2












            $begingroup$


            Python 3, 43 bytes



            Checks every 5-bit chunk to see if it is rude (equal to 4).



            lambda n:any(n>>5*i&31==4for i in range(n))


            Try it online!






            share|improve this answer











            $endgroup$













            • $begingroup$
              *5-bit chunk...
              $endgroup$
              – ASCII-only
              Feb 27 at 7:38



















            2












            $begingroup$


            C (gcc), 34 bytes





            f(i){return i?i&31^4?f(i/32):1:0;}


            Try it online!






            share|improve this answer









            $endgroup$













            • $begingroup$
              32 bytes by rearranging the expression.
              $endgroup$
              – Arnauld
              Feb 27 at 10:11






            • 3




              $begingroup$
              or 25 bytes by abusing the way gcc is compiling this.
              $endgroup$
              – Arnauld
              Feb 27 at 10:11



















            2












            $begingroup$


            Charcoal, 6 bytes



            №⍘N³²4


            Try it online! Link is to verbose version of code. Outputs -s according to how rude the number is. Explanation:



              N     Input as a number
            ⍘ Convert to base as a string
            ³² Literal 32
            № Count occurrences of
            4 Literal string `4`


            I use string base conversion to avoid having to separate the numeric literals for 32 and 4.






            share|improve this answer









            $endgroup$





















              2












              $begingroup$


              Tidy, 18 bytes



              {x:4∈base(32,x)}


              Try it online! Checks if 4 is an element of base(32,x) (base conversion).






              share|improve this answer









              $endgroup$





















                2












                $begingroup$


                Haskell, 31 bytes





                elem 9.(mapM(:[6..36])[0..5]!!)


                Try it online!






                share|improve this answer









                $endgroup$





















                  2












                  $begingroup$

                  ES6, 31 30 bytes



                  a=b=>b.toString(32).match(/4/)


                  Feel free to say ideas on how to reduce this further, if any.






                  share|improve this answer










                  New contributor




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






                  $endgroup$













                  • $begingroup$
                    Welcome to PPCG!
                    $endgroup$
                    – Laikoni
                    Feb 28 at 19:23










                  • $begingroup$
                    You don't need to count the name of your function, and although I think you can save a byte by using test, you can actually save two bytes by matching against 4 as a number and letting match convert that into a string and then a RegExp for you.
                    $endgroup$
                    – Neil
                    Mar 1 at 0:53



















                  2












                  $begingroup$


                  Cubix, 26 bytes



                  u!@-W14;OIS%/;;,p;?wO@u/s


                  Try it online!



                  Wraps onto a cube with edge length 3 as follows



                        u ! @
                  - W 1
                  4 ; O
                  I S % / ; ; , p ; ? w
                  O @ u / s . . . . . . .
                  . . . . . . . . . . . .
                  . . .
                  . . .
                  . . .


                  Watch it run



                  A fairly basic implementation, without all the redirects it does :





                  • IS initiates the program by pushing the input and 32 to the stack


                  • %4-! gets the remainder and checks if it is 4 by subtraction


                  • 1O@ output 1 if it was 4 and halt


                  • ;;, clean up the stack and do integer divide


                  • p;? clean up bottom of the stack and check div result for 0


                  • O@ if div result zero output and halt


                  • s swap the top of stack and start back at step 2 above






                  share|improve this answer









                  $endgroup$





















                    2












                    $begingroup$


                    MATL, 8 bytes



                    32YA52=a


                    Try it online!






                    share|improve this answer











                    $endgroup$













                    • $begingroup$
                      @Luis I can definitely drop the G (not sure why I included it in the first place) but that's only one byte (thanks for spotting that!). Changing 32YA52 to 32_YA4 is the same number of bytes right?
                      $endgroup$
                      – Sanchises
                      Mar 1 at 7:06












                    • $begingroup$
                      Ah, yes, I can't count
                      $endgroup$
                      – Luis Mendo
                      Mar 1 at 10:26






                    • 2




                      $begingroup$
                      @Luis Count? Who needs to count when you can '32_YA4'n'32YA52'n-
                      $endgroup$
                      – Sanchises
                      Mar 1 at 11:56



















                    1












                    $begingroup$


                    Retina 0.8.2, 31 bytes



                    .+
                    $*
                    +`(1+)1{31}
                    $1;
                    b1111b


                    Try it online! Link includes test cases. Outputs zero unless the number is rude. Works by converting the input to unary and then to unary-encoded base 32 and counting the number of 4s in the result.






                    share|improve this answer









                    $endgroup$





















                      1












                      $begingroup$

                      Java 8, 40 33 bytes





                      n->n.toString(n,32).contains("4")


                      Port of @Adám's APL (dzaima/APL) answer.



                      Try it online.



                      Explanation:



                      n->                 // Method with Integer parameter and boolean return-type
                      n.toString(n,32) // Convert the input to a base-32 String
                      .contains("4") // And check if it contains a "4"





                      share|improve this answer











                      $endgroup$





















                        1












                        $begingroup$

                        Batch, 77 45 bytes



                        @cmd/cset/a"m=34636833,n=%1^m*4,(n-m)&~n&m*16


                        Based on these bit twiddling hacks. Explanation: Only 6 hands need to be checked due to the limited range (30 bits) of the input that's required to be supported. The magic number m is equivalent to 111111 in base 32, so that the first operation toggles the rude bits in the input number. It then remains to find which of the 6 hands is now zero.






                        share|improve this answer











                        $endgroup$





















                          1












                          $begingroup$


                          ><>, 28 bytes



                          Outputs 4 for rude numbers throws an exception for non-rude numbers.



                          :1(?^:" ":
                          ,&-v?=4:%&/
                          ;n<


                          Try it online!






                          share|improve this answer











                          $endgroup$









                          • 1




                            $begingroup$
                            An exception is acceptable, the C# answer does it
                            $endgroup$
                            – ASCII-only
                            Mar 1 at 11:22



















                          1












                          $begingroup$


                          Wolfram Language (Mathematica), 37 bytes 36 bytes 29 bytes



                          -2 bytes by Jonathan Frech



                          #~IntegerDigits~32~MemberQ~4&


                          Try it online!



                          31-byte solution:



                          MemberQ[IntegerDigits[#,32],4]&


                          Try it online!






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            Hello and welcome to PPCG. As it stands, your expression is a single Boolean value. Please fix your answer to either be a full program or a function (...#...& is often used in Mathematica).
                            $endgroup$
                            – Jonathan Frech
                            Feb 27 at 9:22










                          • $begingroup$
                            Hello. Is this what you mean?
                            $endgroup$
                            – Rainer Glüge
                            Feb 27 at 9:32










                          • $begingroup$
                            pls use tio.run/#mathematica instead of W|A to make sure it's valid mathematica code :P and you don't need the [n] at the end, just the &. Also since posts have edit history, it's fine to leave out previous entries, and the convention for old scores is <s>40</s> <s>36</s>
                            $endgroup$
                            – ASCII-only
                            Feb 27 at 10:22












                          • $begingroup$
                            Yes. This is what I meant. 29 bytes.
                            $endgroup$
                            – Jonathan Frech
                            Feb 27 at 13:17










                          • $begingroup$
                            I guess I have to get used to the functional programming style.
                            $endgroup$
                            – Rainer Glüge
                            Feb 27 at 13:34



















                          1












                          $begingroup$

                          x86 machine code, 14 bytes



                          (same machine code works in 16-bit, 32-bit, and 64-bit. In 16-bit mode, it uses AX and DI instead of EAX and EDI in 32 and 64-bit mode.)



                          Algorithm: check low 5 bits with x & 31 == 4, then right-shift by 5 bits, and repeat if the shift result is non-zero.



                          Callable from C with char isrude(unsigned n); according to the x86-64 System V calling convention. 0 is truthy, non-0 is falsy (this is asm, not C1).



                           line   addr    code bytes
                          num
                          1 ; input: number in EDI
                          2 ; output: integer result in AL: 0 -> rude, non-zero non-rude
                          3 ; clobbers: RDI
                          4 isrude:
                          5 .check_low_bitgroup:
                          6 00000000 89F8 mov eax, edi
                          7 00000002 241F and al, 31 ; isolate low 5 bits
                          8 00000004 2C04 sub al, 4 ; like cmp but leaves AL 0 or non-zero
                          9 00000006 7405 jz .rude ; if (al & 31 == 4) return 0;
                          10
                          11 00000008 C1EF05 shr edi, 5
                          12 0000000B 75F3 jnz .check_low_bitgroup
                          13 ;; fall through to here is only possible if AL is non-zero
                          14 .rude:
                          15 0000000D C3 ret


                          16 0E size: db $ - isrude


                          This takes advantage of the short-form op al, imm8 encoding for AND and SUB. I could have used XOR al,4 to produce 0 on equality, but SUB is faster because it can macro-fuse with JZ into a single sub-and-branch uop on Sandybridge-family.



                          Fun fact: using the flag-result of a shift by more than 1 will be slow on P6-family (front-end stalls until the shift retires), but that's fine.





                          Footnote 1: This is an assembly language function, and x86 asm has both jz and jnz, so as per meta I can choose either way. I'm not intending this to match C truthy/falsy.



                          It happened to be convenient to return in AL instead of EFLAGS, so we can describe the function to a C compiler without a wrapper, but my choice of truthy/falsy isn't constrained by using a C caller to test it.






                          share|improve this answer









                          $endgroup$





















                            1












                            $begingroup$

                            Java 8, 28 22 21 bytes





                            n->n%32==4|n>>5%32==4


                            Inspired by @kevin-cruijssen's answer. Only works for 2 hands.



                            Try it online!



                            Explanation:



                            n->                 // Method with int parameter and boolean return-type
                            n%32 // Only consider right 5 bytes (fingers)
                            ==4 // Middle finger
                            | ... n>>5 // Repeat with shifted bits for other hand





                            share|improve this answer










                            New contributor




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






                            $endgroup$

















                              1 2
                              next



                              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
                              });


                              }
                              });














                              draft saved

                              draft discarded


















                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f180481%2fam-i-a-rude-number%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown

























                              35 Answers
                              35






                              active

                              oldest

                              votes








                              35 Answers
                              35






                              active

                              oldest

                              votes









                              active

                              oldest

                              votes






                              active

                              oldest

                              votes








                              1 2
                              next










                              28












                              $begingroup$


                              APL (dzaima/APL), 5 bytes





                              4∊32⊤


                              Try it online!



                              4∊ is 4 a member of



                              32⊤ to-base-32?






                              share|improve this answer











                              $endgroup$













                              • $begingroup$
                                s/bytes/characters though?
                                $endgroup$
                                – tripleee
                                Feb 27 at 10:34










                              • $begingroup$
                                @tripleee Thanks, added.
                                $endgroup$
                                – Adám
                                Feb 27 at 11:30
















                              28












                              $begingroup$


                              APL (dzaima/APL), 5 bytes





                              4∊32⊤


                              Try it online!



                              4∊ is 4 a member of



                              32⊤ to-base-32?






                              share|improve this answer











                              $endgroup$













                              • $begingroup$
                                s/bytes/characters though?
                                $endgroup$
                                – tripleee
                                Feb 27 at 10:34










                              • $begingroup$
                                @tripleee Thanks, added.
                                $endgroup$
                                – Adám
                                Feb 27 at 11:30














                              28












                              28








                              28





                              $begingroup$


                              APL (dzaima/APL), 5 bytes





                              4∊32⊤


                              Try it online!



                              4∊ is 4 a member of



                              32⊤ to-base-32?






                              share|improve this answer











                              $endgroup$




                              APL (dzaima/APL), 5 bytes





                              4∊32⊤


                              Try it online!



                              4∊ is 4 a member of



                              32⊤ to-base-32?







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Feb 27 at 11:30

























                              answered Feb 27 at 5:42









                              AdámAdám

                              28.8k276204




                              28.8k276204












                              • $begingroup$
                                s/bytes/characters though?
                                $endgroup$
                                – tripleee
                                Feb 27 at 10:34










                              • $begingroup$
                                @tripleee Thanks, added.
                                $endgroup$
                                – Adám
                                Feb 27 at 11:30


















                              • $begingroup$
                                s/bytes/characters though?
                                $endgroup$
                                – tripleee
                                Feb 27 at 10:34










                              • $begingroup$
                                @tripleee Thanks, added.
                                $endgroup$
                                – Adám
                                Feb 27 at 11:30
















                              $begingroup$
                              s/bytes/characters though?
                              $endgroup$
                              – tripleee
                              Feb 27 at 10:34




                              $begingroup$
                              s/bytes/characters though?
                              $endgroup$
                              – tripleee
                              Feb 27 at 10:34












                              $begingroup$
                              @tripleee Thanks, added.
                              $endgroup$
                              – Adám
                              Feb 27 at 11:30




                              $begingroup$
                              @tripleee Thanks, added.
                              $endgroup$
                              – Adám
                              Feb 27 at 11:30











                              14












                              $begingroup$

                              Regex (ECMAScript), 37 bytes



                              Input is in unary, as the length of a string of xs.



                              ^((?=(x+)(2{31}x*))3)*(x{32})*x{4}$



                              Try it online!



                              ^
                              (
                              (?=(x+)(2{31}x*)) # 2 = floor(tail / 32); 3 = tool to make tail = 2
                              3 # tail = 2
                              )* # Loop the above as many times as necessary to make
                              # the below match
                              (x{32})*x{4}$ # Assert that tail % 32 == 4





                              share|improve this answer











                              $endgroup$









                              • 13




                                $begingroup$
                                I thought I knew regex, but apparently not.
                                $endgroup$
                                – CT Hall
                                Feb 28 at 4:16
















                              14












                              $begingroup$

                              Regex (ECMAScript), 37 bytes



                              Input is in unary, as the length of a string of xs.



                              ^((?=(x+)(2{31}x*))3)*(x{32})*x{4}$



                              Try it online!



                              ^
                              (
                              (?=(x+)(2{31}x*)) # 2 = floor(tail / 32); 3 = tool to make tail = 2
                              3 # tail = 2
                              )* # Loop the above as many times as necessary to make
                              # the below match
                              (x{32})*x{4}$ # Assert that tail % 32 == 4





                              share|improve this answer











                              $endgroup$









                              • 13




                                $begingroup$
                                I thought I knew regex, but apparently not.
                                $endgroup$
                                – CT Hall
                                Feb 28 at 4:16














                              14












                              14








                              14





                              $begingroup$

                              Regex (ECMAScript), 37 bytes



                              Input is in unary, as the length of a string of xs.



                              ^((?=(x+)(2{31}x*))3)*(x{32})*x{4}$



                              Try it online!



                              ^
                              (
                              (?=(x+)(2{31}x*)) # 2 = floor(tail / 32); 3 = tool to make tail = 2
                              3 # tail = 2
                              )* # Loop the above as many times as necessary to make
                              # the below match
                              (x{32})*x{4}$ # Assert that tail % 32 == 4





                              share|improve this answer











                              $endgroup$



                              Regex (ECMAScript), 37 bytes



                              Input is in unary, as the length of a string of xs.



                              ^((?=(x+)(2{31}x*))3)*(x{32})*x{4}$



                              Try it online!



                              ^
                              (
                              (?=(x+)(2{31}x*)) # 2 = floor(tail / 32); 3 = tool to make tail = 2
                              3 # tail = 2
                              )* # Loop the above as many times as necessary to make
                              # the below match
                              (x{32})*x{4}$ # Assert that tail % 32 == 4






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Feb 28 at 18:26

























                              answered Feb 27 at 4:16









                              DeadcodeDeadcode

                              1,8641420




                              1,8641420








                              • 13




                                $begingroup$
                                I thought I knew regex, but apparently not.
                                $endgroup$
                                – CT Hall
                                Feb 28 at 4:16














                              • 13




                                $begingroup$
                                I thought I knew regex, but apparently not.
                                $endgroup$
                                – CT Hall
                                Feb 28 at 4:16








                              13




                              13




                              $begingroup$
                              I thought I knew regex, but apparently not.
                              $endgroup$
                              – CT Hall
                              Feb 28 at 4:16




                              $begingroup$
                              I thought I knew regex, but apparently not.
                              $endgroup$
                              – CT Hall
                              Feb 28 at 4:16











                              14












                              $begingroup$


                              JavaScript (SpiderMonkey), 23 bytes





                              f=x=>x&&x%32==4|f(x>>5)


                              Try it online!



                              This is a trivial solution, you just want to convert to base 32 and check if there is a 4 in it.






                              JavaScript (SpiderMonkey), 26 bytes





                              x=>x.toString(32).match(4)


                              Try it online!



                              It's interesting that /4/.test(...) cost one more byte than ....match(4).






                              share|improve this answer











                              $endgroup$


















                                14












                                $begingroup$


                                JavaScript (SpiderMonkey), 23 bytes





                                f=x=>x&&x%32==4|f(x>>5)


                                Try it online!



                                This is a trivial solution, you just want to convert to base 32 and check if there is a 4 in it.






                                JavaScript (SpiderMonkey), 26 bytes





                                x=>x.toString(32).match(4)


                                Try it online!



                                It's interesting that /4/.test(...) cost one more byte than ....match(4).






                                share|improve this answer











                                $endgroup$
















                                  14












                                  14








                                  14





                                  $begingroup$


                                  JavaScript (SpiderMonkey), 23 bytes





                                  f=x=>x&&x%32==4|f(x>>5)


                                  Try it online!



                                  This is a trivial solution, you just want to convert to base 32 and check if there is a 4 in it.






                                  JavaScript (SpiderMonkey), 26 bytes





                                  x=>x.toString(32).match(4)


                                  Try it online!



                                  It's interesting that /4/.test(...) cost one more byte than ....match(4).






                                  share|improve this answer











                                  $endgroup$




                                  JavaScript (SpiderMonkey), 23 bytes





                                  f=x=>x&&x%32==4|f(x>>5)


                                  Try it online!



                                  This is a trivial solution, you just want to convert to base 32 and check if there is a 4 in it.






                                  JavaScript (SpiderMonkey), 26 bytes





                                  x=>x.toString(32).match(4)


                                  Try it online!



                                  It's interesting that /4/.test(...) cost one more byte than ....match(4).







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited 2 days ago

























                                  answered Feb 27 at 4:17









                                  tshtsh

                                  9,32511652




                                  9,32511652























                                      10












                                      $begingroup$


                                      Japt, 5 bytes



                                      sH ø4


                                      Try it online!



                                      Explanation



                                            // Implicit input
                                      sH // To a base-H (=32) string
                                      ø // Contains
                                      4 // 4 (JavaScript interprets this as a string)





                                      share|improve this answer









                                      $endgroup$


















                                        10












                                        $begingroup$


                                        Japt, 5 bytes



                                        sH ø4


                                        Try it online!



                                        Explanation



                                              // Implicit input
                                        sH // To a base-H (=32) string
                                        ø // Contains
                                        4 // 4 (JavaScript interprets this as a string)





                                        share|improve this answer









                                        $endgroup$
















                                          10












                                          10








                                          10





                                          $begingroup$


                                          Japt, 5 bytes



                                          sH ø4


                                          Try it online!



                                          Explanation



                                                // Implicit input
                                          sH // To a base-H (=32) string
                                          ø // Contains
                                          4 // 4 (JavaScript interprets this as a string)





                                          share|improve this answer









                                          $endgroup$




                                          Japt, 5 bytes



                                          sH ø4


                                          Try it online!



                                          Explanation



                                                // Implicit input
                                          sH // To a base-H (=32) string
                                          ø // Contains
                                          4 // 4 (JavaScript interprets this as a string)






                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Feb 27 at 4:20









                                          ASCII-onlyASCII-only

                                          4,3081238




                                          4,3081238























                                              8












                                              $begingroup$

                                              APL+WIN, 10 bytes



                                              Prompts for input of integer



                                              4∊(6⍴32)⊤⎕


                                              Noting six hands are required to represent 10^9 converts to vector of 6 elements of the base 32 representation and checks if a 4 exists in any element.






                                              share|improve this answer









                                              $endgroup$


















                                                8












                                                $begingroup$

                                                APL+WIN, 10 bytes



                                                Prompts for input of integer



                                                4∊(6⍴32)⊤⎕


                                                Noting six hands are required to represent 10^9 converts to vector of 6 elements of the base 32 representation and checks if a 4 exists in any element.






                                                share|improve this answer









                                                $endgroup$
















                                                  8












                                                  8








                                                  8





                                                  $begingroup$

                                                  APL+WIN, 10 bytes



                                                  Prompts for input of integer



                                                  4∊(6⍴32)⊤⎕


                                                  Noting six hands are required to represent 10^9 converts to vector of 6 elements of the base 32 representation and checks if a 4 exists in any element.






                                                  share|improve this answer









                                                  $endgroup$



                                                  APL+WIN, 10 bytes



                                                  Prompts for input of integer



                                                  4∊(6⍴32)⊤⎕


                                                  Noting six hands are required to represent 10^9 converts to vector of 6 elements of the base 32 representation and checks if a 4 exists in any element.







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Feb 27 at 4:45









                                                  GrahamGraham

                                                  2,49678




                                                  2,49678























                                                      7












                                                      $begingroup$

                                                      Ruby, 36 19 bytes





                                                      ->n{n.to_s(32)[?4]}


                                                      Try it online!



                                                      Saved 17 bytes with @tsh's method.






                                                      share|improve this answer











                                                      $endgroup$













                                                      • $begingroup$
                                                        This returns true for 2207, which has a binary representation of 100010011111
                                                        $endgroup$
                                                        – Embodiment of Ignorance
                                                        Feb 27 at 4:10










                                                      • $begingroup$
                                                        @EmbodimentofIgnorance That is the correct result, is it not? The second hand is 00100.
                                                        $endgroup$
                                                        – Doorknob
                                                        Feb 27 at 4:16










                                                      • $begingroup$
                                                        I don't speak Ruby. But why not ->n{n.to_s(32)=~/4/}?
                                                        $endgroup$
                                                        – tsh
                                                        Feb 27 at 4:19








                                                      • 1




                                                        $begingroup$
                                                        @tsh because I'm not as clever as you :)
                                                        $endgroup$
                                                        – Doorknob
                                                        Feb 27 at 4:23










                                                      • $begingroup$
                                                        Forgive me if I'm not understanding the question, but isn't the first hand of 2207 10001, the second 00111, and the third 11? None of them have their middle finger only up
                                                        $endgroup$
                                                        – Embodiment of Ignorance
                                                        Feb 27 at 4:28
















                                                      7












                                                      $begingroup$

                                                      Ruby, 36 19 bytes





                                                      ->n{n.to_s(32)[?4]}


                                                      Try it online!



                                                      Saved 17 bytes with @tsh's method.






                                                      share|improve this answer











                                                      $endgroup$













                                                      • $begingroup$
                                                        This returns true for 2207, which has a binary representation of 100010011111
                                                        $endgroup$
                                                        – Embodiment of Ignorance
                                                        Feb 27 at 4:10










                                                      • $begingroup$
                                                        @EmbodimentofIgnorance That is the correct result, is it not? The second hand is 00100.
                                                        $endgroup$
                                                        – Doorknob
                                                        Feb 27 at 4:16










                                                      • $begingroup$
                                                        I don't speak Ruby. But why not ->n{n.to_s(32)=~/4/}?
                                                        $endgroup$
                                                        – tsh
                                                        Feb 27 at 4:19








                                                      • 1




                                                        $begingroup$
                                                        @tsh because I'm not as clever as you :)
                                                        $endgroup$
                                                        – Doorknob
                                                        Feb 27 at 4:23










                                                      • $begingroup$
                                                        Forgive me if I'm not understanding the question, but isn't the first hand of 2207 10001, the second 00111, and the third 11? None of them have their middle finger only up
                                                        $endgroup$
                                                        – Embodiment of Ignorance
                                                        Feb 27 at 4:28














                                                      7












                                                      7








                                                      7





                                                      $begingroup$

                                                      Ruby, 36 19 bytes





                                                      ->n{n.to_s(32)[?4]}


                                                      Try it online!



                                                      Saved 17 bytes with @tsh's method.






                                                      share|improve this answer











                                                      $endgroup$



                                                      Ruby, 36 19 bytes





                                                      ->n{n.to_s(32)[?4]}


                                                      Try it online!



                                                      Saved 17 bytes with @tsh's method.







                                                      share|improve this answer














                                                      share|improve this answer



                                                      share|improve this answer








                                                      edited Feb 27 at 4:23

























                                                      answered Feb 27 at 3:37









                                                      DoorknobDoorknob

                                                      54.9k17115352




                                                      54.9k17115352












                                                      • $begingroup$
                                                        This returns true for 2207, which has a binary representation of 100010011111
                                                        $endgroup$
                                                        – Embodiment of Ignorance
                                                        Feb 27 at 4:10










                                                      • $begingroup$
                                                        @EmbodimentofIgnorance That is the correct result, is it not? The second hand is 00100.
                                                        $endgroup$
                                                        – Doorknob
                                                        Feb 27 at 4:16










                                                      • $begingroup$
                                                        I don't speak Ruby. But why not ->n{n.to_s(32)=~/4/}?
                                                        $endgroup$
                                                        – tsh
                                                        Feb 27 at 4:19








                                                      • 1




                                                        $begingroup$
                                                        @tsh because I'm not as clever as you :)
                                                        $endgroup$
                                                        – Doorknob
                                                        Feb 27 at 4:23










                                                      • $begingroup$
                                                        Forgive me if I'm not understanding the question, but isn't the first hand of 2207 10001, the second 00111, and the third 11? None of them have their middle finger only up
                                                        $endgroup$
                                                        – Embodiment of Ignorance
                                                        Feb 27 at 4:28


















                                                      • $begingroup$
                                                        This returns true for 2207, which has a binary representation of 100010011111
                                                        $endgroup$
                                                        – Embodiment of Ignorance
                                                        Feb 27 at 4:10










                                                      • $begingroup$
                                                        @EmbodimentofIgnorance That is the correct result, is it not? The second hand is 00100.
                                                        $endgroup$
                                                        – Doorknob
                                                        Feb 27 at 4:16










                                                      • $begingroup$
                                                        I don't speak Ruby. But why not ->n{n.to_s(32)=~/4/}?
                                                        $endgroup$
                                                        – tsh
                                                        Feb 27 at 4:19








                                                      • 1




                                                        $begingroup$
                                                        @tsh because I'm not as clever as you :)
                                                        $endgroup$
                                                        – Doorknob
                                                        Feb 27 at 4:23










                                                      • $begingroup$
                                                        Forgive me if I'm not understanding the question, but isn't the first hand of 2207 10001, the second 00111, and the third 11? None of them have their middle finger only up
                                                        $endgroup$
                                                        – Embodiment of Ignorance
                                                        Feb 27 at 4:28
















                                                      $begingroup$
                                                      This returns true for 2207, which has a binary representation of 100010011111
                                                      $endgroup$
                                                      – Embodiment of Ignorance
                                                      Feb 27 at 4:10




                                                      $begingroup$
                                                      This returns true for 2207, which has a binary representation of 100010011111
                                                      $endgroup$
                                                      – Embodiment of Ignorance
                                                      Feb 27 at 4:10












                                                      $begingroup$
                                                      @EmbodimentofIgnorance That is the correct result, is it not? The second hand is 00100.
                                                      $endgroup$
                                                      – Doorknob
                                                      Feb 27 at 4:16




                                                      $begingroup$
                                                      @EmbodimentofIgnorance That is the correct result, is it not? The second hand is 00100.
                                                      $endgroup$
                                                      – Doorknob
                                                      Feb 27 at 4:16












                                                      $begingroup$
                                                      I don't speak Ruby. But why not ->n{n.to_s(32)=~/4/}?
                                                      $endgroup$
                                                      – tsh
                                                      Feb 27 at 4:19






                                                      $begingroup$
                                                      I don't speak Ruby. But why not ->n{n.to_s(32)=~/4/}?
                                                      $endgroup$
                                                      – tsh
                                                      Feb 27 at 4:19






                                                      1




                                                      1




                                                      $begingroup$
                                                      @tsh because I'm not as clever as you :)
                                                      $endgroup$
                                                      – Doorknob
                                                      Feb 27 at 4:23




                                                      $begingroup$
                                                      @tsh because I'm not as clever as you :)
                                                      $endgroup$
                                                      – Doorknob
                                                      Feb 27 at 4:23












                                                      $begingroup$
                                                      Forgive me if I'm not understanding the question, but isn't the first hand of 2207 10001, the second 00111, and the third 11? None of them have their middle finger only up
                                                      $endgroup$
                                                      – Embodiment of Ignorance
                                                      Feb 27 at 4:28




                                                      $begingroup$
                                                      Forgive me if I'm not understanding the question, but isn't the first hand of 2207 10001, the second 00111, and the third 11? None of them have their middle finger only up
                                                      $endgroup$
                                                      – Embodiment of Ignorance
                                                      Feb 27 at 4:28











                                                      6












                                                      $begingroup$


                                                      Perl 6, 16 bytes





                                                      {.base(32)~~/4/}


                                                      Try it online!



                                                      Checks if there is a 4 in the base 32 representation of the number. Returns either Nil as false or a Match containing a 4.



                                                      You can prove this by the fact that $2^5 = 32$ so each digit is the state of each hand.






                                                      share|improve this answer









                                                      $endgroup$


















                                                        6












                                                        $begingroup$


                                                        Perl 6, 16 bytes





                                                        {.base(32)~~/4/}


                                                        Try it online!



                                                        Checks if there is a 4 in the base 32 representation of the number. Returns either Nil as false or a Match containing a 4.



                                                        You can prove this by the fact that $2^5 = 32$ so each digit is the state of each hand.






                                                        share|improve this answer









                                                        $endgroup$
















                                                          6












                                                          6








                                                          6





                                                          $begingroup$


                                                          Perl 6, 16 bytes





                                                          {.base(32)~~/4/}


                                                          Try it online!



                                                          Checks if there is a 4 in the base 32 representation of the number. Returns either Nil as false or a Match containing a 4.



                                                          You can prove this by the fact that $2^5 = 32$ so each digit is the state of each hand.






                                                          share|improve this answer









                                                          $endgroup$




                                                          Perl 6, 16 bytes





                                                          {.base(32)~~/4/}


                                                          Try it online!



                                                          Checks if there is a 4 in the base 32 representation of the number. Returns either Nil as false or a Match containing a 4.



                                                          You can prove this by the fact that $2^5 = 32$ so each digit is the state of each hand.







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Feb 27 at 4:26









                                                          Jo KingJo King

                                                          24.3k357126




                                                          24.3k357126























                                                              6












                                                              $begingroup$


                                                              Python 2, 34 32 bytes





                                                              f=lambda a:a%32==4or a>0<f(a/32)


                                                              Try it online!



                                                              2 bytes thanks to tsh






                                                              share|improve this answer











                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                :| you can edit posts, you know that right
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 7:37










                                                              • $begingroup$
                                                                Yes; I know. It was an accident! An accident, I tell ya!
                                                                $endgroup$
                                                                – Chas Brown
                                                                Feb 27 at 8:52










                                                              • $begingroup$
                                                                @tsh Oh nice, forgot that shortcircuits
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 10:24
















                                                              6












                                                              $begingroup$


                                                              Python 2, 34 32 bytes





                                                              f=lambda a:a%32==4or a>0<f(a/32)


                                                              Try it online!



                                                              2 bytes thanks to tsh






                                                              share|improve this answer











                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                :| you can edit posts, you know that right
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 7:37










                                                              • $begingroup$
                                                                Yes; I know. It was an accident! An accident, I tell ya!
                                                                $endgroup$
                                                                – Chas Brown
                                                                Feb 27 at 8:52










                                                              • $begingroup$
                                                                @tsh Oh nice, forgot that shortcircuits
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 10:24














                                                              6












                                                              6








                                                              6





                                                              $begingroup$


                                                              Python 2, 34 32 bytes





                                                              f=lambda a:a%32==4or a>0<f(a/32)


                                                              Try it online!



                                                              2 bytes thanks to tsh






                                                              share|improve this answer











                                                              $endgroup$




                                                              Python 2, 34 32 bytes





                                                              f=lambda a:a%32==4or a>0<f(a/32)


                                                              Try it online!



                                                              2 bytes thanks to tsh







                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited Feb 27 at 19:39

























                                                              answered Feb 27 at 6:47









                                                              Chas BrownChas Brown

                                                              4,9941523




                                                              4,9941523








                                                              • 1




                                                                $begingroup$
                                                                :| you can edit posts, you know that right
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 7:37










                                                              • $begingroup$
                                                                Yes; I know. It was an accident! An accident, I tell ya!
                                                                $endgroup$
                                                                – Chas Brown
                                                                Feb 27 at 8:52










                                                              • $begingroup$
                                                                @tsh Oh nice, forgot that shortcircuits
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 10:24














                                                              • 1




                                                                $begingroup$
                                                                :| you can edit posts, you know that right
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 7:37










                                                              • $begingroup$
                                                                Yes; I know. It was an accident! An accident, I tell ya!
                                                                $endgroup$
                                                                – Chas Brown
                                                                Feb 27 at 8:52










                                                              • $begingroup$
                                                                @tsh Oh nice, forgot that shortcircuits
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 10:24








                                                              1




                                                              1




                                                              $begingroup$
                                                              :| you can edit posts, you know that right
                                                              $endgroup$
                                                              – ASCII-only
                                                              Feb 27 at 7:37




                                                              $begingroup$
                                                              :| you can edit posts, you know that right
                                                              $endgroup$
                                                              – ASCII-only
                                                              Feb 27 at 7:37












                                                              $begingroup$
                                                              Yes; I know. It was an accident! An accident, I tell ya!
                                                              $endgroup$
                                                              – Chas Brown
                                                              Feb 27 at 8:52




                                                              $begingroup$
                                                              Yes; I know. It was an accident! An accident, I tell ya!
                                                              $endgroup$
                                                              – Chas Brown
                                                              Feb 27 at 8:52












                                                              $begingroup$
                                                              @tsh Oh nice, forgot that shortcircuits
                                                              $endgroup$
                                                              – ASCII-only
                                                              Feb 27 at 10:24




                                                              $begingroup$
                                                              @tsh Oh nice, forgot that shortcircuits
                                                              $endgroup$
                                                              – ASCII-only
                                                              Feb 27 at 10:24











                                                              4












                                                              $begingroup$


                                                              Julia 1.0, 25 bytes





                                                              f(n)=n%32==4||n>0<f(n>>5)


                                                              Try it online!




                                                              Julia 1.0, 26 bytes



                                                              Alternative that is 1 character shorter, but 1 byte longer, too bad that takes 3 bytes in unicode.



                                                              n->'4'∈string(n,base=32)


                                                              Try it online!






                                                              share|improve this answer











                                                              $endgroup$













                                                              • $begingroup$
                                                                could you use n->n%32... for your first answer for 2 bytes shorter?
                                                                $endgroup$
                                                                – Giuseppe
                                                                Feb 28 at 22:48










                                                              • $begingroup$
                                                                @Giuseppe, unfortunately no, that function is recursive.
                                                                $endgroup$
                                                                – Kirill L.
                                                                Mar 1 at 7:34
















                                                              4












                                                              $begingroup$


                                                              Julia 1.0, 25 bytes





                                                              f(n)=n%32==4||n>0<f(n>>5)


                                                              Try it online!




                                                              Julia 1.0, 26 bytes



                                                              Alternative that is 1 character shorter, but 1 byte longer, too bad that takes 3 bytes in unicode.



                                                              n->'4'∈string(n,base=32)


                                                              Try it online!






                                                              share|improve this answer











                                                              $endgroup$













                                                              • $begingroup$
                                                                could you use n->n%32... for your first answer for 2 bytes shorter?
                                                                $endgroup$
                                                                – Giuseppe
                                                                Feb 28 at 22:48










                                                              • $begingroup$
                                                                @Giuseppe, unfortunately no, that function is recursive.
                                                                $endgroup$
                                                                – Kirill L.
                                                                Mar 1 at 7:34














                                                              4












                                                              4








                                                              4





                                                              $begingroup$


                                                              Julia 1.0, 25 bytes





                                                              f(n)=n%32==4||n>0<f(n>>5)


                                                              Try it online!




                                                              Julia 1.0, 26 bytes



                                                              Alternative that is 1 character shorter, but 1 byte longer, too bad that takes 3 bytes in unicode.



                                                              n->'4'∈string(n,base=32)


                                                              Try it online!






                                                              share|improve this answer











                                                              $endgroup$




                                                              Julia 1.0, 25 bytes





                                                              f(n)=n%32==4||n>0<f(n>>5)


                                                              Try it online!




                                                              Julia 1.0, 26 bytes



                                                              Alternative that is 1 character shorter, but 1 byte longer, too bad that takes 3 bytes in unicode.



                                                              n->'4'∈string(n,base=32)


                                                              Try it online!







                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited Feb 27 at 10:00

























                                                              answered Feb 27 at 9:49









                                                              Kirill L.Kirill L.

                                                              5,0951525




                                                              5,0951525












                                                              • $begingroup$
                                                                could you use n->n%32... for your first answer for 2 bytes shorter?
                                                                $endgroup$
                                                                – Giuseppe
                                                                Feb 28 at 22:48










                                                              • $begingroup$
                                                                @Giuseppe, unfortunately no, that function is recursive.
                                                                $endgroup$
                                                                – Kirill L.
                                                                Mar 1 at 7:34


















                                                              • $begingroup$
                                                                could you use n->n%32... for your first answer for 2 bytes shorter?
                                                                $endgroup$
                                                                – Giuseppe
                                                                Feb 28 at 22:48










                                                              • $begingroup$
                                                                @Giuseppe, unfortunately no, that function is recursive.
                                                                $endgroup$
                                                                – Kirill L.
                                                                Mar 1 at 7:34
















                                                              $begingroup$
                                                              could you use n->n%32... for your first answer for 2 bytes shorter?
                                                              $endgroup$
                                                              – Giuseppe
                                                              Feb 28 at 22:48




                                                              $begingroup$
                                                              could you use n->n%32... for your first answer for 2 bytes shorter?
                                                              $endgroup$
                                                              – Giuseppe
                                                              Feb 28 at 22:48












                                                              $begingroup$
                                                              @Giuseppe, unfortunately no, that function is recursive.
                                                              $endgroup$
                                                              – Kirill L.
                                                              Mar 1 at 7:34




                                                              $begingroup$
                                                              @Giuseppe, unfortunately no, that function is recursive.
                                                              $endgroup$
                                                              – Kirill L.
                                                              Mar 1 at 7:34











                                                              4












                                                              $begingroup$


                                                              05AB1E, 5 bytes



                                                              32B4å


                                                              Port of @Adám's APL (dzaima/APL) answer.



                                                              Try it online or verify all test cases.



                                                              Explanation:





                                                              32B    # Convert the (implicit) input to Base-32
                                                              4å # And check if it contains a 4
                                                              # (output the result implicitly)





                                                              share|improve this answer









                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Too bad is 36, not 32.
                                                                $endgroup$
                                                                – Magic Octopus Urn
                                                                Feb 28 at 19:51
















                                                              4












                                                              $begingroup$


                                                              05AB1E, 5 bytes



                                                              32B4å


                                                              Port of @Adám's APL (dzaima/APL) answer.



                                                              Try it online or verify all test cases.



                                                              Explanation:





                                                              32B    # Convert the (implicit) input to Base-32
                                                              4å # And check if it contains a 4
                                                              # (output the result implicitly)





                                                              share|improve this answer









                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Too bad is 36, not 32.
                                                                $endgroup$
                                                                – Magic Octopus Urn
                                                                Feb 28 at 19:51














                                                              4












                                                              4








                                                              4





                                                              $begingroup$


                                                              05AB1E, 5 bytes



                                                              32B4å


                                                              Port of @Adám's APL (dzaima/APL) answer.



                                                              Try it online or verify all test cases.



                                                              Explanation:





                                                              32B    # Convert the (implicit) input to Base-32
                                                              4å # And check if it contains a 4
                                                              # (output the result implicitly)





                                                              share|improve this answer









                                                              $endgroup$




                                                              05AB1E, 5 bytes



                                                              32B4å


                                                              Port of @Adám's APL (dzaima/APL) answer.



                                                              Try it online or verify all test cases.



                                                              Explanation:





                                                              32B    # Convert the (implicit) input to Base-32
                                                              4å # And check if it contains a 4
                                                              # (output the result implicitly)






                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered Feb 27 at 12:38









                                                              Kevin CruijssenKevin Cruijssen

                                                              39.7k560203




                                                              39.7k560203








                                                              • 1




                                                                $begingroup$
                                                                Too bad is 36, not 32.
                                                                $endgroup$
                                                                – Magic Octopus Urn
                                                                Feb 28 at 19:51














                                                              • 1




                                                                $begingroup$
                                                                Too bad is 36, not 32.
                                                                $endgroup$
                                                                – Magic Octopus Urn
                                                                Feb 28 at 19:51








                                                              1




                                                              1




                                                              $begingroup$
                                                              Too bad is 36, not 32.
                                                              $endgroup$
                                                              – Magic Octopus Urn
                                                              Feb 28 at 19:51




                                                              $begingroup$
                                                              Too bad is 36, not 32.
                                                              $endgroup$
                                                              – Magic Octopus Urn
                                                              Feb 28 at 19:51











                                                              4












                                                              $begingroup$


                                                              Catholicon, 4 bytes



                                                              ǔ?QǑ


                                                              Takes a number as a base-256 string.



                                                              Try it online!



                                                              Test suite






                                                              share|improve this answer











                                                              $endgroup$









                                                              • 2




                                                                $begingroup$
                                                                Hm, if this is allowed, then is it allowed to accept numbers in base 32 instead?
                                                                $endgroup$
                                                                – recursive
                                                                Feb 27 at 19:47










                                                              • $begingroup$
                                                                @recursive You can surround the numbers in << and >> and it allows for numbers greater than 255 in those, as shown in the test suite.
                                                                $endgroup$
                                                                – Okx
                                                                Feb 28 at 13:11






                                                              • 1




                                                                $begingroup$
                                                                It was intended as a question about the challenge but it wasn't very clear.
                                                                $endgroup$
                                                                – recursive
                                                                Feb 28 at 15:44
















                                                              4












                                                              $begingroup$


                                                              Catholicon, 4 bytes



                                                              ǔ?QǑ


                                                              Takes a number as a base-256 string.



                                                              Try it online!



                                                              Test suite






                                                              share|improve this answer











                                                              $endgroup$









                                                              • 2




                                                                $begingroup$
                                                                Hm, if this is allowed, then is it allowed to accept numbers in base 32 instead?
                                                                $endgroup$
                                                                – recursive
                                                                Feb 27 at 19:47










                                                              • $begingroup$
                                                                @recursive You can surround the numbers in << and >> and it allows for numbers greater than 255 in those, as shown in the test suite.
                                                                $endgroup$
                                                                – Okx
                                                                Feb 28 at 13:11






                                                              • 1




                                                                $begingroup$
                                                                It was intended as a question about the challenge but it wasn't very clear.
                                                                $endgroup$
                                                                – recursive
                                                                Feb 28 at 15:44














                                                              4












                                                              4








                                                              4





                                                              $begingroup$


                                                              Catholicon, 4 bytes



                                                              ǔ?QǑ


                                                              Takes a number as a base-256 string.



                                                              Try it online!



                                                              Test suite






                                                              share|improve this answer











                                                              $endgroup$




                                                              Catholicon, 4 bytes



                                                              ǔ?QǑ


                                                              Takes a number as a base-256 string.



                                                              Try it online!



                                                              Test suite







                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited Feb 27 at 13:19

























                                                              answered Feb 27 at 13:11









                                                              OkxOkx

                                                              12.9k128102




                                                              12.9k128102








                                                              • 2




                                                                $begingroup$
                                                                Hm, if this is allowed, then is it allowed to accept numbers in base 32 instead?
                                                                $endgroup$
                                                                – recursive
                                                                Feb 27 at 19:47










                                                              • $begingroup$
                                                                @recursive You can surround the numbers in << and >> and it allows for numbers greater than 255 in those, as shown in the test suite.
                                                                $endgroup$
                                                                – Okx
                                                                Feb 28 at 13:11






                                                              • 1




                                                                $begingroup$
                                                                It was intended as a question about the challenge but it wasn't very clear.
                                                                $endgroup$
                                                                – recursive
                                                                Feb 28 at 15:44














                                                              • 2




                                                                $begingroup$
                                                                Hm, if this is allowed, then is it allowed to accept numbers in base 32 instead?
                                                                $endgroup$
                                                                – recursive
                                                                Feb 27 at 19:47










                                                              • $begingroup$
                                                                @recursive You can surround the numbers in << and >> and it allows for numbers greater than 255 in those, as shown in the test suite.
                                                                $endgroup$
                                                                – Okx
                                                                Feb 28 at 13:11






                                                              • 1




                                                                $begingroup$
                                                                It was intended as a question about the challenge but it wasn't very clear.
                                                                $endgroup$
                                                                – recursive
                                                                Feb 28 at 15:44








                                                              2




                                                              2




                                                              $begingroup$
                                                              Hm, if this is allowed, then is it allowed to accept numbers in base 32 instead?
                                                              $endgroup$
                                                              – recursive
                                                              Feb 27 at 19:47




                                                              $begingroup$
                                                              Hm, if this is allowed, then is it allowed to accept numbers in base 32 instead?
                                                              $endgroup$
                                                              – recursive
                                                              Feb 27 at 19:47












                                                              $begingroup$
                                                              @recursive You can surround the numbers in << and >> and it allows for numbers greater than 255 in those, as shown in the test suite.
                                                              $endgroup$
                                                              – Okx
                                                              Feb 28 at 13:11




                                                              $begingroup$
                                                              @recursive You can surround the numbers in << and >> and it allows for numbers greater than 255 in those, as shown in the test suite.
                                                              $endgroup$
                                                              – Okx
                                                              Feb 28 at 13:11




                                                              1




                                                              1




                                                              $begingroup$
                                                              It was intended as a question about the challenge but it wasn't very clear.
                                                              $endgroup$
                                                              – recursive
                                                              Feb 28 at 15:44




                                                              $begingroup$
                                                              It was intended as a question about the challenge but it wasn't very clear.
                                                              $endgroup$
                                                              – recursive
                                                              Feb 28 at 15:44











                                                              4












                                                              $begingroup$


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





                                                              n=>{for(;n>0;n/=n%32==4?0:32);}


                                                              Outputs by throwing an exception. The way you convert one number from decimal to another base is to divide the decimal number by that base repeatedly and take the remainder as a digit. That is what we do, and we check if any of the digits have a value of 4 in base-32;



                                                              Try it online!






                                                              share|improve this answer











                                                              $endgroup$













                                                              • $begingroup$
                                                                27? as a bonus it doesn't output in a weird way
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 6:13






                                                              • 1




                                                                $begingroup$
                                                                also what is tplig
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 6:15










                                                              • $begingroup$
                                                                @ASCII-only n>31 -> n>0
                                                                $endgroup$
                                                                – tsh
                                                                Feb 27 at 6:17










                                                              • $begingroup$
                                                                25 bytes
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Feb 27 at 12:57






                                                              • 1




                                                                $begingroup$
                                                                Whether or not a program halts is not an allowed output method. Output via exception is allowed.
                                                                $endgroup$
                                                                – Deadcode
                                                                Feb 28 at 22:58
















                                                              4












                                                              $begingroup$


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





                                                              n=>{for(;n>0;n/=n%32==4?0:32);}


                                                              Outputs by throwing an exception. The way you convert one number from decimal to another base is to divide the decimal number by that base repeatedly and take the remainder as a digit. That is what we do, and we check if any of the digits have a value of 4 in base-32;



                                                              Try it online!






                                                              share|improve this answer











                                                              $endgroup$













                                                              • $begingroup$
                                                                27? as a bonus it doesn't output in a weird way
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 6:13






                                                              • 1




                                                                $begingroup$
                                                                also what is tplig
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 6:15










                                                              • $begingroup$
                                                                @ASCII-only n>31 -> n>0
                                                                $endgroup$
                                                                – tsh
                                                                Feb 27 at 6:17










                                                              • $begingroup$
                                                                25 bytes
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Feb 27 at 12:57






                                                              • 1




                                                                $begingroup$
                                                                Whether or not a program halts is not an allowed output method. Output via exception is allowed.
                                                                $endgroup$
                                                                – Deadcode
                                                                Feb 28 at 22:58














                                                              4












                                                              4








                                                              4





                                                              $begingroup$


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





                                                              n=>{for(;n>0;n/=n%32==4?0:32);}


                                                              Outputs by throwing an exception. The way you convert one number from decimal to another base is to divide the decimal number by that base repeatedly and take the remainder as a digit. That is what we do, and we check if any of the digits have a value of 4 in base-32;



                                                              Try it online!






                                                              share|improve this answer











                                                              $endgroup$




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





                                                              n=>{for(;n>0;n/=n%32==4?0:32);}


                                                              Outputs by throwing an exception. The way you convert one number from decimal to another base is to divide the decimal number by that base repeatedly and take the remainder as a digit. That is what we do, and we check if any of the digits have a value of 4 in base-32;



                                                              Try it online!







                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited Feb 28 at 23:15

























                                                              answered Feb 27 at 5:39









                                                              Embodiment of IgnoranceEmbodiment of Ignorance

                                                              1,476123




                                                              1,476123












                                                              • $begingroup$
                                                                27? as a bonus it doesn't output in a weird way
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 6:13






                                                              • 1




                                                                $begingroup$
                                                                also what is tplig
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 6:15










                                                              • $begingroup$
                                                                @ASCII-only n>31 -> n>0
                                                                $endgroup$
                                                                – tsh
                                                                Feb 27 at 6:17










                                                              • $begingroup$
                                                                25 bytes
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Feb 27 at 12:57






                                                              • 1




                                                                $begingroup$
                                                                Whether or not a program halts is not an allowed output method. Output via exception is allowed.
                                                                $endgroup$
                                                                – Deadcode
                                                                Feb 28 at 22:58


















                                                              • $begingroup$
                                                                27? as a bonus it doesn't output in a weird way
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 6:13






                                                              • 1




                                                                $begingroup$
                                                                also what is tplig
                                                                $endgroup$
                                                                – ASCII-only
                                                                Feb 27 at 6:15










                                                              • $begingroup$
                                                                @ASCII-only n>31 -> n>0
                                                                $endgroup$
                                                                – tsh
                                                                Feb 27 at 6:17










                                                              • $begingroup$
                                                                25 bytes
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Feb 27 at 12:57






                                                              • 1




                                                                $begingroup$
                                                                Whether or not a program halts is not an allowed output method. Output via exception is allowed.
                                                                $endgroup$
                                                                – Deadcode
                                                                Feb 28 at 22:58
















                                                              $begingroup$
                                                              27? as a bonus it doesn't output in a weird way
                                                              $endgroup$
                                                              – ASCII-only
                                                              Feb 27 at 6:13




                                                              $begingroup$
                                                              27? as a bonus it doesn't output in a weird way
                                                              $endgroup$
                                                              – ASCII-only
                                                              Feb 27 at 6:13




                                                              1




                                                              1




                                                              $begingroup$
                                                              also what is tplig
                                                              $endgroup$
                                                              – ASCII-only
                                                              Feb 27 at 6:15




                                                              $begingroup$
                                                              also what is tplig
                                                              $endgroup$
                                                              – ASCII-only
                                                              Feb 27 at 6:15












                                                              $begingroup$
                                                              @ASCII-only n>31 -> n>0
                                                              $endgroup$
                                                              – tsh
                                                              Feb 27 at 6:17




                                                              $begingroup$
                                                              @ASCII-only n>31 -> n>0
                                                              $endgroup$
                                                              – tsh
                                                              Feb 27 at 6:17












                                                              $begingroup$
                                                              25 bytes
                                                              $endgroup$
                                                              – Kevin Cruijssen
                                                              Feb 27 at 12:57




                                                              $begingroup$
                                                              25 bytes
                                                              $endgroup$
                                                              – Kevin Cruijssen
                                                              Feb 27 at 12:57




                                                              1




                                                              1




                                                              $begingroup$
                                                              Whether or not a program halts is not an allowed output method. Output via exception is allowed.
                                                              $endgroup$
                                                              – Deadcode
                                                              Feb 28 at 22:58




                                                              $begingroup$
                                                              Whether or not a program halts is not an allowed output method. Output via exception is allowed.
                                                              $endgroup$
                                                              – Deadcode
                                                              Feb 28 at 22:58











                                                              4












                                                              $begingroup$

                                                              x86 Machine Code, 17 bytes



                                                              6A 20 59 85 C0 74 09 99 F7 F9 83 FA 04 75 F4 91 C3


                                                              The above bytes define a function that takes the number as input in the EAX register, and returns the result as a Boolean value in the EAX register (EAX == 0 if the input is not a rude number; EAX != 0 if the input is a rude number).



                                                              In human-readable assembly mnemonics:



                                                              ; Determines whether the specified number is a "rude" number.
                                                              ; Input: The number to check, in EAX
                                                              ; Output: The Boolean result, in EAX (non-zero if rude; zero otherwise)
                                                              ; Clobbers: ECX, EDX
                                                              IsRudeNumber:
                                                              push 32 ; standard golfing way to enregister a constant value
                                                              pop ecx ; / (in this case: ECX <= 32)
                                                              CheckNext:
                                                              test eax, eax ; if EAX == 0, jump to the end and return EAX (== 0)
                                                              jz TheEnd ; / otherwise, fall through and keep executing
                                                              cdq ; zero-out EDX because EAX is unsigned (shorter than XOR)
                                                              idiv ecx ; EAX <= (EAX / 32)
                                                              ; EDX <= (EAX % 32)
                                                              cmp edx, 4 ; if EDX != 4, jump back to the start of the loop
                                                              jne CheckNext ; / otherwise, fall through and keep executing
                                                              xchg eax, ecx ; store ECX (== 32, a non-zero value) in EAX
                                                              TheEnd:
                                                              ret ; return, with result in EAX


                                                              Try it online!






                                                              share|improve this answer









                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Interesting idea to use idiv, though. I don't see any incremental improvements to this. But see my answer : 14 bytes for a shift loop that uses MOV/AND/SUB/JZ to check the low 5 bits for rudeness.
                                                                $endgroup$
                                                                – Peter Cordes
                                                                Mar 4 at 0:25


















                                                              4












                                                              $begingroup$

                                                              x86 Machine Code, 17 bytes



                                                              6A 20 59 85 C0 74 09 99 F7 F9 83 FA 04 75 F4 91 C3


                                                              The above bytes define a function that takes the number as input in the EAX register, and returns the result as a Boolean value in the EAX register (EAX == 0 if the input is not a rude number; EAX != 0 if the input is a rude number).



                                                              In human-readable assembly mnemonics:



                                                              ; Determines whether the specified number is a "rude" number.
                                                              ; Input: The number to check, in EAX
                                                              ; Output: The Boolean result, in EAX (non-zero if rude; zero otherwise)
                                                              ; Clobbers: ECX, EDX
                                                              IsRudeNumber:
                                                              push 32 ; standard golfing way to enregister a constant value
                                                              pop ecx ; / (in this case: ECX <= 32)
                                                              CheckNext:
                                                              test eax, eax ; if EAX == 0, jump to the end and return EAX (== 0)
                                                              jz TheEnd ; / otherwise, fall through and keep executing
                                                              cdq ; zero-out EDX because EAX is unsigned (shorter than XOR)
                                                              idiv ecx ; EAX <= (EAX / 32)
                                                              ; EDX <= (EAX % 32)
                                                              cmp edx, 4 ; if EDX != 4, jump back to the start of the loop
                                                              jne CheckNext ; / otherwise, fall through and keep executing
                                                              xchg eax, ecx ; store ECX (== 32, a non-zero value) in EAX
                                                              TheEnd:
                                                              ret ; return, with result in EAX


                                                              Try it online!






                                                              share|improve this answer









                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Interesting idea to use idiv, though. I don't see any incremental improvements to this. But see my answer : 14 bytes for a shift loop that uses MOV/AND/SUB/JZ to check the low 5 bits for rudeness.
                                                                $endgroup$
                                                                – Peter Cordes
                                                                Mar 4 at 0:25
















                                                              4












                                                              4








                                                              4





                                                              $begingroup$

                                                              x86 Machine Code, 17 bytes



                                                              6A 20 59 85 C0 74 09 99 F7 F9 83 FA 04 75 F4 91 C3


                                                              The above bytes define a function that takes the number as input in the EAX register, and returns the result as a Boolean value in the EAX register (EAX == 0 if the input is not a rude number; EAX != 0 if the input is a rude number).



                                                              In human-readable assembly mnemonics:



                                                              ; Determines whether the specified number is a "rude" number.
                                                              ; Input: The number to check, in EAX
                                                              ; Output: The Boolean result, in EAX (non-zero if rude; zero otherwise)
                                                              ; Clobbers: ECX, EDX
                                                              IsRudeNumber:
                                                              push 32 ; standard golfing way to enregister a constant value
                                                              pop ecx ; / (in this case: ECX <= 32)
                                                              CheckNext:
                                                              test eax, eax ; if EAX == 0, jump to the end and return EAX (== 0)
                                                              jz TheEnd ; / otherwise, fall through and keep executing
                                                              cdq ; zero-out EDX because EAX is unsigned (shorter than XOR)
                                                              idiv ecx ; EAX <= (EAX / 32)
                                                              ; EDX <= (EAX % 32)
                                                              cmp edx, 4 ; if EDX != 4, jump back to the start of the loop
                                                              jne CheckNext ; / otherwise, fall through and keep executing
                                                              xchg eax, ecx ; store ECX (== 32, a non-zero value) in EAX
                                                              TheEnd:
                                                              ret ; return, with result in EAX


                                                              Try it online!






                                                              share|improve this answer









                                                              $endgroup$



                                                              x86 Machine Code, 17 bytes



                                                              6A 20 59 85 C0 74 09 99 F7 F9 83 FA 04 75 F4 91 C3


                                                              The above bytes define a function that takes the number as input in the EAX register, and returns the result as a Boolean value in the EAX register (EAX == 0 if the input is not a rude number; EAX != 0 if the input is a rude number).



                                                              In human-readable assembly mnemonics:



                                                              ; Determines whether the specified number is a "rude" number.
                                                              ; Input: The number to check, in EAX
                                                              ; Output: The Boolean result, in EAX (non-zero if rude; zero otherwise)
                                                              ; Clobbers: ECX, EDX
                                                              IsRudeNumber:
                                                              push 32 ; standard golfing way to enregister a constant value
                                                              pop ecx ; / (in this case: ECX <= 32)
                                                              CheckNext:
                                                              test eax, eax ; if EAX == 0, jump to the end and return EAX (== 0)
                                                              jz TheEnd ; / otherwise, fall through and keep executing
                                                              cdq ; zero-out EDX because EAX is unsigned (shorter than XOR)
                                                              idiv ecx ; EAX <= (EAX / 32)
                                                              ; EDX <= (EAX % 32)
                                                              cmp edx, 4 ; if EDX != 4, jump back to the start of the loop
                                                              jne CheckNext ; / otherwise, fall through and keep executing
                                                              xchg eax, ecx ; store ECX (== 32, a non-zero value) in EAX
                                                              TheEnd:
                                                              ret ; return, with result in EAX


                                                              Try it online!







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered Mar 1 at 7:04









                                                              Cody GrayCody Gray

                                                              1,869415




                                                              1,869415








                                                              • 1




                                                                $begingroup$
                                                                Interesting idea to use idiv, though. I don't see any incremental improvements to this. But see my answer : 14 bytes for a shift loop that uses MOV/AND/SUB/JZ to check the low 5 bits for rudeness.
                                                                $endgroup$
                                                                – Peter Cordes
                                                                Mar 4 at 0:25
















                                                              • 1




                                                                $begingroup$
                                                                Interesting idea to use idiv, though. I don't see any incremental improvements to this. But see my answer : 14 bytes for a shift loop that uses MOV/AND/SUB/JZ to check the low 5 bits for rudeness.
                                                                $endgroup$
                                                                – Peter Cordes
                                                                Mar 4 at 0:25










                                                              1




                                                              1




                                                              $begingroup$
                                                              Interesting idea to use idiv, though. I don't see any incremental improvements to this. But see my answer : 14 bytes for a shift loop that uses MOV/AND/SUB/JZ to check the low 5 bits for rudeness.
                                                              $endgroup$
                                                              – Peter Cordes
                                                              Mar 4 at 0:25






                                                              $begingroup$
                                                              Interesting idea to use idiv, though. I don't see any incremental improvements to this. But see my answer : 14 bytes for a shift loop that uses MOV/AND/SUB/JZ to check the low 5 bits for rudeness.
                                                              $endgroup$
                                                              – Peter Cordes
                                                              Mar 4 at 0:25













                                                              3












                                                              $begingroup$


                                                              J, 12 bytes



                                                              4 e.32#.inv]


                                                              Try it online!






                                                              share|improve this answer









                                                              $endgroup$


















                                                                3












                                                                $begingroup$


                                                                J, 12 bytes



                                                                4 e.32#.inv]


                                                                Try it online!






                                                                share|improve this answer









                                                                $endgroup$
















                                                                  3












                                                                  3








                                                                  3





                                                                  $begingroup$


                                                                  J, 12 bytes



                                                                  4 e.32#.inv]


                                                                  Try it online!






                                                                  share|improve this answer









                                                                  $endgroup$




                                                                  J, 12 bytes



                                                                  4 e.32#.inv]


                                                                  Try it online!







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered Feb 27 at 7:31









                                                                  Galen IvanovGalen Ivanov

                                                                  7,00711034




                                                                  7,00711034























                                                                      3












                                                                      $begingroup$


                                                                      R, 50 48 bytes





                                                                      any(2^(0:4)%*%matrix(scan()%/%2^(0:34)%%2,5)==4)


                                                                      Try it online!



                                                                      Uses a neat matrix-based approach now (courtesy of @Giueseppe). It generates a 5x7 matrix of bits, converts this to a series of base 32 integers, and checks for any 4s.






                                                                      share|improve this answer











                                                                      $endgroup$













                                                                      • $begingroup$
                                                                        @Giuseppe Oops, completely missed that. Should work now, though disappointingly 19 bytes longer. I don't think there's an inverse function to strtoi other than for hexadecimal and octal in base R
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Feb 28 at 17:45










                                                                      • $begingroup$
                                                                        48 bytes with some matrix magic. I believe the bit conversion is longer than intToBits but then we can work with ints instead of raw which ends up saving a byte -- see for instance this with intToBits
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 18:04












                                                                      • $begingroup$
                                                                        @Giuseppe it's a completely different (and neat) solution to mine - do you want me to update mine or you post your own?
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Feb 28 at 18:18










                                                                      • $begingroup$
                                                                        you're free to take it. :-)
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 18:24






                                                                      • 1




                                                                        $begingroup$
                                                                        of course, porting one of the many answers that tests for the presence of a digit 4 in a base-32 number is, oh, 29 bytes.
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 22:46
















                                                                      3












                                                                      $begingroup$


                                                                      R, 50 48 bytes





                                                                      any(2^(0:4)%*%matrix(scan()%/%2^(0:34)%%2,5)==4)


                                                                      Try it online!



                                                                      Uses a neat matrix-based approach now (courtesy of @Giueseppe). It generates a 5x7 matrix of bits, converts this to a series of base 32 integers, and checks for any 4s.






                                                                      share|improve this answer











                                                                      $endgroup$













                                                                      • $begingroup$
                                                                        @Giuseppe Oops, completely missed that. Should work now, though disappointingly 19 bytes longer. I don't think there's an inverse function to strtoi other than for hexadecimal and octal in base R
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Feb 28 at 17:45










                                                                      • $begingroup$
                                                                        48 bytes with some matrix magic. I believe the bit conversion is longer than intToBits but then we can work with ints instead of raw which ends up saving a byte -- see for instance this with intToBits
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 18:04












                                                                      • $begingroup$
                                                                        @Giuseppe it's a completely different (and neat) solution to mine - do you want me to update mine or you post your own?
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Feb 28 at 18:18










                                                                      • $begingroup$
                                                                        you're free to take it. :-)
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 18:24






                                                                      • 1




                                                                        $begingroup$
                                                                        of course, porting one of the many answers that tests for the presence of a digit 4 in a base-32 number is, oh, 29 bytes.
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 22:46














                                                                      3












                                                                      3








                                                                      3





                                                                      $begingroup$


                                                                      R, 50 48 bytes





                                                                      any(2^(0:4)%*%matrix(scan()%/%2^(0:34)%%2,5)==4)


                                                                      Try it online!



                                                                      Uses a neat matrix-based approach now (courtesy of @Giueseppe). It generates a 5x7 matrix of bits, converts this to a series of base 32 integers, and checks for any 4s.






                                                                      share|improve this answer











                                                                      $endgroup$




                                                                      R, 50 48 bytes





                                                                      any(2^(0:4)%*%matrix(scan()%/%2^(0:34)%%2,5)==4)


                                                                      Try it online!



                                                                      Uses a neat matrix-based approach now (courtesy of @Giueseppe). It generates a 5x7 matrix of bits, converts this to a series of base 32 integers, and checks for any 4s.







                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited Feb 28 at 18:47

























                                                                      answered Feb 28 at 0:12









                                                                      Nick KennedyNick Kennedy

                                                                      44125




                                                                      44125












                                                                      • $begingroup$
                                                                        @Giuseppe Oops, completely missed that. Should work now, though disappointingly 19 bytes longer. I don't think there's an inverse function to strtoi other than for hexadecimal and octal in base R
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Feb 28 at 17:45










                                                                      • $begingroup$
                                                                        48 bytes with some matrix magic. I believe the bit conversion is longer than intToBits but then we can work with ints instead of raw which ends up saving a byte -- see for instance this with intToBits
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 18:04












                                                                      • $begingroup$
                                                                        @Giuseppe it's a completely different (and neat) solution to mine - do you want me to update mine or you post your own?
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Feb 28 at 18:18










                                                                      • $begingroup$
                                                                        you're free to take it. :-)
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 18:24






                                                                      • 1




                                                                        $begingroup$
                                                                        of course, porting one of the many answers that tests for the presence of a digit 4 in a base-32 number is, oh, 29 bytes.
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 22:46


















                                                                      • $begingroup$
                                                                        @Giuseppe Oops, completely missed that. Should work now, though disappointingly 19 bytes longer. I don't think there's an inverse function to strtoi other than for hexadecimal and octal in base R
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Feb 28 at 17:45










                                                                      • $begingroup$
                                                                        48 bytes with some matrix magic. I believe the bit conversion is longer than intToBits but then we can work with ints instead of raw which ends up saving a byte -- see for instance this with intToBits
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 18:04












                                                                      • $begingroup$
                                                                        @Giuseppe it's a completely different (and neat) solution to mine - do you want me to update mine or you post your own?
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Feb 28 at 18:18










                                                                      • $begingroup$
                                                                        you're free to take it. :-)
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 18:24






                                                                      • 1




                                                                        $begingroup$
                                                                        of course, porting one of the many answers that tests for the presence of a digit 4 in a base-32 number is, oh, 29 bytes.
                                                                        $endgroup$
                                                                        – Giuseppe
                                                                        Feb 28 at 22:46
















                                                                      $begingroup$
                                                                      @Giuseppe Oops, completely missed that. Should work now, though disappointingly 19 bytes longer. I don't think there's an inverse function to strtoi other than for hexadecimal and octal in base R
                                                                      $endgroup$
                                                                      – Nick Kennedy
                                                                      Feb 28 at 17:45




                                                                      $begingroup$
                                                                      @Giuseppe Oops, completely missed that. Should work now, though disappointingly 19 bytes longer. I don't think there's an inverse function to strtoi other than for hexadecimal and octal in base R
                                                                      $endgroup$
                                                                      – Nick Kennedy
                                                                      Feb 28 at 17:45












                                                                      $begingroup$
                                                                      48 bytes with some matrix magic. I believe the bit conversion is longer than intToBits but then we can work with ints instead of raw which ends up saving a byte -- see for instance this with intToBits
                                                                      $endgroup$
                                                                      – Giuseppe
                                                                      Feb 28 at 18:04






                                                                      $begingroup$
                                                                      48 bytes with some matrix magic. I believe the bit conversion is longer than intToBits but then we can work with ints instead of raw which ends up saving a byte -- see for instance this with intToBits
                                                                      $endgroup$
                                                                      – Giuseppe
                                                                      Feb 28 at 18:04














                                                                      $begingroup$
                                                                      @Giuseppe it's a completely different (and neat) solution to mine - do you want me to update mine or you post your own?
                                                                      $endgroup$
                                                                      – Nick Kennedy
                                                                      Feb 28 at 18:18




                                                                      $begingroup$
                                                                      @Giuseppe it's a completely different (and neat) solution to mine - do you want me to update mine or you post your own?
                                                                      $endgroup$
                                                                      – Nick Kennedy
                                                                      Feb 28 at 18:18












                                                                      $begingroup$
                                                                      you're free to take it. :-)
                                                                      $endgroup$
                                                                      – Giuseppe
                                                                      Feb 28 at 18:24




                                                                      $begingroup$
                                                                      you're free to take it. :-)
                                                                      $endgroup$
                                                                      – Giuseppe
                                                                      Feb 28 at 18:24




                                                                      1




                                                                      1




                                                                      $begingroup$
                                                                      of course, porting one of the many answers that tests for the presence of a digit 4 in a base-32 number is, oh, 29 bytes.
                                                                      $endgroup$
                                                                      – Giuseppe
                                                                      Feb 28 at 22:46




                                                                      $begingroup$
                                                                      of course, porting one of the many answers that tests for the presence of a digit 4 in a base-32 number is, oh, 29 bytes.
                                                                      $endgroup$
                                                                      – Giuseppe
                                                                      Feb 28 at 22:46











                                                                      2












                                                                      $begingroup$


                                                                      Python 3, 43 bytes



                                                                      Checks every 5-bit chunk to see if it is rude (equal to 4).



                                                                      lambda n:any(n>>5*i&31==4for i in range(n))


                                                                      Try it online!






                                                                      share|improve this answer











                                                                      $endgroup$













                                                                      • $begingroup$
                                                                        *5-bit chunk...
                                                                        $endgroup$
                                                                        – ASCII-only
                                                                        Feb 27 at 7:38
















                                                                      2












                                                                      $begingroup$


                                                                      Python 3, 43 bytes



                                                                      Checks every 5-bit chunk to see if it is rude (equal to 4).



                                                                      lambda n:any(n>>5*i&31==4for i in range(n))


                                                                      Try it online!






                                                                      share|improve this answer











                                                                      $endgroup$













                                                                      • $begingroup$
                                                                        *5-bit chunk...
                                                                        $endgroup$
                                                                        – ASCII-only
                                                                        Feb 27 at 7:38














                                                                      2












                                                                      2








                                                                      2





                                                                      $begingroup$


                                                                      Python 3, 43 bytes



                                                                      Checks every 5-bit chunk to see if it is rude (equal to 4).



                                                                      lambda n:any(n>>5*i&31==4for i in range(n))


                                                                      Try it online!






                                                                      share|improve this answer











                                                                      $endgroup$




                                                                      Python 3, 43 bytes



                                                                      Checks every 5-bit chunk to see if it is rude (equal to 4).



                                                                      lambda n:any(n>>5*i&31==4for i in range(n))


                                                                      Try it online!







                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited Feb 27 at 7:46

























                                                                      answered Feb 27 at 5:30









                                                                      Neil A.Neil A.

                                                                      1,268120




                                                                      1,268120












                                                                      • $begingroup$
                                                                        *5-bit chunk...
                                                                        $endgroup$
                                                                        – ASCII-only
                                                                        Feb 27 at 7:38


















                                                                      • $begingroup$
                                                                        *5-bit chunk...
                                                                        $endgroup$
                                                                        – ASCII-only
                                                                        Feb 27 at 7:38
















                                                                      $begingroup$
                                                                      *5-bit chunk...
                                                                      $endgroup$
                                                                      – ASCII-only
                                                                      Feb 27 at 7:38




                                                                      $begingroup$
                                                                      *5-bit chunk...
                                                                      $endgroup$
                                                                      – ASCII-only
                                                                      Feb 27 at 7:38











                                                                      2












                                                                      $begingroup$


                                                                      C (gcc), 34 bytes





                                                                      f(i){return i?i&31^4?f(i/32):1:0;}


                                                                      Try it online!






                                                                      share|improve this answer









                                                                      $endgroup$













                                                                      • $begingroup$
                                                                        32 bytes by rearranging the expression.
                                                                        $endgroup$
                                                                        – Arnauld
                                                                        Feb 27 at 10:11






                                                                      • 3




                                                                        $begingroup$
                                                                        or 25 bytes by abusing the way gcc is compiling this.
                                                                        $endgroup$
                                                                        – Arnauld
                                                                        Feb 27 at 10:11
















                                                                      2












                                                                      $begingroup$


                                                                      C (gcc), 34 bytes





                                                                      f(i){return i?i&31^4?f(i/32):1:0;}


                                                                      Try it online!






                                                                      share|improve this answer









                                                                      $endgroup$













                                                                      • $begingroup$
                                                                        32 bytes by rearranging the expression.
                                                                        $endgroup$
                                                                        – Arnauld
                                                                        Feb 27 at 10:11






                                                                      • 3




                                                                        $begingroup$
                                                                        or 25 bytes by abusing the way gcc is compiling this.
                                                                        $endgroup$
                                                                        – Arnauld
                                                                        Feb 27 at 10:11














                                                                      2












                                                                      2








                                                                      2





                                                                      $begingroup$


                                                                      C (gcc), 34 bytes





                                                                      f(i){return i?i&31^4?f(i/32):1:0;}


                                                                      Try it online!






                                                                      share|improve this answer









                                                                      $endgroup$




                                                                      C (gcc), 34 bytes





                                                                      f(i){return i?i&31^4?f(i/32):1:0;}


                                                                      Try it online!







                                                                      share|improve this answer












                                                                      share|improve this answer



                                                                      share|improve this answer










                                                                      answered Feb 27 at 10:03









                                                                      celtschkceltschk

                                                                      4,29521619




                                                                      4,29521619












                                                                      • $begingroup$
                                                                        32 bytes by rearranging the expression.
                                                                        $endgroup$
                                                                        – Arnauld
                                                                        Feb 27 at 10:11






                                                                      • 3




                                                                        $begingroup$
                                                                        or 25 bytes by abusing the way gcc is compiling this.
                                                                        $endgroup$
                                                                        – Arnauld
                                                                        Feb 27 at 10:11


















                                                                      • $begingroup$
                                                                        32 bytes by rearranging the expression.
                                                                        $endgroup$
                                                                        – Arnauld
                                                                        Feb 27 at 10:11






                                                                      • 3




                                                                        $begingroup$
                                                                        or 25 bytes by abusing the way gcc is compiling this.
                                                                        $endgroup$
                                                                        – Arnauld
                                                                        Feb 27 at 10:11
















                                                                      $begingroup$
                                                                      32 bytes by rearranging the expression.
                                                                      $endgroup$
                                                                      – Arnauld
                                                                      Feb 27 at 10:11




                                                                      $begingroup$
                                                                      32 bytes by rearranging the expression.
                                                                      $endgroup$
                                                                      – Arnauld
                                                                      Feb 27 at 10:11




                                                                      3




                                                                      3




                                                                      $begingroup$
                                                                      or 25 bytes by abusing the way gcc is compiling this.
                                                                      $endgroup$
                                                                      – Arnauld
                                                                      Feb 27 at 10:11




                                                                      $begingroup$
                                                                      or 25 bytes by abusing the way gcc is compiling this.
                                                                      $endgroup$
                                                                      – Arnauld
                                                                      Feb 27 at 10:11











                                                                      2












                                                                      $begingroup$


                                                                      Charcoal, 6 bytes



                                                                      №⍘N³²4


                                                                      Try it online! Link is to verbose version of code. Outputs -s according to how rude the number is. Explanation:



                                                                        N     Input as a number
                                                                      ⍘ Convert to base as a string
                                                                      ³² Literal 32
                                                                      № Count occurrences of
                                                                      4 Literal string `4`


                                                                      I use string base conversion to avoid having to separate the numeric literals for 32 and 4.






                                                                      share|improve this answer









                                                                      $endgroup$


















                                                                        2












                                                                        $begingroup$


                                                                        Charcoal, 6 bytes



                                                                        №⍘N³²4


                                                                        Try it online! Link is to verbose version of code. Outputs -s according to how rude the number is. Explanation:



                                                                          N     Input as a number
                                                                        ⍘ Convert to base as a string
                                                                        ³² Literal 32
                                                                        № Count occurrences of
                                                                        4 Literal string `4`


                                                                        I use string base conversion to avoid having to separate the numeric literals for 32 and 4.






                                                                        share|improve this answer









                                                                        $endgroup$
















                                                                          2












                                                                          2








                                                                          2





                                                                          $begingroup$


                                                                          Charcoal, 6 bytes



                                                                          №⍘N³²4


                                                                          Try it online! Link is to verbose version of code. Outputs -s according to how rude the number is. Explanation:



                                                                            N     Input as a number
                                                                          ⍘ Convert to base as a string
                                                                          ³² Literal 32
                                                                          № Count occurrences of
                                                                          4 Literal string `4`


                                                                          I use string base conversion to avoid having to separate the numeric literals for 32 and 4.






                                                                          share|improve this answer









                                                                          $endgroup$




                                                                          Charcoal, 6 bytes



                                                                          №⍘N³²4


                                                                          Try it online! Link is to verbose version of code. Outputs -s according to how rude the number is. Explanation:



                                                                            N     Input as a number
                                                                          ⍘ Convert to base as a string
                                                                          ³² Literal 32
                                                                          № Count occurrences of
                                                                          4 Literal string `4`


                                                                          I use string base conversion to avoid having to separate the numeric literals for 32 and 4.







                                                                          share|improve this answer












                                                                          share|improve this answer



                                                                          share|improve this answer










                                                                          answered Feb 27 at 12:38









                                                                          NeilNeil

                                                                          81.4k745178




                                                                          81.4k745178























                                                                              2












                                                                              $begingroup$


                                                                              Tidy, 18 bytes



                                                                              {x:4∈base(32,x)}


                                                                              Try it online! Checks if 4 is an element of base(32,x) (base conversion).






                                                                              share|improve this answer









                                                                              $endgroup$


















                                                                                2












                                                                                $begingroup$


                                                                                Tidy, 18 bytes



                                                                                {x:4∈base(32,x)}


                                                                                Try it online! Checks if 4 is an element of base(32,x) (base conversion).






                                                                                share|improve this answer









                                                                                $endgroup$
















                                                                                  2












                                                                                  2








                                                                                  2





                                                                                  $begingroup$


                                                                                  Tidy, 18 bytes



                                                                                  {x:4∈base(32,x)}


                                                                                  Try it online! Checks if 4 is an element of base(32,x) (base conversion).






                                                                                  share|improve this answer









                                                                                  $endgroup$




                                                                                  Tidy, 18 bytes



                                                                                  {x:4∈base(32,x)}


                                                                                  Try it online! Checks if 4 is an element of base(32,x) (base conversion).







                                                                                  share|improve this answer












                                                                                  share|improve this answer



                                                                                  share|improve this answer










                                                                                  answered Feb 27 at 15:06









                                                                                  Conor O'BrienConor O'Brien

                                                                                  30.3k264162




                                                                                  30.3k264162























                                                                                      2












                                                                                      $begingroup$


                                                                                      Haskell, 31 bytes





                                                                                      elem 9.(mapM(:[6..36])[0..5]!!)


                                                                                      Try it online!






                                                                                      share|improve this answer









                                                                                      $endgroup$


















                                                                                        2












                                                                                        $begingroup$


                                                                                        Haskell, 31 bytes





                                                                                        elem 9.(mapM(:[6..36])[0..5]!!)


                                                                                        Try it online!






                                                                                        share|improve this answer









                                                                                        $endgroup$
















                                                                                          2












                                                                                          2








                                                                                          2





                                                                                          $begingroup$


                                                                                          Haskell, 31 bytes





                                                                                          elem 9.(mapM(:[6..36])[0..5]!!)


                                                                                          Try it online!






                                                                                          share|improve this answer









                                                                                          $endgroup$




                                                                                          Haskell, 31 bytes





                                                                                          elem 9.(mapM(:[6..36])[0..5]!!)


                                                                                          Try it online!







                                                                                          share|improve this answer












                                                                                          share|improve this answer



                                                                                          share|improve this answer










                                                                                          answered Feb 28 at 4:07









                                                                                          xnorxnor

                                                                                          91.6k18187443




                                                                                          91.6k18187443























                                                                                              2












                                                                                              $begingroup$

                                                                                              ES6, 31 30 bytes



                                                                                              a=b=>b.toString(32).match(/4/)


                                                                                              Feel free to say ideas on how to reduce this further, if any.






                                                                                              share|improve this answer










                                                                                              New contributor




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






                                                                                              $endgroup$













                                                                                              • $begingroup$
                                                                                                Welcome to PPCG!
                                                                                                $endgroup$
                                                                                                – Laikoni
                                                                                                Feb 28 at 19:23










                                                                                              • $begingroup$
                                                                                                You don't need to count the name of your function, and although I think you can save a byte by using test, you can actually save two bytes by matching against 4 as a number and letting match convert that into a string and then a RegExp for you.
                                                                                                $endgroup$
                                                                                                – Neil
                                                                                                Mar 1 at 0:53
















                                                                                              2












                                                                                              $begingroup$

                                                                                              ES6, 31 30 bytes



                                                                                              a=b=>b.toString(32).match(/4/)


                                                                                              Feel free to say ideas on how to reduce this further, if any.






                                                                                              share|improve this answer










                                                                                              New contributor




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






                                                                                              $endgroup$













                                                                                              • $begingroup$
                                                                                                Welcome to PPCG!
                                                                                                $endgroup$
                                                                                                – Laikoni
                                                                                                Feb 28 at 19:23










                                                                                              • $begingroup$
                                                                                                You don't need to count the name of your function, and although I think you can save a byte by using test, you can actually save two bytes by matching against 4 as a number and letting match convert that into a string and then a RegExp for you.
                                                                                                $endgroup$
                                                                                                – Neil
                                                                                                Mar 1 at 0:53














                                                                                              2












                                                                                              2








                                                                                              2





                                                                                              $begingroup$

                                                                                              ES6, 31 30 bytes



                                                                                              a=b=>b.toString(32).match(/4/)


                                                                                              Feel free to say ideas on how to reduce this further, if any.






                                                                                              share|improve this answer










                                                                                              New contributor




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






                                                                                              $endgroup$



                                                                                              ES6, 31 30 bytes



                                                                                              a=b=>b.toString(32).match(/4/)


                                                                                              Feel free to say ideas on how to reduce this further, if any.







                                                                                              share|improve this answer










                                                                                              New contributor




                                                                                              elipszilon 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 answer



                                                                                              share|improve this answer








                                                                                              edited Feb 28 at 18:08





















                                                                                              New contributor




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









                                                                                              answered Feb 28 at 18:01









                                                                                              elipszilonelipszilon

                                                                                              212




                                                                                              212




                                                                                              New contributor




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





                                                                                              New contributor





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






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












                                                                                              • $begingroup$
                                                                                                Welcome to PPCG!
                                                                                                $endgroup$
                                                                                                – Laikoni
                                                                                                Feb 28 at 19:23










                                                                                              • $begingroup$
                                                                                                You don't need to count the name of your function, and although I think you can save a byte by using test, you can actually save two bytes by matching against 4 as a number and letting match convert that into a string and then a RegExp for you.
                                                                                                $endgroup$
                                                                                                – Neil
                                                                                                Mar 1 at 0:53


















                                                                                              • $begingroup$
                                                                                                Welcome to PPCG!
                                                                                                $endgroup$
                                                                                                – Laikoni
                                                                                                Feb 28 at 19:23










                                                                                              • $begingroup$
                                                                                                You don't need to count the name of your function, and although I think you can save a byte by using test, you can actually save two bytes by matching against 4 as a number and letting match convert that into a string and then a RegExp for you.
                                                                                                $endgroup$
                                                                                                – Neil
                                                                                                Mar 1 at 0:53
















                                                                                              $begingroup$
                                                                                              Welcome to PPCG!
                                                                                              $endgroup$
                                                                                              – Laikoni
                                                                                              Feb 28 at 19:23




                                                                                              $begingroup$
                                                                                              Welcome to PPCG!
                                                                                              $endgroup$
                                                                                              – Laikoni
                                                                                              Feb 28 at 19:23












                                                                                              $begingroup$
                                                                                              You don't need to count the name of your function, and although I think you can save a byte by using test, you can actually save two bytes by matching against 4 as a number and letting match convert that into a string and then a RegExp for you.
                                                                                              $endgroup$
                                                                                              – Neil
                                                                                              Mar 1 at 0:53




                                                                                              $begingroup$
                                                                                              You don't need to count the name of your function, and although I think you can save a byte by using test, you can actually save two bytes by matching against 4 as a number and letting match convert that into a string and then a RegExp for you.
                                                                                              $endgroup$
                                                                                              – Neil
                                                                                              Mar 1 at 0:53











                                                                                              2












                                                                                              $begingroup$


                                                                                              Cubix, 26 bytes



                                                                                              u!@-W14;OIS%/;;,p;?wO@u/s


                                                                                              Try it online!



                                                                                              Wraps onto a cube with edge length 3 as follows



                                                                                                    u ! @
                                                                                              - W 1
                                                                                              4 ; O
                                                                                              I S % / ; ; , p ; ? w
                                                                                              O @ u / s . . . . . . .
                                                                                              . . . . . . . . . . . .
                                                                                              . . .
                                                                                              . . .
                                                                                              . . .


                                                                                              Watch it run



                                                                                              A fairly basic implementation, without all the redirects it does :





                                                                                              • IS initiates the program by pushing the input and 32 to the stack


                                                                                              • %4-! gets the remainder and checks if it is 4 by subtraction


                                                                                              • 1O@ output 1 if it was 4 and halt


                                                                                              • ;;, clean up the stack and do integer divide


                                                                                              • p;? clean up bottom of the stack and check div result for 0


                                                                                              • O@ if div result zero output and halt


                                                                                              • s swap the top of stack and start back at step 2 above






                                                                                              share|improve this answer









                                                                                              $endgroup$


















                                                                                                2












                                                                                                $begingroup$


                                                                                                Cubix, 26 bytes



                                                                                                u!@-W14;OIS%/;;,p;?wO@u/s


                                                                                                Try it online!



                                                                                                Wraps onto a cube with edge length 3 as follows



                                                                                                      u ! @
                                                                                                - W 1
                                                                                                4 ; O
                                                                                                I S % / ; ; , p ; ? w
                                                                                                O @ u / s . . . . . . .
                                                                                                . . . . . . . . . . . .
                                                                                                . . .
                                                                                                . . .
                                                                                                . . .


                                                                                                Watch it run



                                                                                                A fairly basic implementation, without all the redirects it does :





                                                                                                • IS initiates the program by pushing the input and 32 to the stack


                                                                                                • %4-! gets the remainder and checks if it is 4 by subtraction


                                                                                                • 1O@ output 1 if it was 4 and halt


                                                                                                • ;;, clean up the stack and do integer divide


                                                                                                • p;? clean up bottom of the stack and check div result for 0


                                                                                                • O@ if div result zero output and halt


                                                                                                • s swap the top of stack and start back at step 2 above






                                                                                                share|improve this answer









                                                                                                $endgroup$
















                                                                                                  2












                                                                                                  2








                                                                                                  2





                                                                                                  $begingroup$


                                                                                                  Cubix, 26 bytes



                                                                                                  u!@-W14;OIS%/;;,p;?wO@u/s


                                                                                                  Try it online!



                                                                                                  Wraps onto a cube with edge length 3 as follows



                                                                                                        u ! @
                                                                                                  - W 1
                                                                                                  4 ; O
                                                                                                  I S % / ; ; , p ; ? w
                                                                                                  O @ u / s . . . . . . .
                                                                                                  . . . . . . . . . . . .
                                                                                                  . . .
                                                                                                  . . .
                                                                                                  . . .


                                                                                                  Watch it run



                                                                                                  A fairly basic implementation, without all the redirects it does :





                                                                                                  • IS initiates the program by pushing the input and 32 to the stack


                                                                                                  • %4-! gets the remainder and checks if it is 4 by subtraction


                                                                                                  • 1O@ output 1 if it was 4 and halt


                                                                                                  • ;;, clean up the stack and do integer divide


                                                                                                  • p;? clean up bottom of the stack and check div result for 0


                                                                                                  • O@ if div result zero output and halt


                                                                                                  • s swap the top of stack and start back at step 2 above






                                                                                                  share|improve this answer









                                                                                                  $endgroup$




                                                                                                  Cubix, 26 bytes



                                                                                                  u!@-W14;OIS%/;;,p;?wO@u/s


                                                                                                  Try it online!



                                                                                                  Wraps onto a cube with edge length 3 as follows



                                                                                                        u ! @
                                                                                                  - W 1
                                                                                                  4 ; O
                                                                                                  I S % / ; ; , p ; ? w
                                                                                                  O @ u / s . . . . . . .
                                                                                                  . . . . . . . . . . . .
                                                                                                  . . .
                                                                                                  . . .
                                                                                                  . . .


                                                                                                  Watch it run



                                                                                                  A fairly basic implementation, without all the redirects it does :





                                                                                                  • IS initiates the program by pushing the input and 32 to the stack


                                                                                                  • %4-! gets the remainder and checks if it is 4 by subtraction


                                                                                                  • 1O@ output 1 if it was 4 and halt


                                                                                                  • ;;, clean up the stack and do integer divide


                                                                                                  • p;? clean up bottom of the stack and check div result for 0


                                                                                                  • O@ if div result zero output and halt


                                                                                                  • s swap the top of stack and start back at step 2 above







                                                                                                  share|improve this answer












                                                                                                  share|improve this answer



                                                                                                  share|improve this answer










                                                                                                  answered Feb 28 at 21:34









                                                                                                  MickyTMickyT

                                                                                                  10.2k21637




                                                                                                  10.2k21637























                                                                                                      2












                                                                                                      $begingroup$


                                                                                                      MATL, 8 bytes



                                                                                                      32YA52=a


                                                                                                      Try it online!






                                                                                                      share|improve this answer











                                                                                                      $endgroup$













                                                                                                      • $begingroup$
                                                                                                        @Luis I can definitely drop the G (not sure why I included it in the first place) but that's only one byte (thanks for spotting that!). Changing 32YA52 to 32_YA4 is the same number of bytes right?
                                                                                                        $endgroup$
                                                                                                        – Sanchises
                                                                                                        Mar 1 at 7:06












                                                                                                      • $begingroup$
                                                                                                        Ah, yes, I can't count
                                                                                                        $endgroup$
                                                                                                        – Luis Mendo
                                                                                                        Mar 1 at 10:26






                                                                                                      • 2




                                                                                                        $begingroup$
                                                                                                        @Luis Count? Who needs to count when you can '32_YA4'n'32YA52'n-
                                                                                                        $endgroup$
                                                                                                        – Sanchises
                                                                                                        Mar 1 at 11:56
















                                                                                                      2












                                                                                                      $begingroup$


                                                                                                      MATL, 8 bytes



                                                                                                      32YA52=a


                                                                                                      Try it online!






                                                                                                      share|improve this answer











                                                                                                      $endgroup$













                                                                                                      • $begingroup$
                                                                                                        @Luis I can definitely drop the G (not sure why I included it in the first place) but that's only one byte (thanks for spotting that!). Changing 32YA52 to 32_YA4 is the same number of bytes right?
                                                                                                        $endgroup$
                                                                                                        – Sanchises
                                                                                                        Mar 1 at 7:06












                                                                                                      • $begingroup$
                                                                                                        Ah, yes, I can't count
                                                                                                        $endgroup$
                                                                                                        – Luis Mendo
                                                                                                        Mar 1 at 10:26






                                                                                                      • 2




                                                                                                        $begingroup$
                                                                                                        @Luis Count? Who needs to count when you can '32_YA4'n'32YA52'n-
                                                                                                        $endgroup$
                                                                                                        – Sanchises
                                                                                                        Mar 1 at 11:56














                                                                                                      2












                                                                                                      2








                                                                                                      2





                                                                                                      $begingroup$


                                                                                                      MATL, 8 bytes



                                                                                                      32YA52=a


                                                                                                      Try it online!






                                                                                                      share|improve this answer











                                                                                                      $endgroup$




                                                                                                      MATL, 8 bytes



                                                                                                      32YA52=a


                                                                                                      Try it online!







                                                                                                      share|improve this answer














                                                                                                      share|improve this answer



                                                                                                      share|improve this answer








                                                                                                      edited Mar 1 at 7:07

























                                                                                                      answered Feb 28 at 13:57









                                                                                                      SanchisesSanchises

                                                                                                      6,17712352




                                                                                                      6,17712352












                                                                                                      • $begingroup$
                                                                                                        @Luis I can definitely drop the G (not sure why I included it in the first place) but that's only one byte (thanks for spotting that!). Changing 32YA52 to 32_YA4 is the same number of bytes right?
                                                                                                        $endgroup$
                                                                                                        – Sanchises
                                                                                                        Mar 1 at 7:06












                                                                                                      • $begingroup$
                                                                                                        Ah, yes, I can't count
                                                                                                        $endgroup$
                                                                                                        – Luis Mendo
                                                                                                        Mar 1 at 10:26






                                                                                                      • 2




                                                                                                        $begingroup$
                                                                                                        @Luis Count? Who needs to count when you can '32_YA4'n'32YA52'n-
                                                                                                        $endgroup$
                                                                                                        – Sanchises
                                                                                                        Mar 1 at 11:56


















                                                                                                      • $begingroup$
                                                                                                        @Luis I can definitely drop the G (not sure why I included it in the first place) but that's only one byte (thanks for spotting that!). Changing 32YA52 to 32_YA4 is the same number of bytes right?
                                                                                                        $endgroup$
                                                                                                        – Sanchises
                                                                                                        Mar 1 at 7:06












                                                                                                      • $begingroup$
                                                                                                        Ah, yes, I can't count
                                                                                                        $endgroup$
                                                                                                        – Luis Mendo
                                                                                                        Mar 1 at 10:26






                                                                                                      • 2




                                                                                                        $begingroup$
                                                                                                        @Luis Count? Who needs to count when you can '32_YA4'n'32YA52'n-
                                                                                                        $endgroup$
                                                                                                        – Sanchises
                                                                                                        Mar 1 at 11:56
















                                                                                                      $begingroup$
                                                                                                      @Luis I can definitely drop the G (not sure why I included it in the first place) but that's only one byte (thanks for spotting that!). Changing 32YA52 to 32_YA4 is the same number of bytes right?
                                                                                                      $endgroup$
                                                                                                      – Sanchises
                                                                                                      Mar 1 at 7:06






                                                                                                      $begingroup$
                                                                                                      @Luis I can definitely drop the G (not sure why I included it in the first place) but that's only one byte (thanks for spotting that!). Changing 32YA52 to 32_YA4 is the same number of bytes right?
                                                                                                      $endgroup$
                                                                                                      – Sanchises
                                                                                                      Mar 1 at 7:06














                                                                                                      $begingroup$
                                                                                                      Ah, yes, I can't count
                                                                                                      $endgroup$
                                                                                                      – Luis Mendo
                                                                                                      Mar 1 at 10:26




                                                                                                      $begingroup$
                                                                                                      Ah, yes, I can't count
                                                                                                      $endgroup$
                                                                                                      – Luis Mendo
                                                                                                      Mar 1 at 10:26




                                                                                                      2




                                                                                                      2




                                                                                                      $begingroup$
                                                                                                      @Luis Count? Who needs to count when you can '32_YA4'n'32YA52'n-
                                                                                                      $endgroup$
                                                                                                      – Sanchises
                                                                                                      Mar 1 at 11:56




                                                                                                      $begingroup$
                                                                                                      @Luis Count? Who needs to count when you can '32_YA4'n'32YA52'n-
                                                                                                      $endgroup$
                                                                                                      – Sanchises
                                                                                                      Mar 1 at 11:56











                                                                                                      1












                                                                                                      $begingroup$


                                                                                                      Retina 0.8.2, 31 bytes



                                                                                                      .+
                                                                                                      $*
                                                                                                      +`(1+)1{31}
                                                                                                      $1;
                                                                                                      b1111b


                                                                                                      Try it online! Link includes test cases. Outputs zero unless the number is rude. Works by converting the input to unary and then to unary-encoded base 32 and counting the number of 4s in the result.






                                                                                                      share|improve this answer









                                                                                                      $endgroup$


















                                                                                                        1












                                                                                                        $begingroup$


                                                                                                        Retina 0.8.2, 31 bytes



                                                                                                        .+
                                                                                                        $*
                                                                                                        +`(1+)1{31}
                                                                                                        $1;
                                                                                                        b1111b


                                                                                                        Try it online! Link includes test cases. Outputs zero unless the number is rude. Works by converting the input to unary and then to unary-encoded base 32 and counting the number of 4s in the result.






                                                                                                        share|improve this answer









                                                                                                        $endgroup$
















                                                                                                          1












                                                                                                          1








                                                                                                          1





                                                                                                          $begingroup$


                                                                                                          Retina 0.8.2, 31 bytes



                                                                                                          .+
                                                                                                          $*
                                                                                                          +`(1+)1{31}
                                                                                                          $1;
                                                                                                          b1111b


                                                                                                          Try it online! Link includes test cases. Outputs zero unless the number is rude. Works by converting the input to unary and then to unary-encoded base 32 and counting the number of 4s in the result.






                                                                                                          share|improve this answer









                                                                                                          $endgroup$




                                                                                                          Retina 0.8.2, 31 bytes



                                                                                                          .+
                                                                                                          $*
                                                                                                          +`(1+)1{31}
                                                                                                          $1;
                                                                                                          b1111b


                                                                                                          Try it online! Link includes test cases. Outputs zero unless the number is rude. Works by converting the input to unary and then to unary-encoded base 32 and counting the number of 4s in the result.







                                                                                                          share|improve this answer












                                                                                                          share|improve this answer



                                                                                                          share|improve this answer










                                                                                                          answered Feb 27 at 13:28









                                                                                                          NeilNeil

                                                                                                          81.4k745178




                                                                                                          81.4k745178























                                                                                                              1












                                                                                                              $begingroup$

                                                                                                              Java 8, 40 33 bytes





                                                                                                              n->n.toString(n,32).contains("4")


                                                                                                              Port of @Adám's APL (dzaima/APL) answer.



                                                                                                              Try it online.



                                                                                                              Explanation:



                                                                                                              n->                 // Method with Integer parameter and boolean return-type
                                                                                                              n.toString(n,32) // Convert the input to a base-32 String
                                                                                                              .contains("4") // And check if it contains a "4"





                                                                                                              share|improve this answer











                                                                                                              $endgroup$


















                                                                                                                1












                                                                                                                $begingroup$

                                                                                                                Java 8, 40 33 bytes





                                                                                                                n->n.toString(n,32).contains("4")


                                                                                                                Port of @Adám's APL (dzaima/APL) answer.



                                                                                                                Try it online.



                                                                                                                Explanation:



                                                                                                                n->                 // Method with Integer parameter and boolean return-type
                                                                                                                n.toString(n,32) // Convert the input to a base-32 String
                                                                                                                .contains("4") // And check if it contains a "4"





                                                                                                                share|improve this answer











                                                                                                                $endgroup$
















                                                                                                                  1












                                                                                                                  1








                                                                                                                  1





                                                                                                                  $begingroup$

                                                                                                                  Java 8, 40 33 bytes





                                                                                                                  n->n.toString(n,32).contains("4")


                                                                                                                  Port of @Adám's APL (dzaima/APL) answer.



                                                                                                                  Try it online.



                                                                                                                  Explanation:



                                                                                                                  n->                 // Method with Integer parameter and boolean return-type
                                                                                                                  n.toString(n,32) // Convert the input to a base-32 String
                                                                                                                  .contains("4") // And check if it contains a "4"





                                                                                                                  share|improve this answer











                                                                                                                  $endgroup$



                                                                                                                  Java 8, 40 33 bytes





                                                                                                                  n->n.toString(n,32).contains("4")


                                                                                                                  Port of @Adám's APL (dzaima/APL) answer.



                                                                                                                  Try it online.



                                                                                                                  Explanation:



                                                                                                                  n->                 // Method with Integer parameter and boolean return-type
                                                                                                                  n.toString(n,32) // Convert the input to a base-32 String
                                                                                                                  .contains("4") // And check if it contains a "4"






                                                                                                                  share|improve this answer














                                                                                                                  share|improve this answer



                                                                                                                  share|improve this answer








                                                                                                                  edited Feb 27 at 14:58

























                                                                                                                  answered Feb 27 at 12:56









                                                                                                                  Kevin CruijssenKevin Cruijssen

                                                                                                                  39.7k560203




                                                                                                                  39.7k560203























                                                                                                                      1












                                                                                                                      $begingroup$

                                                                                                                      Batch, 77 45 bytes



                                                                                                                      @cmd/cset/a"m=34636833,n=%1^m*4,(n-m)&~n&m*16


                                                                                                                      Based on these bit twiddling hacks. Explanation: Only 6 hands need to be checked due to the limited range (30 bits) of the input that's required to be supported. The magic number m is equivalent to 111111 in base 32, so that the first operation toggles the rude bits in the input number. It then remains to find which of the 6 hands is now zero.






                                                                                                                      share|improve this answer











                                                                                                                      $endgroup$


















                                                                                                                        1












                                                                                                                        $begingroup$

                                                                                                                        Batch, 77 45 bytes



                                                                                                                        @cmd/cset/a"m=34636833,n=%1^m*4,(n-m)&~n&m*16


                                                                                                                        Based on these bit twiddling hacks. Explanation: Only 6 hands need to be checked due to the limited range (30 bits) of the input that's required to be supported. The magic number m is equivalent to 111111 in base 32, so that the first operation toggles the rude bits in the input number. It then remains to find which of the 6 hands is now zero.






                                                                                                                        share|improve this answer











                                                                                                                        $endgroup$
















                                                                                                                          1












                                                                                                                          1








                                                                                                                          1





                                                                                                                          $begingroup$

                                                                                                                          Batch, 77 45 bytes



                                                                                                                          @cmd/cset/a"m=34636833,n=%1^m*4,(n-m)&~n&m*16


                                                                                                                          Based on these bit twiddling hacks. Explanation: Only 6 hands need to be checked due to the limited range (30 bits) of the input that's required to be supported. The magic number m is equivalent to 111111 in base 32, so that the first operation toggles the rude bits in the input number. It then remains to find which of the 6 hands is now zero.






                                                                                                                          share|improve this answer











                                                                                                                          $endgroup$



                                                                                                                          Batch, 77 45 bytes



                                                                                                                          @cmd/cset/a"m=34636833,n=%1^m*4,(n-m)&~n&m*16


                                                                                                                          Based on these bit twiddling hacks. Explanation: Only 6 hands need to be checked due to the limited range (30 bits) of the input that's required to be supported. The magic number m is equivalent to 111111 in base 32, so that the first operation toggles the rude bits in the input number. It then remains to find which of the 6 hands is now zero.







                                                                                                                          share|improve this answer














                                                                                                                          share|improve this answer



                                                                                                                          share|improve this answer








                                                                                                                          edited Mar 1 at 11:13

























                                                                                                                          answered Mar 1 at 0:50









                                                                                                                          NeilNeil

                                                                                                                          81.4k745178




                                                                                                                          81.4k745178























                                                                                                                              1












                                                                                                                              $begingroup$


                                                                                                                              ><>, 28 bytes



                                                                                                                              Outputs 4 for rude numbers throws an exception for non-rude numbers.



                                                                                                                              :1(?^:" ":
                                                                                                                              ,&-v?=4:%&/
                                                                                                                              ;n<


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$









                                                                                                                              • 1




                                                                                                                                $begingroup$
                                                                                                                                An exception is acceptable, the C# answer does it
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                Mar 1 at 11:22
















                                                                                                                              1












                                                                                                                              $begingroup$


                                                                                                                              ><>, 28 bytes



                                                                                                                              Outputs 4 for rude numbers throws an exception for non-rude numbers.



                                                                                                                              :1(?^:" ":
                                                                                                                              ,&-v?=4:%&/
                                                                                                                              ;n<


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$









                                                                                                                              • 1




                                                                                                                                $begingroup$
                                                                                                                                An exception is acceptable, the C# answer does it
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                Mar 1 at 11:22














                                                                                                                              1












                                                                                                                              1








                                                                                                                              1





                                                                                                                              $begingroup$


                                                                                                                              ><>, 28 bytes



                                                                                                                              Outputs 4 for rude numbers throws an exception for non-rude numbers.



                                                                                                                              :1(?^:" ":
                                                                                                                              ,&-v?=4:%&/
                                                                                                                              ;n<


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$




                                                                                                                              ><>, 28 bytes



                                                                                                                              Outputs 4 for rude numbers throws an exception for non-rude numbers.



                                                                                                                              :1(?^:" ":
                                                                                                                              ,&-v?=4:%&/
                                                                                                                              ;n<


                                                                                                                              Try it online!







                                                                                                                              share|improve this answer














                                                                                                                              share|improve this answer



                                                                                                                              share|improve this answer








                                                                                                                              edited Mar 1 at 11:29

























                                                                                                                              answered Mar 1 at 10:34









                                                                                                                              EmignaEmigna

                                                                                                                              46.7k432142




                                                                                                                              46.7k432142








                                                                                                                              • 1




                                                                                                                                $begingroup$
                                                                                                                                An exception is acceptable, the C# answer does it
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                Mar 1 at 11:22














                                                                                                                              • 1




                                                                                                                                $begingroup$
                                                                                                                                An exception is acceptable, the C# answer does it
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                Mar 1 at 11:22








                                                                                                                              1




                                                                                                                              1




                                                                                                                              $begingroup$
                                                                                                                              An exception is acceptable, the C# answer does it
                                                                                                                              $endgroup$
                                                                                                                              – ASCII-only
                                                                                                                              Mar 1 at 11:22




                                                                                                                              $begingroup$
                                                                                                                              An exception is acceptable, the C# answer does it
                                                                                                                              $endgroup$
                                                                                                                              – ASCII-only
                                                                                                                              Mar 1 at 11:22











                                                                                                                              1












                                                                                                                              $begingroup$


                                                                                                                              Wolfram Language (Mathematica), 37 bytes 36 bytes 29 bytes



                                                                                                                              -2 bytes by Jonathan Frech



                                                                                                                              #~IntegerDigits~32~MemberQ~4&


                                                                                                                              Try it online!



                                                                                                                              31-byte solution:



                                                                                                                              MemberQ[IntegerDigits[#,32],4]&


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$













                                                                                                                              • $begingroup$
                                                                                                                                Hello and welcome to PPCG. As it stands, your expression is a single Boolean value. Please fix your answer to either be a full program or a function (...#...& is often used in Mathematica).
                                                                                                                                $endgroup$
                                                                                                                                – Jonathan Frech
                                                                                                                                Feb 27 at 9:22










                                                                                                                              • $begingroup$
                                                                                                                                Hello. Is this what you mean?
                                                                                                                                $endgroup$
                                                                                                                                – Rainer Glüge
                                                                                                                                Feb 27 at 9:32










                                                                                                                              • $begingroup$
                                                                                                                                pls use tio.run/#mathematica instead of W|A to make sure it's valid mathematica code :P and you don't need the [n] at the end, just the &. Also since posts have edit history, it's fine to leave out previous entries, and the convention for old scores is <s>40</s> <s>36</s>
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                Feb 27 at 10:22












                                                                                                                              • $begingroup$
                                                                                                                                Yes. This is what I meant. 29 bytes.
                                                                                                                                $endgroup$
                                                                                                                                – Jonathan Frech
                                                                                                                                Feb 27 at 13:17










                                                                                                                              • $begingroup$
                                                                                                                                I guess I have to get used to the functional programming style.
                                                                                                                                $endgroup$
                                                                                                                                – Rainer Glüge
                                                                                                                                Feb 27 at 13:34
















                                                                                                                              1












                                                                                                                              $begingroup$


                                                                                                                              Wolfram Language (Mathematica), 37 bytes 36 bytes 29 bytes



                                                                                                                              -2 bytes by Jonathan Frech



                                                                                                                              #~IntegerDigits~32~MemberQ~4&


                                                                                                                              Try it online!



                                                                                                                              31-byte solution:



                                                                                                                              MemberQ[IntegerDigits[#,32],4]&


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$













                                                                                                                              • $begingroup$
                                                                                                                                Hello and welcome to PPCG. As it stands, your expression is a single Boolean value. Please fix your answer to either be a full program or a function (...#...& is often used in Mathematica).
                                                                                                                                $endgroup$
                                                                                                                                – Jonathan Frech
                                                                                                                                Feb 27 at 9:22










                                                                                                                              • $begingroup$
                                                                                                                                Hello. Is this what you mean?
                                                                                                                                $endgroup$
                                                                                                                                – Rainer Glüge
                                                                                                                                Feb 27 at 9:32










                                                                                                                              • $begingroup$
                                                                                                                                pls use tio.run/#mathematica instead of W|A to make sure it's valid mathematica code :P and you don't need the [n] at the end, just the &. Also since posts have edit history, it's fine to leave out previous entries, and the convention for old scores is <s>40</s> <s>36</s>
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                Feb 27 at 10:22












                                                                                                                              • $begingroup$
                                                                                                                                Yes. This is what I meant. 29 bytes.
                                                                                                                                $endgroup$
                                                                                                                                – Jonathan Frech
                                                                                                                                Feb 27 at 13:17










                                                                                                                              • $begingroup$
                                                                                                                                I guess I have to get used to the functional programming style.
                                                                                                                                $endgroup$
                                                                                                                                – Rainer Glüge
                                                                                                                                Feb 27 at 13:34














                                                                                                                              1












                                                                                                                              1








                                                                                                                              1





                                                                                                                              $begingroup$


                                                                                                                              Wolfram Language (Mathematica), 37 bytes 36 bytes 29 bytes



                                                                                                                              -2 bytes by Jonathan Frech



                                                                                                                              #~IntegerDigits~32~MemberQ~4&


                                                                                                                              Try it online!



                                                                                                                              31-byte solution:



                                                                                                                              MemberQ[IntegerDigits[#,32],4]&


                                                                                                                              Try it online!






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$




                                                                                                                              Wolfram Language (Mathematica), 37 bytes 36 bytes 29 bytes



                                                                                                                              -2 bytes by Jonathan Frech



                                                                                                                              #~IntegerDigits~32~MemberQ~4&


                                                                                                                              Try it online!



                                                                                                                              31-byte solution:



                                                                                                                              MemberQ[IntegerDigits[#,32],4]&


                                                                                                                              Try it online!







                                                                                                                              share|improve this answer














                                                                                                                              share|improve this answer



                                                                                                                              share|improve this answer








                                                                                                                              edited Mar 2 at 1:49









                                                                                                                              lirtosiast

                                                                                                                              18.2k438109




                                                                                                                              18.2k438109










                                                                                                                              answered Feb 27 at 9:03









                                                                                                                              Rainer GlügeRainer Glüge

                                                                                                                              1213




                                                                                                                              1213












                                                                                                                              • $begingroup$
                                                                                                                                Hello and welcome to PPCG. As it stands, your expression is a single Boolean value. Please fix your answer to either be a full program or a function (...#...& is often used in Mathematica).
                                                                                                                                $endgroup$
                                                                                                                                – Jonathan Frech
                                                                                                                                Feb 27 at 9:22










                                                                                                                              • $begingroup$
                                                                                                                                Hello. Is this what you mean?
                                                                                                                                $endgroup$
                                                                                                                                – Rainer Glüge
                                                                                                                                Feb 27 at 9:32










                                                                                                                              • $begingroup$
                                                                                                                                pls use tio.run/#mathematica instead of W|A to make sure it's valid mathematica code :P and you don't need the [n] at the end, just the &. Also since posts have edit history, it's fine to leave out previous entries, and the convention for old scores is <s>40</s> <s>36</s>
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                Feb 27 at 10:22












                                                                                                                              • $begingroup$
                                                                                                                                Yes. This is what I meant. 29 bytes.
                                                                                                                                $endgroup$
                                                                                                                                – Jonathan Frech
                                                                                                                                Feb 27 at 13:17










                                                                                                                              • $begingroup$
                                                                                                                                I guess I have to get used to the functional programming style.
                                                                                                                                $endgroup$
                                                                                                                                – Rainer Glüge
                                                                                                                                Feb 27 at 13:34


















                                                                                                                              • $begingroup$
                                                                                                                                Hello and welcome to PPCG. As it stands, your expression is a single Boolean value. Please fix your answer to either be a full program or a function (...#...& is often used in Mathematica).
                                                                                                                                $endgroup$
                                                                                                                                – Jonathan Frech
                                                                                                                                Feb 27 at 9:22










                                                                                                                              • $begingroup$
                                                                                                                                Hello. Is this what you mean?
                                                                                                                                $endgroup$
                                                                                                                                – Rainer Glüge
                                                                                                                                Feb 27 at 9:32










                                                                                                                              • $begingroup$
                                                                                                                                pls use tio.run/#mathematica instead of W|A to make sure it's valid mathematica code :P and you don't need the [n] at the end, just the &. Also since posts have edit history, it's fine to leave out previous entries, and the convention for old scores is <s>40</s> <s>36</s>
                                                                                                                                $endgroup$
                                                                                                                                – ASCII-only
                                                                                                                                Feb 27 at 10:22












                                                                                                                              • $begingroup$
                                                                                                                                Yes. This is what I meant. 29 bytes.
                                                                                                                                $endgroup$
                                                                                                                                – Jonathan Frech
                                                                                                                                Feb 27 at 13:17










                                                                                                                              • $begingroup$
                                                                                                                                I guess I have to get used to the functional programming style.
                                                                                                                                $endgroup$
                                                                                                                                – Rainer Glüge
                                                                                                                                Feb 27 at 13:34
















                                                                                                                              $begingroup$
                                                                                                                              Hello and welcome to PPCG. As it stands, your expression is a single Boolean value. Please fix your answer to either be a full program or a function (...#...& is often used in Mathematica).
                                                                                                                              $endgroup$
                                                                                                                              – Jonathan Frech
                                                                                                                              Feb 27 at 9:22




                                                                                                                              $begingroup$
                                                                                                                              Hello and welcome to PPCG. As it stands, your expression is a single Boolean value. Please fix your answer to either be a full program or a function (...#...& is often used in Mathematica).
                                                                                                                              $endgroup$
                                                                                                                              – Jonathan Frech
                                                                                                                              Feb 27 at 9:22












                                                                                                                              $begingroup$
                                                                                                                              Hello. Is this what you mean?
                                                                                                                              $endgroup$
                                                                                                                              – Rainer Glüge
                                                                                                                              Feb 27 at 9:32




                                                                                                                              $begingroup$
                                                                                                                              Hello. Is this what you mean?
                                                                                                                              $endgroup$
                                                                                                                              – Rainer Glüge
                                                                                                                              Feb 27 at 9:32












                                                                                                                              $begingroup$
                                                                                                                              pls use tio.run/#mathematica instead of W|A to make sure it's valid mathematica code :P and you don't need the [n] at the end, just the &. Also since posts have edit history, it's fine to leave out previous entries, and the convention for old scores is <s>40</s> <s>36</s>
                                                                                                                              $endgroup$
                                                                                                                              – ASCII-only
                                                                                                                              Feb 27 at 10:22






                                                                                                                              $begingroup$
                                                                                                                              pls use tio.run/#mathematica instead of W|A to make sure it's valid mathematica code :P and you don't need the [n] at the end, just the &. Also since posts have edit history, it's fine to leave out previous entries, and the convention for old scores is <s>40</s> <s>36</s>
                                                                                                                              $endgroup$
                                                                                                                              – ASCII-only
                                                                                                                              Feb 27 at 10:22














                                                                                                                              $begingroup$
                                                                                                                              Yes. This is what I meant. 29 bytes.
                                                                                                                              $endgroup$
                                                                                                                              – Jonathan Frech
                                                                                                                              Feb 27 at 13:17




                                                                                                                              $begingroup$
                                                                                                                              Yes. This is what I meant. 29 bytes.
                                                                                                                              $endgroup$
                                                                                                                              – Jonathan Frech
                                                                                                                              Feb 27 at 13:17












                                                                                                                              $begingroup$
                                                                                                                              I guess I have to get used to the functional programming style.
                                                                                                                              $endgroup$
                                                                                                                              – Rainer Glüge
                                                                                                                              Feb 27 at 13:34




                                                                                                                              $begingroup$
                                                                                                                              I guess I have to get used to the functional programming style.
                                                                                                                              $endgroup$
                                                                                                                              – Rainer Glüge
                                                                                                                              Feb 27 at 13:34











                                                                                                                              1












                                                                                                                              $begingroup$

                                                                                                                              x86 machine code, 14 bytes



                                                                                                                              (same machine code works in 16-bit, 32-bit, and 64-bit. In 16-bit mode, it uses AX and DI instead of EAX and EDI in 32 and 64-bit mode.)



                                                                                                                              Algorithm: check low 5 bits with x & 31 == 4, then right-shift by 5 bits, and repeat if the shift result is non-zero.



                                                                                                                              Callable from C with char isrude(unsigned n); according to the x86-64 System V calling convention. 0 is truthy, non-0 is falsy (this is asm, not C1).



                                                                                                                               line   addr    code bytes
                                                                                                                              num
                                                                                                                              1 ; input: number in EDI
                                                                                                                              2 ; output: integer result in AL: 0 -> rude, non-zero non-rude
                                                                                                                              3 ; clobbers: RDI
                                                                                                                              4 isrude:
                                                                                                                              5 .check_low_bitgroup:
                                                                                                                              6 00000000 89F8 mov eax, edi
                                                                                                                              7 00000002 241F and al, 31 ; isolate low 5 bits
                                                                                                                              8 00000004 2C04 sub al, 4 ; like cmp but leaves AL 0 or non-zero
                                                                                                                              9 00000006 7405 jz .rude ; if (al & 31 == 4) return 0;
                                                                                                                              10
                                                                                                                              11 00000008 C1EF05 shr edi, 5
                                                                                                                              12 0000000B 75F3 jnz .check_low_bitgroup
                                                                                                                              13 ;; fall through to here is only possible if AL is non-zero
                                                                                                                              14 .rude:
                                                                                                                              15 0000000D C3 ret


                                                                                                                              16 0E size: db $ - isrude


                                                                                                                              This takes advantage of the short-form op al, imm8 encoding for AND and SUB. I could have used XOR al,4 to produce 0 on equality, but SUB is faster because it can macro-fuse with JZ into a single sub-and-branch uop on Sandybridge-family.



                                                                                                                              Fun fact: using the flag-result of a shift by more than 1 will be slow on P6-family (front-end stalls until the shift retires), but that's fine.





                                                                                                                              Footnote 1: This is an assembly language function, and x86 asm has both jz and jnz, so as per meta I can choose either way. I'm not intending this to match C truthy/falsy.



                                                                                                                              It happened to be convenient to return in AL instead of EFLAGS, so we can describe the function to a C compiler without a wrapper, but my choice of truthy/falsy isn't constrained by using a C caller to test it.






                                                                                                                              share|improve this answer









                                                                                                                              $endgroup$


















                                                                                                                                1












                                                                                                                                $begingroup$

                                                                                                                                x86 machine code, 14 bytes



                                                                                                                                (same machine code works in 16-bit, 32-bit, and 64-bit. In 16-bit mode, it uses AX and DI instead of EAX and EDI in 32 and 64-bit mode.)



                                                                                                                                Algorithm: check low 5 bits with x & 31 == 4, then right-shift by 5 bits, and repeat if the shift result is non-zero.



                                                                                                                                Callable from C with char isrude(unsigned n); according to the x86-64 System V calling convention. 0 is truthy, non-0 is falsy (this is asm, not C1).



                                                                                                                                 line   addr    code bytes
                                                                                                                                num
                                                                                                                                1 ; input: number in EDI
                                                                                                                                2 ; output: integer result in AL: 0 -> rude, non-zero non-rude
                                                                                                                                3 ; clobbers: RDI
                                                                                                                                4 isrude:
                                                                                                                                5 .check_low_bitgroup:
                                                                                                                                6 00000000 89F8 mov eax, edi
                                                                                                                                7 00000002 241F and al, 31 ; isolate low 5 bits
                                                                                                                                8 00000004 2C04 sub al, 4 ; like cmp but leaves AL 0 or non-zero
                                                                                                                                9 00000006 7405 jz .rude ; if (al & 31 == 4) return 0;
                                                                                                                                10
                                                                                                                                11 00000008 C1EF05 shr edi, 5
                                                                                                                                12 0000000B 75F3 jnz .check_low_bitgroup
                                                                                                                                13 ;; fall through to here is only possible if AL is non-zero
                                                                                                                                14 .rude:
                                                                                                                                15 0000000D C3 ret


                                                                                                                                16 0E size: db $ - isrude


                                                                                                                                This takes advantage of the short-form op al, imm8 encoding for AND and SUB. I could have used XOR al,4 to produce 0 on equality, but SUB is faster because it can macro-fuse with JZ into a single sub-and-branch uop on Sandybridge-family.



                                                                                                                                Fun fact: using the flag-result of a shift by more than 1 will be slow on P6-family (front-end stalls until the shift retires), but that's fine.





                                                                                                                                Footnote 1: This is an assembly language function, and x86 asm has both jz and jnz, so as per meta I can choose either way. I'm not intending this to match C truthy/falsy.



                                                                                                                                It happened to be convenient to return in AL instead of EFLAGS, so we can describe the function to a C compiler without a wrapper, but my choice of truthy/falsy isn't constrained by using a C caller to test it.






                                                                                                                                share|improve this answer









                                                                                                                                $endgroup$
















                                                                                                                                  1












                                                                                                                                  1








                                                                                                                                  1





                                                                                                                                  $begingroup$

                                                                                                                                  x86 machine code, 14 bytes



                                                                                                                                  (same machine code works in 16-bit, 32-bit, and 64-bit. In 16-bit mode, it uses AX and DI instead of EAX and EDI in 32 and 64-bit mode.)



                                                                                                                                  Algorithm: check low 5 bits with x & 31 == 4, then right-shift by 5 bits, and repeat if the shift result is non-zero.



                                                                                                                                  Callable from C with char isrude(unsigned n); according to the x86-64 System V calling convention. 0 is truthy, non-0 is falsy (this is asm, not C1).



                                                                                                                                   line   addr    code bytes
                                                                                                                                  num
                                                                                                                                  1 ; input: number in EDI
                                                                                                                                  2 ; output: integer result in AL: 0 -> rude, non-zero non-rude
                                                                                                                                  3 ; clobbers: RDI
                                                                                                                                  4 isrude:
                                                                                                                                  5 .check_low_bitgroup:
                                                                                                                                  6 00000000 89F8 mov eax, edi
                                                                                                                                  7 00000002 241F and al, 31 ; isolate low 5 bits
                                                                                                                                  8 00000004 2C04 sub al, 4 ; like cmp but leaves AL 0 or non-zero
                                                                                                                                  9 00000006 7405 jz .rude ; if (al & 31 == 4) return 0;
                                                                                                                                  10
                                                                                                                                  11 00000008 C1EF05 shr edi, 5
                                                                                                                                  12 0000000B 75F3 jnz .check_low_bitgroup
                                                                                                                                  13 ;; fall through to here is only possible if AL is non-zero
                                                                                                                                  14 .rude:
                                                                                                                                  15 0000000D C3 ret


                                                                                                                                  16 0E size: db $ - isrude


                                                                                                                                  This takes advantage of the short-form op al, imm8 encoding for AND and SUB. I could have used XOR al,4 to produce 0 on equality, but SUB is faster because it can macro-fuse with JZ into a single sub-and-branch uop on Sandybridge-family.



                                                                                                                                  Fun fact: using the flag-result of a shift by more than 1 will be slow on P6-family (front-end stalls until the shift retires), but that's fine.





                                                                                                                                  Footnote 1: This is an assembly language function, and x86 asm has both jz and jnz, so as per meta I can choose either way. I'm not intending this to match C truthy/falsy.



                                                                                                                                  It happened to be convenient to return in AL instead of EFLAGS, so we can describe the function to a C compiler without a wrapper, but my choice of truthy/falsy isn't constrained by using a C caller to test it.






                                                                                                                                  share|improve this answer









                                                                                                                                  $endgroup$



                                                                                                                                  x86 machine code, 14 bytes



                                                                                                                                  (same machine code works in 16-bit, 32-bit, and 64-bit. In 16-bit mode, it uses AX and DI instead of EAX and EDI in 32 and 64-bit mode.)



                                                                                                                                  Algorithm: check low 5 bits with x & 31 == 4, then right-shift by 5 bits, and repeat if the shift result is non-zero.



                                                                                                                                  Callable from C with char isrude(unsigned n); according to the x86-64 System V calling convention. 0 is truthy, non-0 is falsy (this is asm, not C1).



                                                                                                                                   line   addr    code bytes
                                                                                                                                  num
                                                                                                                                  1 ; input: number in EDI
                                                                                                                                  2 ; output: integer result in AL: 0 -> rude, non-zero non-rude
                                                                                                                                  3 ; clobbers: RDI
                                                                                                                                  4 isrude:
                                                                                                                                  5 .check_low_bitgroup:
                                                                                                                                  6 00000000 89F8 mov eax, edi
                                                                                                                                  7 00000002 241F and al, 31 ; isolate low 5 bits
                                                                                                                                  8 00000004 2C04 sub al, 4 ; like cmp but leaves AL 0 or non-zero
                                                                                                                                  9 00000006 7405 jz .rude ; if (al & 31 == 4) return 0;
                                                                                                                                  10
                                                                                                                                  11 00000008 C1EF05 shr edi, 5
                                                                                                                                  12 0000000B 75F3 jnz .check_low_bitgroup
                                                                                                                                  13 ;; fall through to here is only possible if AL is non-zero
                                                                                                                                  14 .rude:
                                                                                                                                  15 0000000D C3 ret


                                                                                                                                  16 0E size: db $ - isrude


                                                                                                                                  This takes advantage of the short-form op al, imm8 encoding for AND and SUB. I could have used XOR al,4 to produce 0 on equality, but SUB is faster because it can macro-fuse with JZ into a single sub-and-branch uop on Sandybridge-family.



                                                                                                                                  Fun fact: using the flag-result of a shift by more than 1 will be slow on P6-family (front-end stalls until the shift retires), but that's fine.





                                                                                                                                  Footnote 1: This is an assembly language function, and x86 asm has both jz and jnz, so as per meta I can choose either way. I'm not intending this to match C truthy/falsy.



                                                                                                                                  It happened to be convenient to return in AL instead of EFLAGS, so we can describe the function to a C compiler without a wrapper, but my choice of truthy/falsy isn't constrained by using a C caller to test it.







                                                                                                                                  share|improve this answer












                                                                                                                                  share|improve this answer



                                                                                                                                  share|improve this answer










                                                                                                                                  answered Mar 4 at 0:21









                                                                                                                                  Peter CordesPeter Cordes

                                                                                                                                  2,0921018




                                                                                                                                  2,0921018























                                                                                                                                      1












                                                                                                                                      $begingroup$

                                                                                                                                      Java 8, 28 22 21 bytes





                                                                                                                                      n->n%32==4|n>>5%32==4


                                                                                                                                      Inspired by @kevin-cruijssen's answer. Only works for 2 hands.



                                                                                                                                      Try it online!



                                                                                                                                      Explanation:



                                                                                                                                      n->                 // Method with int parameter and boolean return-type
                                                                                                                                      n%32 // Only consider right 5 bytes (fingers)
                                                                                                                                      ==4 // Middle finger
                                                                                                                                      | ... n>>5 // Repeat with shifted bits for other hand





                                                                                                                                      share|improve this answer










                                                                                                                                      New contributor




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






                                                                                                                                      $endgroup$


















                                                                                                                                        1












                                                                                                                                        $begingroup$

                                                                                                                                        Java 8, 28 22 21 bytes





                                                                                                                                        n->n%32==4|n>>5%32==4


                                                                                                                                        Inspired by @kevin-cruijssen's answer. Only works for 2 hands.



                                                                                                                                        Try it online!



                                                                                                                                        Explanation:



                                                                                                                                        n->                 // Method with int parameter and boolean return-type
                                                                                                                                        n%32 // Only consider right 5 bytes (fingers)
                                                                                                                                        ==4 // Middle finger
                                                                                                                                        | ... n>>5 // Repeat with shifted bits for other hand





                                                                                                                                        share|improve this answer










                                                                                                                                        New contributor




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






                                                                                                                                        $endgroup$
















                                                                                                                                          1












                                                                                                                                          1








                                                                                                                                          1





                                                                                                                                          $begingroup$

                                                                                                                                          Java 8, 28 22 21 bytes





                                                                                                                                          n->n%32==4|n>>5%32==4


                                                                                                                                          Inspired by @kevin-cruijssen's answer. Only works for 2 hands.



                                                                                                                                          Try it online!



                                                                                                                                          Explanation:



                                                                                                                                          n->                 // Method with int parameter and boolean return-type
                                                                                                                                          n%32 // Only consider right 5 bytes (fingers)
                                                                                                                                          ==4 // Middle finger
                                                                                                                                          | ... n>>5 // Repeat with shifted bits for other hand





                                                                                                                                          share|improve this answer










                                                                                                                                          New contributor




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






                                                                                                                                          $endgroup$



                                                                                                                                          Java 8, 28 22 21 bytes





                                                                                                                                          n->n%32==4|n>>5%32==4


                                                                                                                                          Inspired by @kevin-cruijssen's answer. Only works for 2 hands.



                                                                                                                                          Try it online!



                                                                                                                                          Explanation:



                                                                                                                                          n->                 // Method with int parameter and boolean return-type
                                                                                                                                          n%32 // Only consider right 5 bytes (fingers)
                                                                                                                                          ==4 // Middle finger
                                                                                                                                          | ... n>>5 // Repeat with shifted bits for other hand






                                                                                                                                          share|improve this answer










                                                                                                                                          New contributor




                                                                                                                                          Daniel Widdis 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 answer



                                                                                                                                          share|improve this answer








                                                                                                                                          edited 2 days ago





















                                                                                                                                          New contributor




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









                                                                                                                                          answered 2 days ago









                                                                                                                                          Daniel WiddisDaniel Widdis

                                                                                                                                          1114




                                                                                                                                          1114




                                                                                                                                          New contributor




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





                                                                                                                                          New contributor





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






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






















                                                                                                                                              1 2
                                                                                                                                              next

















                                                                                                                                              draft saved

                                                                                                                                              draft discarded




















































                                                                                                                                              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%2f180481%2fam-i-a-rude-number%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

                                                                                                                                              Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                                                                                                                                              ComboBox Display Member on multiple fields

                                                                                                                                              Is it possible to collect Nectar points via Trainline?