Am I a Rude Number?

72

6

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 , so the lowest score in bytes wins.

Gryphon

Posted 2019-02-27T03:21:25.830

Reputation: 6 697

43assume we continue with a third hand, When it comes to being rude, teamwork makes the dream work. – Veskah – 2019-02-27T03:24:40.217

5@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. – Gryphon – 2019-02-27T03:26:57.363

Also, I don't have the time at the moment, but if anyone could figure out an equation for this sequence, that'd be great. – Gryphon – 2019-02-27T03:30:03.793

12It's worse if you're British - 6 is rude too then! – Matthew – 2019-02-27T07:07:48.510

1Is it OK to take input in a different base than 10? – wastl – 2019-02-27T20:08:12.470

25 seems fairly rude too. Not sure anyone would say "Oh she had her thumb out, that's perfectly polite" – ale10ander – 2019-03-01T01:43:15.897

1@Matthew 6 is a lot worse than 4 ... (upvoted your comment so it wouldn't be considered rude in the uk) – Tom Tanner – 2019-03-01T11:42:24.160

and 18 means 'cuckold'.... – Tom Tanner – 2019-03-01T11:44:19.313

1I wouldn't have even thought to convert to base 32. These answers are clever. – Kyle Delaney – 2019-03-01T17:49:22.697

Is there an OEIS for this? – MickyT – 2019-03-04T03:49:36.877

@MickyT No. At least currently no. – tsh – 2019-03-04T05:12:35.697

Answers

30

APL (dzaima/APL), 5 bytes

4∊32⊤

Try it online!

4∊ is 4 a member of

32⊤ to-base-32?

Adám

Posted 2019-02-27T03:21:25.830

Reputation: 37 779

s/bytes/characters though? – tripleee – 2019-02-27T10:34:13.127

@tripleee Thanks, added. – Adám – 2019-02-27T11:30:55.917

18

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

Deadcode

Posted 2019-02-27T03:21:25.830

Reputation: 3 022

13I thought I knew regex, but apparently not. – CT Hall – 2019-02-28T04:16:34.767

14

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).

tsh

Posted 2019-02-27T03:21:25.830

Reputation: 13 072

10

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)

ASCII-only

Posted 2019-02-27T03:21:25.830

Reputation: 4 687

8

Ruby, 36 19 bytes

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

Try it online!

Saved 17 bytes with @tsh's method.

Doorknob

Posted 2019-02-27T03:21:25.830

Reputation: 68 138

This returns true for 2207, which has a binary representation of 100010011111 – Embodiment of Ignorance – 2019-02-27T04:10:14.500

@EmbodimentofIgnorance That is the correct result, is it not? The second hand is 00100. – Doorknob – 2019-02-27T04:16:26.967

I don't speak Ruby. But why not ->n{n.to_s(32)=~/4/}? – tsh – 2019-02-27T04:19:57.880

1@tsh because I'm not as clever as you :) – Doorknob – 2019-02-27T04:23:16.347

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 – Embodiment of Ignorance – 2019-02-27T04:28:30.163

@EmbodimentofIgnorance No, you do it from right to left. 2207 → 100010011111 → first hand 11111, second hand 00100, third hand 00010. – Deadcode – 2019-02-27T04:30:55.947

Ah, I see. Disregard my above comments. – Embodiment of Ignorance – 2019-02-27T04:32:48.220

The question states that the maximum value is 1024 (2^10) anyways. – Tvde1 – 2019-02-28T10:32:12.307

8

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.

Graham

Posted 2019-02-27T03:21:25.830

Reputation: 3 184

6

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.

Jo King

Posted 2019-02-27T03:21:25.830

Reputation: 38 234

6

Python 2, 34 32 bytes

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

Try it online!

2 bytes thanks to tsh

Chas Brown

Posted 2019-02-27T03:21:25.830

Reputation: 8 959

1:| you can edit posts, you know that right – ASCII-only – 2019-02-27T07:37:42.610

Yes; I know. It was an accident! An accident, I tell ya! – Chas Brown – 2019-02-27T08:52:46.770

@tsh Oh nice, forgot that shortcircuits – ASCII-only – 2019-02-27T10:24:40.880

6

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!

Cody Gray

Posted 2019-02-27T03:21:25.830

Reputation: 2 639

1

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.

– Peter Cordes – 2019-03-04T00:25:04.827

4

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!

Embodiment of Ignorance

Posted 2019-02-27T03:21:25.830

Reputation: 7 014

27? as a bonus it doesn't output in a weird way – ASCII-only – 2019-02-27T06:13:02.467

1also what is tplig – ASCII-only – 2019-02-27T06:15:50.077

@ASCII-only n>31 -> n>0 – tsh – 2019-02-27T06:17:50.207

25 bytes – Kevin Cruijssen – 2019-02-27T12:57:47.223

