g | x | w | all
Bytes Lang Time Link
038jq230718T123219Zmanatwor
003Vyxal 2.4.1 K230718T105851Zlyxal
003Thunno 2 B230718T102314ZThe Thon
023APOL220114T191202ZGinger
006Husk220114T121040ZNatte
033Factor + math.unicode220114T071456Zchunes
041Java210225T041404ZUnmitiga
033PowerShell Core210222T213253ZJulian
007Pyth200909T103517ZMukundan
030PowerShell Core210223T061725Zmazzy
049Python 3.8 prerelease210222T203428ZGotoro
005Vyxal210222T075024ZDion
012NARS2000210222T150842Zjimfan
053C gcc200909T093636ZNoodle9
020GolfScript200916T202640Z2014MELO
031Zsh200916T151204ZGammaFun
052PHP200910T143059ZKaddath
052Python 3200913T010640ZSteve28
040Wolfram Language Mathematica200909T081108ZZaMoC
008Brachylog200912T084855Zxash
148C clang200909T194718Zaidan062
010x8616 machine code200911T165952Z640KB
162Rockstar200910T091721ZShaggy
076Go200911T133438Zwilkben
023MAWP200910T130743ZDion
041Clojure200911T091055ZStuart
065TSQL200910T115842Zt-clause
066Excel200910T115620ZEngineer
038R200909T092053ZDominic
021Aceto200910T064237ZL3viatha
032JavaScript200909T085744ZShaggy
020Perl 5 pF200909T140504ZNahuel F
081C# Visual C# Interactive Compiler200909T110830Zbit
032Ruby200909T103938ZRazetime
004Jelly200909T081814Zovs
039Haskell200909T102041Zrak1507
062Factor200909T090624ZGalen Iv
012Pip200909T101301ZRazetime
031Befunge98 FBBI200909T085717Zovs
036Rust200909T094825Zmadlaina
004MathGolf200909T094216ZKevin Cr
006Japt e200909T093643ZShaggy
008Charcoal200909T090601ZNeil
025C# .NET Core200909T085658ZLiefdeWe
011K oK200909T083416ZGalen Iv
007APL Dyalog Extended200909T082401ZAdá
004MATL200909T081855ZLuis Men
039Python 2200909T080624ZDion
00505AB1E200909T080646Zovs

jq, 38 characters

length as$a|explode|map(.%$a)|all(.<1)

Sample run:

bash-5.2$ jq -R 'length as$a|explode|map(.%$a)|all(.<1)' <<< 'Hello'
false

bash-5.2$ jq -R 'length as$a|explode|map(.%$a)|all(.<1)' <<< 'lol'
true

Try it online! / Try all test cases online!

Vyxal 2.4.1 K, 3 bytes

LḊΠ

Try it Online!

I too can play the K flag game, especially given that I invented it.

Thunno 2 B, 3 bytes

lḊp

Try it online!

Explanation

lḊp  # Implicit input
     # Convert to charcodes
l    # Length of input
 Ḋ   # Are they divisible
  p  # Product of the list
     # Implicit output

APOL, 23 bytes

!(x(ƒ(i %(↶(∋) l(⋒)))))

Explanation:

!(           Not
  x(         Any list item is true
    ƒ(       List-builder for
      i      Input
      %(     Modulo
        ↶(   ASCII codepoint
          ∋  Loop item
       )
       l(    Length of
         ⋒   Loop iterator (what the loop is looping through)
       )
     )
    )
  )
)

Husk, 6 bytes

Λo¦L¹c

Try it online!

Explanation

Λo¦L¹c   translates = Λo¦L⁰c⁰
Λ     ⁰  all of input:
 o   c   charcode
  ¦      divides
   L⁰    length of input

Factor + math.unicode, 33 bytes

[ dup length '[ _ mod 0 = ] ∀ ]

Try it online!

Java, 41 bytes

s->s.chars().allMatch(i->i%s.length()==0)

Try it online!

PowerShell Core, 40 33 bytes

$l=$args.Count
!($args|?{+$_%$l})

7 bytes saved thanks to mazzy

Try it online!

Pyth, 8 7 bytes

-1 byte thanks to @isaag

!%#lQCM

Try it online!

!%#lQCM
!        - logical negation of
  #      - filtering
     CM  - ascii values of input with
 % lQ    - func(x): return x % len(input) 

PowerShell Core, 30 bytes

!(($args|?{(++$l)})|?{+$_%$l})

Try it online!

Python 3.8 (pre-release), 63 49 bytes

lambda h:print({0}=={*[ord(i)%len(h)for i in h]})

Try it online!

* in the {} constructs a set which I think is more byte-efficient than using set(), which I didn't know.

----

Python 3.8 (pre-release), 42? bytes

lambda h:{0}=={*[ord(i)%len(h)for i in h]}

I can't get TIO to output the True or False. This works with IDLE or Jupyter. Try it online.

Vyxal, 8 5 bytes

₌CLœΠ

Thanks @Lyxal for saving 3 bytes Try it Online!

NARS2000 (12 characters)

(∧/0=⍴|⎕ucs)

Fork ⍴|⎕ucs finds residue of each ASCII int value when divided by length of string. ∧/0= checks if all residue are zero.

C (gcc), 54 53 bytes

l;r;f(char*s){l=strlen(s);for(r=0;*s;)r|=*s++%l;l=r;}

Try it online!

Returns falsey if the ASCII value of each character is divisible by the length of the input string or truthy otherwise.

Explanation:

l;r;f(char*s){l=strlen(s);for(r=0;*s;)r|=*s++%l;l=r;}  
l;r;                                                  // Declare 2 int variables
    f(                                                // Function f taking
      char*s){                                        //   string parameter s  
              l=strlen(s);                            // Store length of s in l
                          for(                        // Loop
                              r=0;                    //   initialising r to 0
                                  *s;)                //   until end of s  
                                      r|=             // Bitwise or r with 
                                         *s           //   the ASCII value of the next
                                                      //   character...  
                                           ++         // Aside: push s pointer forward
                                             %l;      //  ... mod the string length
                                                l=r;  // Return r (r will be 0
                                                      //   iff every character was
                                                      //   divisible by the length of the   
                                                      //   input string)

GolfScript, 20 bytes

.,0@{(3$%@+\}3$*;!\;

Try it online!

This outputs 1 if the string is divisible and 0 if it isn't. Let S be the string and L its length.

.,0@                  # The stack from bottom up will be: L  0  S
    {       }3$*      # Execute this block L times
     (                # Separate first char from the string as a number
      3$%             # Previous number mod L
         @+\          # Add result to the acumulator
                ;     # Discard the ""
                 !    # 1 iff the acumulator is 0
                  \;  # Discard L

Zsh, 31 bytes

for c (${(s::)1})((r||=#c%$#1))

Try it online!

If we accept a "list of characters" as arguments, then we don't have to split the string for 19 bytes:

for c;((r||=#c%$#))

Try it online!

PHP, 56 52 bytes

for(;$c=ord($argn[$i++]);$c%strlen($argn)?die(f):1);

Try it online!

Output is reversed

Execution stops with f if any char is not divisible, or empty string (falsy in PHP) if all are divisible

EDIT: saved 4 bytes thanks to @640KB

Python 3, 55 52 bytes

N=input();print(not sum([ord(i)%len(N) for i in N]))

Try it online!

Wolfram Language (Mathematica), 40 bytes

{0}==##&@@ToCharacterCode@#~Mod~Tr[1^#]&

Try it online!

thanks to @att for saving some bytes

Brachylog, 8 bytes

ạfᵐ∋ᵛ~l?

Try it online!

ạfᵐ∋ᵛ~l?
ạ        characters to integer
 fᵐ      find all factors
   ∋ᵛ    every list of factors contain …
     ~l? the length of the input

Alternative version,

⟨ạzl⟩%ᵛ0
⟨fhg⟩    forks! fA & gB ∧ [A, B]h
 ạzl     zip the code blocks with the length;
          [[108, 3], [111, 3], [108, 3]]
     %ᵛ0 every list must be 0 after modulo

C (clang), 149 148 bytes

#include<stdio.h>
int main(){char s[100];scanf("%s",s);int j;int k=strlen(s);for(int i=0;i<k;i++){if(s[i]%k>0){printf("0");return 0;}};printf("1");}

Try it online!

x86-16 machine code, 10 bytes

00000000: 880e 0601 acd4 0ae1 fbc3                 ..........

Listing:

88 0E 0106      MOV  BYTE PTR[CHR_LOOP+2], CL   ; move len to second byte of AAM opcode 
            CHR_LOOP: 
AC              LODSB                           ; AL = next char 
D4 0A           AAM  CL                         ; ZF = (AL % CL == 0) 
E1 FB           LOOPZ CHR_LOOP                  ; loop if CX > 0 AND ZF = 1 
C3              RET                             ; return to caller

As a callable function. Input: string in SI, length in CX. Output: ZF = 1 if Truthy, ZF = 0 if Falsey.

Output of DOS test program:

enter image description here

Rockstar, 205 192 175 162 bytes

Well, this was fun. Rockstar has no way of reading the length of a string directly, can't convert characters to codepoints and has no modulo operator. Surprised it worked out this short!

listen to S
cut S
X's0
D's0
while S at X
N's32
while N-127
cast N into C
if C is S at X
let M be N/S
turn down M
let D be+N-S*M

let N be+1

let X be+1

say not D

Try it here (Code will need to be pasted in)

Go, 76 bytes

func f(a string)int{for _,v:=range a{if int(v)%len(a)>0{return 0}}
return 1}

Try it online!

MAWP, 34 33 24 23 bytes

`|_=M0=A0/[M%{0:.}?`]1:

Try it!

Thanks to @Razetime for saving 9 bytes!

Explanation:

`        Remove starting 1 on stack
|        Push input on stack as ASCII codes
_=M      Set variable M to length of stack (length of input)
0=A      Set variable A to 0
0/       Push 0 and cycle stack
[        Start of loop
M%       Modulo by M
{0:.}    If not 0 then print 0 and terminate
?`       If 0 then pop value
]        End of loop
1:       Print 1

Clojure, 41 chars

(every? #(= 0 (mod (int %) (count x))) x)

Removing spaces after comment 37 chars

(every? #(= 0(mod(int %)(count x)))x) 

T-SQL, 65 bytes

Returns 1 for true, 0 for false

SELECT-1/~max(ascii(substring(@,number,1))%len(@))FROM spt_values

Try it online

Excel, 66 bytes

=SUM(MOD(CODE(MID(A1,ROW(OFFSET(A1,0,0,LEN(A1))),1))/LEN(A1),1))=0

Input is in the cell A1.

ROW(OFFSET(A1,0,0,LEN(A1))) gives us an array of values from 1 to the length of the input.
MID(A1,ROW(~),1) pulls out each character of the input, one at a time.
CODE(MID(~) converts those characters to their decimal ASCII equivalent.
MOD(CODE(~)/LEN(A1),1) returns just the decimal portion of those codes divided by the input length.
SUM(MOD(~))=0 adds up all those decimal portions and returns TRUE if there weren't any (SUM=0 means everything divided nicely) and FALSE if there were.


I thought this would have to be an array formula but it seems to work without that. Color me surprised.

R, 39 38 bytes

Edit: -1byte thanks to the new rule that we can output TRUE for FALSE and FALSE for TRUE

function(s)any(utf8ToInt(s)%%nchar(s))

Try it online!

Or try the original 39-byte version that outputs TRUE for TRUE...

Aceto, 21 bytes

&L
|%o 1
€l|!
rM@dp

Explanation

We read a string and xplode it, push the stack length and Memorize that.

Then, after setting the exception catch point (@), we always duplicate the top stack element, negate (!) it, and m|rror horizontally if we get a truthy value (string has ended; we popped a 0). Otherwise, we get the ordinal of the character, Load the memorized value and do modulo (%). If this is truthy, we m|rror again.

Finally, we raise an exception (&) to land back in front of the d, for our next character.

If we mirrored, then we eventually land on p, printing the top-most element of the stack. In one of the two cases of mirroring, we will have pushed a 1 before.


I don't see much potential to golf this down further; there's only one space character used, and 3 newlines. Perhaps one or two bytes could be saved by making it a 16x16 in two lines.

JavaScript, 32 bytes

Ouput is reversed.

s=>Buffer(s).some(c=>c%s.length)

Try it online!

Perl 5 -pF, 20 bytes

$_=!grep ord()%@F,@F

Try it online!

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

(s)=>{var bs = ASCIIEncoding.ASCII.GetBytes(s);return bs.All(b=>b%s.Length==0);};

Try it online!

C# (Visual C# Interactive Compiler), 27 26 bytes

s=>s.All(c=>c%s.Length<1);

Try it online!

Ruby, 43 37 36 32 bytes

->a{a.bytes.all?{|n|n%a.size<1}}

if only map could be used on strings..

-10 bytes from ovs.

-1 byte from Dingus.

Try it online!

Jelly, 4 bytes

LḍOP

Try it online! or Verify all cases!

Commmented: (At least I think it works like this)

   P  # product of ...
L     #   does the length 
 ḍ    #   ... divide ...
  O   #   the char codes

Haskell, 42 39 bytes

(<1).sum.(map=<<flip(mod.fromEnum).length)
f s=sum[fromEnum c`mod`length s|c<-s]<1

3 fewer bytes thanks to ovs and xnor!

Try it online!

Factor, 62 bytes

: f ( s -- ? ) dup length [ mod ] curry [ + ] map-reduce 0 = ;

Try it online!

Pip, 12 bytes

!$+(A_Ma)%#a

Try it online!

Explanation

!$+(A_Ma)%#a a → input
   (A_Ma)    Map a to Unicode/ASCII codepoints
         %#a Modulo the list by it's length
 $+          Sum up the remainders
!            Not(returns 0 for any positive number, 1 for 0)

Befunge-98 (FBBI), 31 bytes

Output is via exit code, 1 for truthy, 0 for falsey cases.

#v~\1+
v>53p
>:#v_1q
^  >' %#@_

Try it online!


Code running with inputs lol and ab:

Code with input lol Code with input ab

small numbers represent literal byte values

Rust, 36 bytes

|s|s.iter().all(|x|1>x%s.len()as u8)

Try it online!

Takes the input as a &[u8], outputs a bool.

MathGolf, 4 bytes

$h÷╓

Input as a list of characters.

Try it online.

Explanation:

$     # Get the codepoint of each character in the (implicit) input-list
 h    # Push the length of this list (without popping the list itself)
  ÷   # Check for each codepoint if it's divisible by this length
   ╓  # Pop and push the minimum of the list
      # (after which the entire stack joined together is output implicitly as result)

Japt -e, 6 bytes

c vNÎÊ

Try it

Charcoal, 8 bytes

¬⊙θ﹪℅ιLθ

Try it online! Link is to verbose version of code. Output is a Charcoal boolean, i.e. - for true, nothing for false. Explanation:

  θ         Input string
 ⊙          Is there a character where
     ι      Current character
    ℅       Ordinal
   ﹪        Modulo (i.e. is not divisible by)
       θ    Input string
      L     Length
¬           Boolean NOT
            Implicitly print

⬤θ¬﹪℅ιLθ also works of course.

C# (.NET Core), 25 bytes

a=>a.All(x=>x%a.Length<1)

Try it online!

K (oK), 11 bytes

{~+/(#x)!x}

Try it online!

APL (Dyalog Extended), 7 bytes (SBCS)

Anonymous tacit prefix function

⍱≢|⎕UCS

Try it online!

 are not any of the following true (non-zero)?

 the length

| divides (lit. division remainder when dividing)

⎕UCS the code points

MATL, 4 bytes

tn\~

Try it online! Or verify all test cases including truthiness/falsihood test.

How it works

t   % Implicit input. Duplicate
n   % Number of elements
\   % Modulo
~   % Negate. Implicit display

Python 2, 41 39 bytes

lambda s:all(ord(i)%len(s)<1for i in s)

Try it online!

-2 bytes thanks to @ovs

05AB1E, 5 bytes

ÇsgÖP

Try it online!

Commented

        # implicit input    "lol"
Ç       # push ASCII value  [108, 111, 108]
 s      # swap (with input) [108, 111, 108], "lol"
  g     # length            [108, 111, 108], 3
   Ö    # is divisible?     [1, 1, 1]
    P   # product           1