@Kevin Cruijssen @ASCII-only Recursive functions must have their declarations, so it would have to have a void f(...)..., massively increasing the byte count – Embodiment of Ignorance – 2019-02-27T21:04:40.413

yeah :/ (also... lambda is shorter than function here. byte count is still massive though, yes). Disappointingly, C# doesn't have a short builtin base conversion function – ASCII-only – 2019-02-28T08:01:17.240

Your first "Try it online!" tells me "4 isn't a rude number.". Your 2nd "Try it online." fails to compile. – Tvde1 – 2019-02-28T10:34:03.730

@Tvde1 fixed now, I messed the code on the footer for the second one. I deleted the first one since it was longer anyways – Embodiment of Ignorance – 2019-02-28T17:41:07.177

1

Whether or not a program halts is not an allowed output method. Output via exception is allowed.

– Deadcode – 2019-02-28T22:58:34.720

4

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!

Kirill L.

Posted 2019-02-27T03:21:25.830

Reputation: 6 693

could you use n->n%32... for your first answer for 2 bytes shorter? – Giuseppe – 2019-02-28T22:48:17.230

@Giuseppe, unfortunately no, that function is recursive. – Kirill L. – 2019-03-01T07:34:28.290

4

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)

Kevin Cruijssen

Posted 2019-02-27T03:21:25.830

Reputation: 67 575

1Too bad is 36, not 32. – Magic Octopus Urn – 2019-02-28T19:51:01.430

4

Catholicon, 4 bytes

ǔ?QǑ

Takes a number as a base-256 string.

Try it online!

Test suite

Okx

Posted 2019-02-27T03:21:25.830

Reputation: 15 025

2Hm, if this is allowed, then is it allowed to accept numbers in base 32 instead? – recursive – 2019-02-27T19:47:09.877

@recursive You can surround the numbers in << and >> and it allows for numbers greater than 255 in those, as shown in the test suite. – Okx – 2019-02-28T13:11:04.783

1It was intended as a question about the challenge but it wasn't very clear. – recursive – 2019-02-28T15:44:36.477

3

J, 12 bytes

4 e.32#.inv]

Try it online!

Galen Ivanov

Posted 2019-02-27T03:21:25.830

Reputation: 13 815

3

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.

Nick Kennedy

Posted 2019-02-27T03:21:25.830

Reputation: 11 829

@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 – Nick Kennedy – 2019-02-28T17:45:55.237

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 – Giuseppe – 2019-02-28T18:04:49.057

@Giuseppe it's a completely different (and neat) solution to mine - do you want me to update mine or you post your own? – Nick Kennedy – 2019-02-28T18:18:26.527

you're free to take it. :-) – Giuseppe – 2019-02-28T18:24:36.023

1

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.

– Giuseppe – 2019-02-28T22:46:57.380

2

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!

Neil A.

Posted 2019-02-27T03:21:25.830

Reputation: 2 038

*5-bit chunk... – ASCII-only – 2019-02-27T07:38:41.477

2

C (gcc), 34 bytes

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

Try it online!

celtschk

Posted 2019-02-27T03:21:25.830

Reputation: 4 650

32 bytes by rearranging the expression. – Arnauld – 2019-02-27T10:11:54.390

3

or 25 bytes by abusing the way gcc is compiling this.

– Arnauld – 2019-02-27T10:11:57.543

2

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.

Neil

Posted 2019-02-27T03:21:25.830

Reputation: 95 035

2

Tidy, 18 bytes

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

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

Conor O'Brien

Posted 2019-02-27T03:21:25.830

Reputation: 36 228

2

Haskell, 31 bytes

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

Try it online!

xnor

Posted 2019-02-27T03:21:25.830

Reputation: 115 687

2

MATL, 8 bytes

32YA52=a

Try it online!

Sanchises

Posted 2019-02-27T03:21:25.830

Reputation: 8 530

@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? – Sanchises – 2019-03-01T07:06:43.623

Ah, yes, I can't count – Luis Mendo – 2019-03-01T10:26:32.543

2@Luis Count? Who needs to count when you can '32_YA4'n'32YA52'n- – Sanchises – 2019-03-01T11:56:32.410

2

ES6, 31 30 26 bytes

b=>b.toString(32).match`4`

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

elipszilon

Posted 2019-02-27T03:21:25.830

Reputation: 61

Welcome to PPCG! – Laikoni – 2019-02-28T19:23:46.523

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. – Neil – 2019-03-01T00:53:04.853

2

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

MickyT

Posted 2019-02-27T03:21:25.830

Reputation: 11 735

2

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.

Neil

Posted 2019-02-27T03:21:25.830

Reputation: 95 035

2

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.

Peter Cordes

Posted 2019-02-27T03:21:25.830

Reputation: 2 810

1

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!

Rainer Glüge

Posted 2019-02-27T03:21:25.830

Reputation: 131

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). – Jonathan Frech – 2019-02-27T09:22:51.433

Hello. Is this what you mean? – Rainer Glüge – 2019-02-27T09:32:33.340

pls use https://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>

– ASCII-only – 2019-02-27T10:22:15.813

Yes. This is what I meant. 29 bytes.

– Jonathan Frech – 2019-02-27T13:17:56.763

I guess I have to get used to the functional programming style. – Rainer Glüge – 2019-02-27T13:34:53.320

1

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"

Kevin Cruijssen

Posted 2019-02-27T03:21:25.830

Reputation: 67 575

1

Retina 0.8.2, 31 bytes

.+
$*
+`(1+)\1{31}
$1;
\b1111\b

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.

Neil

Posted 2019-02-27T03:21:25.830

Reputation: 95 035

1

><>, 28 bytes

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

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

Try it online!

Emigna

Posted 2019-02-27T03:21:25.830

Reputation: 50 798

1An exception is acceptable, the C# answer does it – ASCII-only – 2019-03-01T11:22:40.783

1

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

Daniel Widdis

Posted 2019-02-27T03:21:25.830

Reputation: 159

I'm pretty sure answers have to work with both hands – Embodiment of Ignorance – 2019-05-09T03:41:52.973

0

Perl 5, 43 bytes

sub f{sprintf("%099b",@_)=~/00100(.{5})*$/}

Try it online!

Kjetil S.

Posted 2019-02-27T03:21:25.830

Reputation: 1 049

0

Ink, 38 36 bytes

=r(n)
{n:{n%32-4:->r(n/32)|1}|0}->->

Try it online!

Edit: Saved 2 bytes by simplifying the first conditional to "if n" rather than "if n>0".

Sara J

Posted 2019-02-27T03:21:25.830

Reputation: 2 576

0

K 8 Bytes

|/4=32\:

True if any digit of 32-base is 4

  • 32\: converts its argument to 32-base

  • 4=32\: compares 4 with each of the digits of 32: (generates a boolean list)

  • |/ is max-over the boolean list (any)

NOTES:

  • Use example: for argument 131 |/4=32\:131 returns 1b (1b for true 0b for false)

  • For all the case tests: (|/4=32\:)'0 3 4 25 36 127 131 returns 0010101b

  • If a function is needed, use {|/4=32\:x} (lambda, 11 Bytes) or with name r:{|/4=32\:x}. For all case tests {|/4=32\:x}'0 3 4 25 36 127 131 or r'0 3 4 25 36 127 131

  • 4 in 32\: is easier to read than |/4=32\:, but it's longer (9 bytes)

J. Sendra

Posted 2019-02-27T03:21:25.830

Reputation: 396

0

Java 1, 42 40 bytes

r(int n){return n>0&&(4==n%32|r(n>>5));}

Edit: Replaced ternary operator with && to save 1 char, thanks to @Dillon Davis, which works due to short-circuit; inspiring me to change || to | to save another character

Try it online.

Explanation:

r(int n)        // Method with int parameter and boolean return-type
  n>0           // Stop recursion if no more bits
  &&            // Short-circuit stops recursion
  n%32=4        // Rude
  | r(n>>5)     // Recurse with shifted bits

Daniel Widdis

Posted 2019-02-27T03:21:25.830

Reputation: 159

1Saves 1 byte r(int n){return n>0&&(4==n%32||r(n>>5));} – Dillon Davis – 2019-03-04T04:47:49.373

@DillonDavis Thanks! And that inspired me to save another byte changing || to | – Daniel Widdis – 2019-03-04T05:15:12.173

0

Kotlin, 24 bytes

Simple base-32 conversion approach.

{'4' in it.toString(32)}

{  // lambda implicitly takes an int and returns a boolean
 '4' in  // 4 is within...
        it.toString(32)  // arg written in base-32
}

Try it online!

snail_

Posted 2019-02-27T03:21:25.830

Reputation: 1 982

0

05AB1E, 5 bytes

32в4¢

Try it online!

Returns a truthy value (> 1) if the input is a rude number, and 0 otherwise. Uses a conversion to base 32 (to group by 5 bits) and tests for a 4 (00100 in binary, a rude number)

ThePlasmaRailgun

Posted 2019-02-27T03:21:25.830

Reputation: 383

lol, there's already a 5-byter – ASCII-only – 2019-03-11T00:01:29.390

That is a different language. – None – 2020-01-09T04:28:48.590

0

Perl 6, 16 bytes

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

Returns 「4」 (truthy) when given a rude number and Nil (falsy) otherwise.

bb94

Posted 2019-02-27T03:21:25.830

Reputation: 1 831

0

GolfScript, 10 bytes

Empty list is false, a list with something is true. (Seems like cheating. But it isn't.)

~32base 4&

Try it online!

Explanation

~           # Evaluate the input
 32base     # Convert to base-32
            # Copy
        4&  # Setwise and: does this list have 4?

user85052

Posted 2019-02-27T03:21:25.830

Reputation: