# Question
Title: Now I know my ABCs, won't you come and golf with me?
Write a program or function that outputs this exact text, case-insensitive:

```
A, B, C, D, E, F, G,
H, I, J, K, L, M, N, O, P,
Q, R, S,
T, U, V,
W, X, Y, Z.

```

(Based on the alphabet song that many American kids learn to help memorize the alphabet, though edited for more compressibility.)

The output must *look* exactly the same as the above (again, case-insensitive), but may contain trailing spaces on each line and/or trailing newlines. Notice the period at the end.

This is code-golf, so **the shortest code in bytes wins.**

# Answer
# Vim, ~~42~~, 40 keystrokes/bytes

```
:h<_<cr>jjYZZP:s/./&, /g<cr>7f r<cr>9;.3;.3;.$ch.

```

Thanks to Lynn and her awesome vim answer for the tip to grab the alphabet from help.

Thanks to RomanGräf for saving two bytes!

Explanation:

```
:h<_<cr>                                      " Open up vim-help
        jj                                    " Move down two lines
          Y                                   " Yank this line (containing the alphabet)
           ZZ                                 " Close this buffer
             P                                " Paste the line we just yanked
              :s/./&, /g<cr>                  " Replace every character with that character followed by a comma and a space
                            7f                " Find the seven space on this line
                               r<cr>          " And replace it with a newline
                                    9;        " Repeat the last search (space) 9 times
                                      .       " Repeat the last edit (replace with a newline)
                                       3;     " Third space
                                         .    " Replace with newline
                                          3;  " Third space
                                            . " Replace with newline

```

Then, we move the end of the of the line with `$`, change back a character with `ch` and insert a dot.
> 18 votes

# Answer
# Bash + GNU utilities, 36

* 5 bytes saved thanks to Neil.

```
echo {A..Y}, Z.|sed 's/[HQTW]/\n&/g'

```

Ideone.
> 13 votes

# Answer
# 05AB1E, 16 bytes

**Code**

```
A',â79334S£»¨'.J

```

**Explanation:**

```
A                  # Push the alphabet.
 ',â               # Cartesian product with ','.
    79334S         # Push [7, 9, 3, 3, 4].
          £        # Contigious substring, pushes the substrings [0:7], [7:7+9],
                     [7+9:7+9+3], [7+9+3:7+9+3+3], [7+9+3+3:7+9+3+3+4].
           »       # Gridify, join the inner arrays with spaces and join those arrays
                     with newlines.
            ¨      # Remove the last character.
             '.J   # Append a '.'-character.

```

Uses the **CP-1252** encoding. Try it online!
> 13 votes

# Answer
# JavaScript (ES6), ~~66~~ 65 bytes

Beating @Neil was impossible... That's why I did it. :-)

```
f=(i=10)=>i>34?"z.":i.toString(++i)+","+`
`[9568512>>i-9&1]+f(i)

```

Golfed 1 byte thanks to a trick from @LevelRiverSt. Using `String.fromCharCode` is 7 bytes longer:

```
f=(i=65)=>i>89?"Z.":String.fromCharCode(i,44,i%86%83%80%71?32:10)+f(i+1)

```

### How it works

This recursively generates each character of the alphabet from `a` to `y`, using `.toString()`. A comma is appended after each letter, plus a newline if `9568512>>i-9&1` is 1, or a space otherwise. When the recursion gets past 34, i.e. to `z`, the function simply returns `"z."`.
> 12 votes

# Answer
# Python 2.7, ~~67 66~~ 63 bytes

```
a=65;exec"print'%c'%a+',.'[a>89]+'\\n'[a%42%39%9^2:],;a+=1;"*26

```

Dennis saved a byte.
> 10 votes

# Answer
# Jelly, ~~19~~ 18 bytes

```
ØAp”,ṁ79334DR¤GṖ”.

```

*Thanks to @Adnan for golfing off 1 byte!*

Try it online!

### How it works

```
ØAp”,ṁ79334DR¤GṖ”.  Main link. No arguments.

ØA                  Yield "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
  p”,               Cartesian product with ','; append a comma to each letter.
             ¤      Combine the two links to the left into a niladic chain.
      79334D          Decimal; yield [7, 9, 3, 3, 4].
            R         Range; yield [[1, 2, 3, 4, 5, 6, 7], ..., [1, 2, 3, 4]].
     ṁ              Mold; reshape the array of letters with commata like the
                    generated 2D array.
              G     Grid; separate rows by spaces, columns by linefeeds.
               Ṗ    Pop; discard the last comma.
                ”.  Print the previous result and set the return value to '.'.
                     (implicit) Print the return value.

```
> 8 votes

# Answer
## Pyke, ~~23~~ ~~19~~ 17 bytes

```
G\,J\.+2cu  /P

```

Try it here!

```
G\,J\.+        -    ",".join(alphabet)+"."
       2c      -   split(^, size=2)
            /  -  split_sized(^, V)
         u     -   yield list [7,9,3,3] (actual bytes `u%04%07%09%03%03`)
             P - print(^)

```
> 6 votes

# Answer
## Brainfuck, 117 bytes

```
+[++[-<]-[->->]<]+++[->++>+++>+>+<<<<<--<<->>>]>+[[-<<<<<+.>-.+>.>>>]>[[-<+>]>]<<[<]<.>>]<<-[---<<<+.>-.+>.>]<<<+.>+.

```

The first four lines each have a trailing space, and the program assumes 8-bit cells. Try it online!

<sup>(Handling the last line is tricky...)</sup>
> 6 votes

# Answer
# Vim, 32 bytes

`26o<C-V><C-V>64,<Esc>r.V{g<C-A>8Jj9Jj3Jj.j4JcH<C-R>"`

Leaves a blank line at the end, which was allowed, but it's weird being this clumsy. Even worse, I'm ending in insert mode. I've seen some other folks do it here, so I guess it's allowed? It feels dirty.

* `26o<C-V><C-V>64,<Esc>`: The first `<C-V>` makes the second one insert literally. The `<C-V>64`s this leaves in the buffer will be turned into ASCII code points, then into letters. Commas already in.
* `r.`: Never going to be at the end again, so do the `.` now.
* `V{g<C-A>`: Uses visual increment to turn all the `64`s into the ASCII code points of the capital letters.
* `8Jj9Jj3Jj.j4J`: The arbitrary line joins. First one is `8J` instead of `7J` because we're dealing with the blank line. The repeated `3J`s are eligible for a dot repeat.
* `cH<C-R>"`: People usually think of `i<C-R>` as an insert mode paste, but it's more like an insert mode macro. Stuff like `<C-V>65` will run as if typed, and interpreted as a decimal code point. This leaves an extra (allowed) line at the end, and stays in insert mode.
> 6 votes

# Answer
## JavaScript (ES6), ~~80~~ 74 bytes

```
_=>[...`ABCDEFGHIJKLMNOPQRSTUVWXYZ`].join`, `.replace(/[HQTW]/g,`
$&`)+`.`

```

Probably possible to shorten this with atob/btoa if you can work out how to use ISO-8859-1 encoding. Edit: Saved 6 bytes thanks to @RickHitchcock.
> 5 votes

# Answer
## Perl, 37 bytes

*Credits to @Dom Hastings for this solution (3 bytes shorter than mine, see bellow).*

```
say+(map"$_, ".$/x/[GPSV]/,A..Y),"Z."

```

Run with `-E` (or `-M5.010`) flag :

```
perl -E 'say+(map"$_, ".$/x/[GPSV]/,A..Y),"Z."'

```

My previous version, 3 bytes longer (total of 40 bytes) :

```
perl -E '$_=join", ",A..Z;s/[HQTW]/\n$&/g;say"$_."'

```
> 5 votes

# Answer
# R, ~~83~~ 71 bytes

```
a=rbind(LETTERS[-26],","," ");a[3,7+3*c(0,3:5)]="\n";cat(a,"Z.",sep="")

```

Try it online!

Makes a matrix of 3 rows (one with the letters, one with the commas and the other with either a space or a newline).

**Edit**: Thanks Billywob!
> 5 votes

# Answer
## CJam, 26 bytes

```
'A79333Ab{{',S2$)}*N\}/'.@

```

Online interpreter

```
'A                             Push 'A'
  79333Ab                      Push [7 9 3 3 3]
         {           }/        For each number n in the previous array...
          {      }*              Execute n times...
           ',S                     Push a comma and a space
              2$)                  Copy last letter and increment
                   N\            Place a newline under the letter on top
                       '.@     Push '.' and rotate

```
> 5 votes

# Answer
# Brainfuck, 157 bytes

```
+++++[>+>+++<<-]>>[->+>++++>+++>++<<<<]>----->+++++.>-.>++.<<<<<+[->>>+.>.>.<<<<<]+++++++++>>.<<[->>>+.>.>.<<<<<]<---[+>+++>>.<<[->>>+.>.>.<<<<<]<]>>>>+.>++.

```

Try it online
> 4 votes

# Answer
# JavaScript (ES6), ~~66~~ ~~64~~ 60 bytes

```
_=>`ABCDEFG
HIJKLMNOP
QRS
TUV
WXY`.replace(/./g,"$&, ")+"Z."

```

Regex matches the characters but not the carriage returns, so, using regex replace, I can add the ", " to each character.

Edit: Removed 2 characters thanks to ETHProductions

Edit: Changed from CRLF to LF, thanks @Olivier Grégoire
> 4 votes

# Answer
# Vyxal, 15 bytes

```
n\,Ẋ7933fẇ⁋Ṫ\.+

```

Try it Online! -2 thanks to lyxal. -1 thanks to ffseq

```
n               # Uppercase alphabet
   Ẋ            # Each prepended to
 \,             # ","
         ẇ      # Cut into chunks of lengths
    7933f       # Digits of 7933 (+ rest, which is 4)
          ⁋     # Join by newlines
           Ṫ    # Remove the last character
            \.+ # Append a dot

```
> 4 votes

# Answer
# Cheddar, 70 bytes

```
->[65@"71,72@"80,"QRS","TUV","WXYZ"].map(@.chars.join(", ")).vfuse+'.'

```

Looks like it's not getting shorter than this. I've made other versions of this which use quite interesting methods but this is shortest

Try it online!

## Explanation

```
->                        // Function with no arguments
  [                       // Array, each item represents a line
   65@"71,                // See below on what @" does
   72@"80,
   "QRS",
   "TUV",
   "WXYZ"
  ].map(                  // On each item...
    @.chars.join(", ")    // Join the characters on ", "
  ).vfuse                 // Vertical fuse or join by newlines
  + '.'                   // The period at the end

```

---

The `@"` operator is used to generate string ranged. It generates a string starting from the left char code to the right char code.

For example, `65` is the char code for `A` and `90` for `Z`. Doing `65 @" 90` would generate A through Z or the alphabet.
> 3 votes

# Answer
# MATL, ~~38~~ 29 bytes

*9 bytes saved thanks to @Luis!*

```
1Y2X{', '&Zc46h1[CEII]I*11hY{

```

**Try it Online!**

**Explanation**

```
1Y2     % Push the upper-case alphabet to the stack
X{      % Break the character array into a cell array (similar to a list)
        % where each element is a letter
', '&Zc % Combine back into a string with ', ' between each element
46h     % Append '.' (via ASCII code) to the end of the string
1       % Push the number 1
[CEII]  % Push the array: [7, 9, 3, 3]
I*      % Multiply this array by 3: [21, 27, 9, 9]
llh     % Append an 11 to this array: [21, 27, 9, 9, 11]
Y{      % Break our comma-separated list of characters into groups of this size
        % Implicitly display the result

```
> 3 votes

# Answer
## C, ~~112~~ ~~102~~ 81 bytes

Thanks to cleblanc & LevelRiverSt!

```
i,c;main(){for(c=64;++c<91;)printf("%c%c%c",c,44+c/90*2,c=="GPSVZ"[i]?++i,10:32);}

```
> 3 votes

# Answer
# Japt, 24 bytes

```
;B¬qJ+S r"[HQTW]"@R+XÃ+L

```

Test it online!

### How it works

```
;                        // Reset various variables. B is set to "ABC...XYZ", J is set to ",", and L is set to ".".
 B¬                      // Take the uppercase alphabet and split into chars.
   qJ+S                  // Join with ", ".
        r"[HQTW]"        // Replace each H, Q, T, or W with
                 @R+XÃ   //   a newline plus the character.
                      +L // Append a period to the result.
                         // Implicit: output last expression

```
> 3 votes

# Answer
# Ruby, ~~56~~ 54 bytes

```
$><<(?A..?Y).map{|c|c+('GPSV'[c]?",
":", ")}.join+"Z."

```

The first line ends with a literal newline.

**Edit:** saved two bytes by replacing `'A'..'Y'` with `?A..?Y`.
> 3 votes

# Answer
# Java, ~~116~~ ~~109~~ ~~105~~ 104

```
String f(){String s="";for(char c=65;c<91;)s=s+c+(c>89?46:',')+("GPSV".indexOf(c++)<0?' ':10);return s;}

```

Ungolfed:

```
String f() {
  String s = "";
  for (char c = 65; c < 91;) {
    s = s + c
      + (c > 89 ? 46 : ',')
      + ("GPSV".indexOf(c++) < 0 ? ' ' : 10);
  }
  return s;
}

```
> 3 votes

# Answer
# q, 46 bytes

```
-1@'(", "sv/:0 7 16 19 22_,:'[.Q.A]),'",,,,.";

```
> 2 votes

# Answer
## PowerShell v3+, ~~60~~ ~~78~~ 67 bytes

```
-join(65..90|%{[char]$_+'.,'[$_-le89]+" "+"`n"*($_-in71,80,83,86)})

```

OK. I've actually read, understood, and followed the spec this time. Promise. :D

Takes the array `65..90` and loops over each element `|%{...}`. Each iteration, we're constructing a new string using concatenation, indexing, and multiplication.

First, we take the current number and `char` cast it to make it an ASCII letter. That's concatenated with another char, based on indexing into the string `'.,'` whether we're at `90` or not (i.e., to account for `Z.` while having all the rest be commas). That's string concatenated with `" "` to space-separate the letters, and string multiplication of `"`n"` based on Boolean value for whether the current element is `-in` the specified array (i.e., whether we need to concatenate on a newline character). The resulting string is left on the pipeline.

Those strings are encapsulated in parens, and `-join`ed together into a new string, which is then also left on the pipeline and implicit `Write-Output` at the end prints the result. Since we have ``n` in the string, it's automatically converted to newlines upon printing.

Requires v3+ for the `-in` operator. Has a trailing space on each line, which is OK per the challenge specs.

### Example

```
PS C:\Tools\Scripts\golfing> .\now-i-know-my-abc.ps1
A, B, C, D, E, F, G,
H, I, J, K, L, M, N, O, P,
Q, R, S,
T, U, V,
W, X, Y, Z.

```
> 2 votes

# Answer
# PHP, 62 Bytes

```
<?=preg_filter("# ([HQTW])#","\n$1",join(", ",range(A,Z)));?>.

```

only for comparison 87 Bytes

```
<?="A, B, C, D, E, F, G,\nH, I, J, K, L, M, N, O, P,\nQ, R, S,\nT, U, V,\nW, X, Y, Z.";

```
> 2 votes

# Answer
## R, 146 bytes

```
L=LETTERS
f=function(x,y=""){paste(x,collapse=paste0(", ",y))}
cat(f(c(f(L[1:7]),f(L[8:16]),f(L[17:19]),f(L[20:22]),f(L[23:26])),"\n"),".",sep="")

```

**Explanation:**

`LETTERS` is predefined for uppercase letters.
The `f` function is for concatenating vector x on `,` with additional `y` (used for newlines).
The cat is the used as it prints `\n` as newlines. `f` is called on the letters to form rows and then on the rows again to form the whole output.

*Probably golfable - I don't like the multiple calls of f...*
> 2 votes

# Answer
# Pyth, 25 bytes

```
+Pjmj\ dc*G\,j94092 23)\.

```

A program that prints the result to STDOUT.

Try it online

**How it works**

```
+Pjmj\ dc*G\,j94092 23)\.  Program. Input: none
          G                Yield string literal'abcdefghijklmnopqrstuvwxyz'
         * \,              Cartesian product of that with ',', yielding a list of
                           characters with appended commas
             j94092 23)    Yield the integer 94092 in base-23, giving [7, 16, 19, 22]
        c                  Split the comma-appended character list at those indices
   mj\                     Join each element of that on spaces
  j                        Join that on newlines
 P                         All but the last element of that, removing trailing ','
+                      \.  Append '.'
                           Implicitly print

```
> 2 votes

# Answer
## Pip, 19 bytes

18 bytes of code, +1 for the `-n` flag. Outputs in lowercase.

```
(zJk).'.^@A*"?09B"

```

The `?` represents a non-printing character, ASCII code 21. Try it online!

### Explanation

```
 z                  Lowercase alphabet
  Jk                Join on ", "
(   ).'.            Append a period
          A*"?09B"  Map ascval() over that string, results in list: [21 48 57 66]
        ^@          Split at those indices
                    Join on newline and print (implicit, -n flag)

```
> 2 votes

# Answer
# CJam, 31 bytes

```
'[,65>", "*7933Ab{3*/(\:+}%N*'.

```

Explanation:

```
'[,65>                             push uppercase alphabet
      ", "*                        ", " between all letters
           7933Ab                  push [7 9 3 3]
                 {3*/(\:+}%        slices of lengths 21, 27, 9, 9
                           N*'.    join slices with newlines, add final "."

```

Try it online
> 2 votes

# Answer
# Julia, 71 bytes

```
f()=join(join.(['A':'G','H':'P',"QRS","TUV","WXYZ"],[", "]),",\n")*"."

```

Requires 0.5 or better for broadcasting `.()`
> 2 votes

# Answer
# Cheddar, 57 bytes

```
->(65@"90).sub(/[GPSV]/g,"$0
").sub(/[^Z\n]/g,"$0, ")+"."

```

Try it online! Isn't that beautiful? It's a nice rectangle.

Two regex substitutions. `(65@"90)` is the uppercase alphabet, `.sub(/[GPSV]/g,"$0\n")` replaces `GPSV` with itself and `"\n"`, `.sub(/[^Z\n]/g,"$0, ")` replaces all non newline and `Z` characters with itself and `", "`, and `"."` adds a final `.`.
> 2 votes

# Answer
# TI-Basic, 86 bytes

Cheers to anyone who can compress it further :3

```
Disp "A, B, C, D, E, F, G,","H, I, J, K, L, M, N, O, P,","Q, R, S,","T, U, V,
"W, X, Y, Z.

```
> 2 votes

# Answer
# MathGolf, 20 bytes

```
'A[793∙]öæ└╣·\n\\;'.

```

Try it online!

## Explanation

```
'A                    Push "A"
  [793∙]              Push [7, 9, 3, 3, 3]
        ö             Start foreach-loop over index array using next 7 instructions
         æ            Start for-loop for current item of index array, using next 4 instructions
          └           Duplicate and increment, e.g. "A" -> "A", "B"
           ╣·         Push ", "
             \        Swap top two, keeping the letter on top after inner loop
              n\      Push newline and swap top two, keeping the letter on top
                \;'.  Swap top two, discard top, and push "." (remove trailing comma)

```
> 2 votes

# Answer
# Japt `-R`, 17 bytes

```
;LiB¬q,ú2¹óÏk`qw

```

Test it

```
;LiB¬q,ú2¹óÏk`qw
;L                   :"."
  i                  :Prepend
;  B                 :  Uppercase alphabet
    ¬                :  Split
     q               :  Join with
      ,ú2            :    "," right padded with spaces to length 2
         ¹           :End prepend
          ó          :Partition before characters that return a falsey value (empty string)
           Ï         :When passed through the following function
            k        :  Case insensitively remove
             `qw     :  Characters in the compressed string "qthw"
                     :Implicit output joined with newlines

```
> 2 votes

# Answer
# Java (JDK), 66 bytes

```
v->"ABCDEFG\nHIJKLMNOP\nQRS\nTUV\nWXY".replaceAll(".","$0, ")+"Z."

```

Try it online!
> 2 votes

# Answer
# C (76 bytes)

```
c;main(){for(c=64;++c<90;)printf("%c,%c",c," \n"[4784256>>c&1]);puts("Z.");}

```

This relies on

1. implicit-`int` declarations (for `c`, `main`, `puts` and `printf` without `#include<stdio.h>`);
2. ASCII;
3. `>>` being modulo the size of an integer in bits, either 32 or 64, so that `X>>'A'` gives "`X` shifted by 1" and `X>>'Z'` gives "`X` shifted by 26".

`4784256` is `2⁷+2¹⁶+2¹⁹+2²²` (or equivalently `1<<7 | 1<<16 | 1<<19 | 1<<22`), because 'G', 'P', 'S', and 'V' are respectively the 7th, 16th, 19th, and 22nd letters of the alphabet.
> 2 votes

# Answer
# PHP, 90 chars

```
A<?for($i=66;$i<91;$i++){echo", ";if(in_array($i,[72,81,84,87]))echo"\n";echo chr($i);}?>.

```

I know it's longer than 77 chars, but this is as short as it gets.
> 1 votes

# Answer
# Retina, 43 bytes

```

Z
{2`
$`
}T01`L`_L
.
$&,
[HQTW]
¶$&
, $
.
```

Leading newline is significant. Try it online!

This is my first time using Retina, so any golfing tips are appreciated...
> 1 votes

# Answer
# PHP, ~~67~~ ~~65~~ 64 bytes

Not exactly short, but it works.
This assumes that all errors are going to `stderr`.

```
foreach(range(A,Z)as$C)echo$C,",."[$C>Y],"
 "[!strstr(GPSV,$C)];

```

You can try it on `http://ideone.com/VSK8Yu`.

Thanks to @Jörg Hülsermann for saving 2 bytes! And thanks to @Titus for saving me 1 byte!
> 1 votes

# Answer
# Forth, 85 bytes

This is a function that prints the string. Checking for when to print a new line is costly. This is still shorter than simply printing the required string, because it has new lines in it. The code does not need to be on this many lines, but there does need to be a line break within the `DO LOOP` somewhere. I don't know why.

```
: f 90 65 DO
I 72 = I 81 = I 84 = I 87 = + + +
if CR then
I emit ." , "
LOOP ." Z." ;

```

**Try it online**

The code is case-insensitive.
> 1 votes

# Answer
# Ruby, 57 bytes

```
26.times{|i|$><<(i+65).chr+",."[i/25]+"
"[2392128>>i&1]}

```

The space at the end of the first line is required: it's a literal \[space\]\[newline.\]

# C,74 bytes

```
c;main(){for(;++c<27;)printf("%c%c%c",64+c,44+c/26*2,4784256>>c&1?10:32);}

```

Basic bitshift and mask to determine when to print a space and when to print a newline. I noted that with the A and Z removed all groups are a multiple of 3 letters long, but I was unable to make use of this.
> 1 votes

# Answer
## Racket 173 bytes

```
(λ()(let((l(list 7 9 3 3 4))(s 65))(for((i 5))(define e(+ s(list-ref l i)))(for((j(range s e)))
(printf"~a~a "(integer->char j)(if(= j 90)"."",")))(printf"~n")(set! s e))))

```

Ungolfed:

```
(define f
  (λ()
    (let ((l (list 7 9 3 3 4))
          (s 65))
      (for ((i 5))
        (define e (+ s (list-ref l i)))
        (for ((j (range s e)))
          (printf "~a~a " (integer->char j) (if(= j 90) "." ",")))
        (printf "~n")
        (set! s e)
        ))))

```

Testing:

```
(f)

```

Output:

```
A, B, C, D, E, F, G,
H, I, J, K, L, M, N, O, P,
Q, R, S,
T, U, V,
W, X, Y, Z.

```
> 1 votes

# Answer
# Haskell, 60 bytes

```
putStr$(['A'..'Y']>>= \x->x:", "++['\n'|elem x"GPSV"])++"Z."

```

Try it on Ideone.

```
putStr$(['A'..'Y']>>= \x->x:", "++['\n'|elem x"GPSV"])++"Z."
        ['A'..'Y']                                          --String "ABC...XY"
                      \x->x:", "++['\n'|elem x"GPSV"]       --function to append ", " and a "\n" when needed
       (          >>=                                )      --map function over the string and concat
                                                      ++"Z."--append "Z."
putStr$                                                     --print

```
> 1 votes

# Answer
# Fourier, 56 bytes

```
|~S44a32aS^|f|(iaf~i)10a|L65~i72L81L84L87L90(iaf~i)ia46a

```

Again, uses functions to take out repeated parts of the code.

**Try it FourIDE!**
> 1 votes

# Answer
## Clojure, 154 bytes

```
#(print(loop[a(map char(range 65 91))[c & d][7 9 3 3 4]s""](if c(let[[l r](split-at c a)e(if d\,\.)](recur r d(str s(clojure.string/join", "l)e"\n")))s)))

```

That call to `clojure.string/join` is killer, although this wasn't competitive to begin with. Basically, it cuts the generated alphabet string `a` at the predefined line lengths, then adds each line to the `acc`.

It would have been significantly shorter for me to just "cheat" and print the string (91 bytes):

```
(print "A, B, C, D, E, F, G,\nH, I, J, K, L, M, N, O, P,\nQ, R, S,\nT, U, V,\nW, X, Y, Z.")

```

But where's the fun in that?

Ungolfed:

```
(defn abcs []
  (print
    (loop [alpha (map char (range 65 91))
           [c & cuts] [7 9 3 3 4]
           acc ""]
      (if c
        (let [[a-line a-rest] (split-at c alpha)
              e (if cuts \, \.)]
          (recur a-rest cuts (str acc (clojure.string/join ", " a-line) e "\n")))
        acc))))

```
> 1 votes

# Answer
# GameMaker Language, 85 bytes

```
b=""for(a=65;a<90;a++){d=chr(a)c=", "if string_pos(d,"GPSV")c=",#"b+=d+c}return b+"Z.

```

**Boring alternate (94 bytes)**

```
return string_replace_all("AaBaCaDaEaFaG,#HaIaJaKaLaMaNaOaP,#QaRaS,#TaUaV,#WaXaYaZ.","a",", ")

```

Pretty straightforward. Note that `#` is newline literal (think `\n` in most languages). Use `\#` for `#`.
> 1 votes

# Answer
# \>\<\>, 52 bytes

```
79334"A"\
or:?!~r&>:o1+:}&a" ,.["{=:}?$~o{?;{1-:}?$~

```

Try it online!
> 1 votes

# Answer
# PHP, ~~61~~ ~~58~~ ~~55~~ 50 bytes

Note: uses Windows 1252 encoding.

```
for($a=A;$a<Z;)echo"$a,",~ßõ[!trim($a++,GPSV)]?>Z.

```

Run like this:

```
php -r 'for($a=A;$a<Z;)echo"$a,",~ßõ[!trim($a++,GPSV)]?>Z.' 2>/dev/null;echo

```

If your terminal is set to UTF-8, this shows that it works:

```
php -r 'for($a=A;$a<Z;)echo"$a,"," \n"[!trim($a++,GPSV)]?>Z.' 2>/dev/null;echo

```

# Explanation

Iterates over the alphabet until `Y` is reached. Prints the letter with a comma, then prints a space, unless the letter is one of `GPSV` (found by `!trim($a,"GPSV")`). After the loop, print `Z.`.

# Tweaks

* Saved 3 bytes by using `strpos` instead of char count
* Saved 3 bytes by using trim instead of strpos
* Saved 5 bytes by using the closing tag to print a literal `Z.` instead of `echo`
> 1 votes

# Answer
**q, 41 bytes**

```
@[", "sv,:'[.Q.A];20 47 56 65;:;"\n"],"."

```

How it works:

```
            .Q.A                          / Built-in alphabet
        ,:'[    ]                         / Flip data (to 1-row matrix)
  ", "sv                                  / Join with ", "
@[               ;20 47 56 65;:;"\n"]     / Replace spaces with newlines at indices
                                     ,"." / Append period

```
> 1 votes

# Answer
# PowerShell, 56 bytes

```
('ABCDEFG
HIJKLMNOP
QRS
TUV
WXY'-replace'.','$0, ')+'Z.'

```

Try it online!
> 1 votes

# Answer
# \>\<\>, 45 bytes

```
4339"A"7v$oa~<
"&+oo1+$>:1(?^1-$:o:"Z"=2*&" ,

```

Try it online!
> 1 votes

# Answer
# PowerShell 6, ~~53~~ ~~52~~ 47 bytes

```
"$('A'..'Y'|%{"$_,"-replace'[HQTW]','
$&'}) Z."

```

Try it online!

I believe PowerShell 6 is newer than this challenge. Originally posted as a suggestion for @mazzy's solution.
> 1 votes

# Answer
# Stax, 16 bytes

```
é╡₧!D☻àw╟`«▒Σ╪░↓

```

Run and debug it

Unpacked, ungolfed, and commented, it looks like this.

```
'.          push "."
VA          push "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
',\         repeat zip alphabet with comma, yielding ["A,", "B,", ...]
J           join with spaces
)           overwrite end of joined string with period (pushed first)
"r!WEF"!    crammed array literal for [20, 47, 56, 65]
A&          assign 10 to these array indices.  10 is the codepoint for newline.

```

Run this one
> 1 votes

# Answer
# APL (Dyalog Unicode), ~~30~~ 29 bytes<sup>SBCS</sup>

Full program.

```
↑'AHQTW'(∊⍨⊂⊢)'.',⍨∊', '∘,¨⎕a

```

Try it online!

`⎕a` the uppercase **a**lphabet

`', '∘,¨` prepend `", "` to each letter

**ϵ**nlist (flatten)

`'.',⍨` append a period

`'AHQTW'(``)` apply the following tacit function with the string as left argument:

the right argument (`", A, B…"`)

partitioned so a new partition begins at each True in

`∊⍨` the Boolean mask indicating argument elements that are members of the left argument

mix the list of strings into a character matrix

solved together with Adam
> 1 votes

# Answer
# ReRegex, 47 bytes

```
-/,\n/\w\B/$0, /ABCDEFG-HIJKLMNOP-QRS-TUV-WXYZ.

```

## Ungolfed

```
-/,\n/                             # Replace all dashes with a comma and newline
\w\B/$0, /                         # Replace all letters preceeding a letter with itself and a comma space.
ABCDEFG-HIJKLMNOP-QRS-TUV-WXYZ.    # The default code.

```

Try it online!
> 1 votes

# Answer
# sed, 54 bytes

No further tricks take us down, I'm afraid:

```
s/^/ABCDEFG\
HIJKLMNOP\
QRS\
TUV\
WXYZ./
s/[A-Y]/&, /g

```

Try it online!
> 1 votes

# Answer
# Ly, 29 bytes

```
'A043397[[r:o`r' ',oo,]p9`o];

```

Try it online!

This code pushes the number of letters to print on each line onto the stack. It also keeps the current character on the end of the stack, iterating it each time it prints. The code loops until the "number of letters to print on the next line" is zero.

```
'A                            - push "A" on the stack
  0                           - add 0 divider to stop loop
   43397                      - push number of chars per line
        [                  ]  - loop while number of chars>0
         [           ,]       - loop for one line of chars
          r                   - reverse stack
           :                  - duplicate current char
            o                 - print
             `                - increment to next char
              r               - reverse stack again
               ' ',oo         - push/print " ,"
                       p      - delete iterator var
                        9`o   - push/print LF
                            ; - exit to abandon junk on stack

```
> 1 votes

# Answer
# ///, 62 bytes

```
/c/, /AcBcCcDcEcFcG,
HcIcJcKcLcMcNcOcP,
QcRcS,
TcUcV,
WcXcYcZ.

```

Try it online!

Not much to golf here, but I reduced it from 77 bytes to 62 just by replacing `,`  with `c`.
> 0 votes

# Answer
## ListSharp, 88 bytes

```
SHOW="A, B, C, D, E, F, G,\nH, I, J, K, L, M, N, O, P,\nQ, R, S,\nT, U, V,\nW, X, Y, Z."

```
> 0 votes

# Answer
# Julia 1.0, 53 bytes

```
_->replace(join('A':'Z',", "),r"(?=[HQTW])"=>"
")*'.'

```

Try it online!
> 0 votes

---
Tags: code-golf, string, kolmogorov-complexity
---


title: Golf to find Boring numbers

text:
# Question
Title: Golf to find Boring numbers
If an integer has a digit/sequence of digits in it which repeats continuously (You will understand why I said "continuously") 5 or more times, we call It "Boring".

For example, `11111` is Boring, whereas `12345` is not.

# Instructions

Take an Integer as Input

Output a truthy value if the integer is boring, and a falsey value if the integer is not boring.

# Example

`11111`=\>`true` or `1` (1 repeats 5 times)

`12345`=\>`false` or `0`

`1112111`=\>`false` or `0`

`4242424242`=\>`true` or `1` (42 repeats 5 times)

`-11111`=\>`true` or `1`

`3452514263534543543543543543876514264527473275`=\>`true` or `1` (543 repeats 5 times)

If you use other types of "truth" and "false", specify it.

# Rules

Basic rules apply.

Good luck!

# Answer
# 05AB1E, 8 bytes

Code:

```
Œv¹y5×åO

```

Explanation:

```
Œ         # Compute all substrings from the input.
 v        # For each substring.
   y5×    # Repeat the substring 5 times (42 × 5 = 4242424242).
  ¹   å   # Check if it's in the input string.
       O  # Sum up the result. Non-boring numbers should give 0.

```

**Truthy** is non-zero and **falsy** is zero. Uses the **CP-1252** encoding.

Try it online!
> 15 votes

# Answer
# Retina, 9 bytes

```
(.+)\1{4}

```

Verify all testcases! (slightly modified to run all testcases at once.)
> 23 votes

# Answer
# Java 8, 52 bytes

```
s->s.matches(".*(.+)\\1{4}.*")

```

Outgolfed this Java 8 answer with a direct `String#matches`.

**Explanation:**

Try it here.

```
s->              // Method with String parameter and boolean return-type
  s.matches(     //  Return whether the entire String matches the following regex:
    ".*          //   0 or more leading characters
     (.+)\\1{4}  //   group of 1 or more characters, repeated 5 times
     .*")        //   0 or more trailing characters

```
> 7 votes

# Answer
# Java 8, ~~73~~ 66 bytes:

```
L->java.util.regex.Pattern.compile("(.+)\\1{4}").matcher(L).find();

```

Hooray for Java 8 lambdas! Returns `true` if match is found and `false` otherwise.

Try It Online! (Ideone)
> 6 votes

# Answer
## Lua, 35 Bytes

Well, I don't see how to do better with Lua's patterns! Takes a command-line argument as input and output `nil` for falsy cases, and the number repeated when truthy.

```
print((...):match("(%d+)%1%1%1%1"))

```
> 4 votes

# Answer
# JavaScript, 16 bytes

In node.js (60 bytes)

```
process.stdin.on('data',t=>console.log(/(.+)\1{4}/.test(t)))

```

Wasting a *ton* of bytes on input/output.

JavaScript ES6 (33 bytes)

```
alert(/(.+)\1{4}/.test(prompt()))

```

Again wasting bytes on input/output.

Preferably, as an anonymous function (22 bytes)

```
n=>/(.+)\1{4}/.test(n)

```

Or even shorter (**16 bytes**)

```
/(.+)\1{4}/.test

```

Thanks @BusinessCat for pointing out my mistakes.
> 4 votes

# Answer
# Python 3.5, ~~49~~ 43 bytes:

(*-6 bytes thanks to tips from Martin Ender!*)

```
import re;lambda u:re.search(r'(.+)\1{4}',u)

```

Uses a Regular Expression to match all repeating sequences of characters as long as they repeat continuously 5 or more times. Returns an `re` match object (such as `<_sre.SRE_Match object; span=(0, 10), match='4242424242'>`) if a match is found as a truthy value, and nothing or `None` as a falsey value.

Try It Online! (Ideone)
> 3 votes

# Answer
## Perl, ~~17~~ 15 bytes

```
$_=/(.+)\1{4}/

```

\+ the `p` flag.

(run with `perl -pe '$_=/(.+)\1{4}/'`)

Thanks to Dom Hasting for the `(.+)` instead of `(\d+)`.

Explanations if needed : `(.+)` will match any part of the number, and `\1{4}$` searches if it is repeated 4 times consecutives.
> 2 votes

# Answer
# Husk, ~~13~~ 11 bytes

```
§ṁ€ȯm*5tQda

```

Try it online!

similar to 05AB1E.

-2 bytes from Dominic Van Essen and Jo King.
> 2 votes

# Answer
## SABDT, 41 bytes

White Space-less:

```
if($.r("(.+)\1{4})"=""){pr"0";}el{pr"1";}

```

Prettified:

```
if( $.r( "(.+)\1{4}" ) = "" ){
    pr "0";
} el {
    pr "1";
}

```

Answer brought to you partly by the brilliant person who came up the regex "(.+)\1{4}"
> 2 votes

# Answer
# Python 3 without regex, 66 bytes

```
lambda s:any(s[j:i]*5in s for i in range(len(s))for j in range(i))

```

Try it online!
> 2 votes

# Answer
## C# - 93 38 bytes

```
s=>new Regex(@"(.+)\1{4}").IsMatch(s);

```

Takes a string, returns an integer.

Thanks to aloisdg for saving a lot of bytes!
> 1 votes

# Answer
# Pyth, ~~9~~ 8 bytes

1 byte thanks to Maltysen.

```
~~sm}*5dQ.:~~
f}*5TQ.:

```

Truthy value is a non-empty array.

Falsey value is `[]` (empty array).

Test suite.

```
f}*5TQ.:   input as a string stored in Q
f}*5TQ.:Q  implicit arguments
        Q  input
      .:   all substrings of.
f   T      filter for this condition, keep those returning true:
  *5           repeat five times
 }   Q         in Q? (True/False)

```
> 1 votes

# Answer
# Mathematica, ~~46~~ ~~40~~ 36 bytes

```
b=a__;StringContainsQ[b~~b~~b~~b~~b]

```

Function. Takes a string as input and outputs `True` or `False`. Tests strings against the expression `a__~~a__~~a__~~a__~~a__`, which represents the same character sequence repeated 5 times. For reference, the shortest solution using a regex is 45 bytes long:

```
StringContainsQ@RegularExpression@"(.+)\1{4}"

```

*curse you RegularExpression!*
> 1 votes

# Answer
# PHP, ~~37~~ 33 bytes

thanks to NoOneIsHere, I forgot about `<?=`

program for PHP\<5.4, prints `1` for boring numbers, `0` else

```
<?=preg_match('/(.+)\1{4}/U',$n);

```

usage:

* set `register_globals=1` in `php.ini` for php-cgi
then call `php-cgi <filename> n=<number>;echo""`
* for PHP\>=5.4, replace `$n` with `$_GET[n]`

**non-regexp solution, ~~152~~ ~~147~~ 140 bytes**

```
<?for($e=$n+1;--$e;)for($f=$e;$f--;)for($a=str_split(substr($n,$f),$e),$k=$c='';strlen($v=array_pop($a));)$c-$v?$k=0&$c=$v:($k++<3?:die(1));

```
* returns exit code 1 for boring numbers, 0 else
replace `die(1)` with `die(print 1)` and append `echo 0;` to print instead
* same usage as above, but also set `short_open_tags=1` if disabled
* The outer loop got an unreasonable start value in the golfing, replace `$n+1` with `ceil(strlen($n)/5)+1` or at least with `strlen($n)` for testing or it may loop like forever.
> 1 votes

# Answer
# Haskell, 80 (63?)

It would be 63 if there were no import statement.

```
import Data.List
f x=or$tail[isInfixOf(concat$replicate 5 b)x|b<-subsequences x]

```

### Usage

```
f "11111211"
f "11111"
f "12345"
f "1112111"
f "4242424242"
f "-11111"
f "3452514263534543543543543543876514264527473275"

```

By the way, *consecutive* makes more sense to me than *continuously.*

(Sorry, I can't comment yet.)
> 1 votes

# Answer
# CJam, 22 bytes

```
q:T,{)Tew{5*T\#)}/}%:+

```

Try it online!

Takes sum of 1-indexed positions of all possible repeated substrings in the input. Returns 0 if interesting, anything non-zero if boring.
> 1 votes

# Answer
# Japt, 7 bytes

```
øUã mp5

```

Try it (includes all test cases)

```
øUã mp5     :Implicit input of string U
ø           :Does U contain any element of
 Uã         :  Substrings of U
    m       :  Map
     p5     :    Repeat 5 times

```
> 1 votes

# Answer
# Vyxal `Ṡs`, 34 bitsv2, 4.25 bytes

```
K5*vc

```

Try it Online! The 05ab1e answer but in less bytes :)
> 1 votes

# Answer
# JavaScript (Node.js), 77 bytes

```
s=>s.some((_,i)=>s.some(c=>--i<0&&([,s]+1).split([t+=[,c]]+t+t+t+t)[1],t=''))

```

Try it online!
> 1 votes

# Answer
# TSQL, 151 bytes

Golfed:

```
DECLARE @t varchar(99)='11111'

,@z bit=0,@a INT=1,@ INT=1WHILE @a<LEN(@t)SELECT @z=IIF(@t LIKE'%'+replicate(SUBSTRING(@t,@a,@),5)+'%',1,@z),@=IIF(@=20,1,@+1),@a+=IIF(@=1,1,0)PRINT @z

```

Ungolfed:

```
DECLARE @t varchar(99)='11111'

,@z bit=0,
@a INT=1,
@ INT=1
WHILE @a<LEN(@t)
  SELECT
    @z=IIF(@t LIKE'%'+replicate(SUBSTRING(@t,@a,@),5)+'%',1,@z),
    @=IIF(@=20,1,@+1),
    @a+=IIF(@=1,1,0)

PRINT @z

```

**Fiddle**
> 0 votes

# Answer
# PowerShell, 26 bytes

```
$args[0]-match"(.+)\1{4}"

```

I'm by no means a regex master, so credit to the other answers for that.
> 0 votes

# Answer
# JS without regexes, 166

```
b=s=>{for(let i=0;i<s.length-4;i++){for(let n=1;n<=Math.floor((s.length-i)/5);n++){if([1,2,3,4].every(k=>s.slice(i,i+n)==s.slice(i+n*k,i+n*(k+1))))return 1}}return 0}

```

non minified:

```
// test any start pos, and length
var b = s => {
    for (let i = 0; i <= s.length - 5; i++) {
        for (let n = 1; n <= Math.floor((s.length - i) / 5); n++) {
            // test if s is boring at position i, with length n
            if ([1, 2, 3, 4].every(k => s.slice(i, i + n) === s.slice(i + n * k, i + n * (k + 1)))) {
                return 1;
            }
        }
    }
    return 0;
};

console.log(b('11111'));
console.log(b('12345'));
console.log(b('1112111'));
console.log(b('-11111'));
console.log(b('3452514263534543543543543543876514264527473275'));

```
> 0 votes

# Answer
# Clojure, 24 bytes

```
#(re-find #"(.+)\1{4}"%)

```

Uses clojure's falsey values of `nil`/`false` and truthy values for everything else. Specifically, `nil` when no match is found for false, and an array `[]` for true when a match is found like for 11111 then `["11111" "1"]` is true.
> 0 votes

# Answer
# Scala 3, 27 bytes

```
_.matches(".*(.+)\\1{4}.*")

```

Attempt This Online!
> 0 votes

---
Tags: code-golf, number
---


# Question
Title: Shortest digid-app GetPercentageRounds function
## Context

So the Dutch "Ministerie van Binnenlandse Zaken en Koninkrijksrelaties" (NL) - "Ministry of the Interior and Kingdom Relations" (EN) recently released the source code of their digid-app.

They have some goofy code in there, which led to mockery and memes on reddit

Source code of the offending method can be found here. Here's a copy:

```
private static string GetPercentageRounds(double percentage)
{
    if (percentage == 0)
        return "⚪⚪⚪⚪⚪⚪⚪⚪⚪⚪";
    if (percentage > 0.0 && percentage <= 0.1)
        return "⚪⚪⚪⚪⚪⚪⚪⚪⚪";
    if (percentage > 0.1 && percentage <= 0.2)
        return "⚪⚪⚪⚪⚪⚪⚪⚪";
    if (percentage > 0.2 && percentage <= 0.3)
        return "⚪⚪⚪⚪⚪⚪⚪";
    if (percentage > 0.3 && percentage <= 0.4)
        return "⚪⚪⚪⚪⚪⚪";
    if (percentage > 0.4 && percentage <= 0.5)
        return "⚪⚪⚪⚪⚪";
    if (percentage > 0.5 && percentage <= 0.6)
        return "⚪⚪⚪⚪";
    if (percentage > 0.6 && percentage <= 0.7)
        return "⚪⚪⚪";
    if (percentage > 0.7 && percentage <= 0.8)
        return "⚪⚪";
    if (percentage > 0.8 && percentage <= 0.9)
        return "⚪";

    return "";
}

```

## Try it online:

https://dotnetfiddle.net/aMEUAM

## Challenge

Write code in any language as short as possible to replicate the above function

## Rule clarification

* You must exactly match the input and output of the original function. Substituting the ball characters with something else is not allowed.
* You must stick to the functions original boundaries. Meaning if the input is something unexpected like -1 or 42 you must still return the same result as the original function.

# Answer
> 13 votes
# JavaScript (Node.js), 53 bytes

```
f=(n,i=10)=>i?f(n,--i)+(n>=0&n<=i/10?"⚪":""):''

```

Try it online!

Need `n>=0` to handle NaN

# Answer
> 12 votes
# Scratch, ~~172 166~~ 142 bytes

This program outputs to a global variable `o` which is automatically displayed and assumes that the `i` variable is initialized at 0 and that the procedure will only be run once1.

```
define(n
set[o v]to(
set[a v]to[
repeat(10
change[i v]by(1
if<<(i)>((n)*(10))>and<(-.01)<(n)>>then
set[a v]to[⚪
end
set[o v]to(join(o)(a

```

Try it on Scratch!

## Scratch, 116 bytes

This solution is technically invalid because it replaces the emojis with the characters "x" and "\_". Unfortunately, this method cannot use emojis due to the way strings seem to work in Scratch, as getting the character at a certain index of a string doesn't work for unicode chars. I just wanted to add this since I think it's really cool.

```
define(n
set[o v]to(
repeat(10
change[i v]by(1
set[o v]to(join(o)(letter((1)+<<(i)>((n)*(10))>and<(-.01)<(n)>>)of[x_

```

Try it on Scratch!

1For testing purposes, the procedure is run many times in the scratch link, so `o` is pushed to an array of test results at the end of each call.

# Answer
> 9 votes
# Type System (TypeScript 4.9.4) - ~~243~~ 188 Bytes

Now they can validate their function with type safety!

* 56 Bytes thanks to **@ASCII-only**
* 8 Bytes thanks to **@ASCII-only**
* 114 Bytes only by **@ASCII-only** (without rounding)

```
type H<N,C=[],E={length:N},I='',L=C['length'],D=(`${N}`extends`${}e-${}`?'0.0':`${N}.0`)extends`0.${L}.0`|`0.${E['length']}${string}`?'⚪':I>=`${D}${L extends 9?'':H<N,[...C,0],C,D>}`

```

**Example usage**:

```
type ProgressBarZero = H<0>
type ProgressBarHalf = H<0.5>
type ProgressBarFull = H<1>

```

**(Original) Un-golfed Version**:

```
type LoadingBar<
  // N is a given number
  N extends number,
  // AddOne is used to add 1 to a number since we can't use addition [0]=1, [1]=2, [9]=10 etc.
  AddOne extends number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
  // Progress is calculated by checking if N is 0 if so return 0, otherwise cast to string and extract first digit after 0.(M)(R...)
  // and cast to a number along with anything else after R. If R is an empty string '' then we can just return M since this means
  // it must be .(1)(0), .(2)(0), .(3)(0), etc. otherwise we use M to index V to add one.
  Progress = N extends 0 ? 0 : `${N}` extends `0.${infer M extends number}${infer R}` ? R extends '' ? M : AddOne[M] : 10,
  // ArrayCounter is an empty tuple which is used to count the iterations by tracking the length and appending
  // elements recursively.
  ArrayCounter extends any[] = [],
  // IsLoading is a cached flag to help denote when to display ⚪ or  since we can only check for equality and not less than
  // or greater than we need to be able to keep track of when we are finished showing the percent loaded.
  IsLoading extends number = 1,
  // OutputString is our output string which we return at the end.
  OutputString extends string = '',
  // Length tracks the length of A each pass.
  Length extends number = ArrayCounter['length'],
  // Check if we have loaded all the  elements by checking if our Length is equal to our Progress
  CheckIsLoaded extends number = (Progress extends Length ? 0 : 1) & IsLoading,
  // Symbol is which string to display and in order to check for "never" we need to compare [never] inside a tuple
  // otherwise it becomes distributive, also [never] = [0]
  Symbol extends string = [CheckIsLoaded] extends [0] ? '⚪' : ''
> =
  // Here is the logic portion: if our Length is 10 we are finished and return the OutputString
  Length extends 10 ?  OutputString :
  // Otherwise call recursively adding a new element to ArrayCounter each time to keep of the iterations
  // using EndLoading as the new IsLoading and concatinating Symbol to OutputString. Unfortunately,
  // we can only keep track of the tuple ArrayCounter'ss length and not strings.
  LoadingBar<N, AddOne, Progress, [...ArrayCounter, Symbol], CheckIsLoaded, `${OutputString}${Symbol}`>

```

Try it on the TypeScript playground!

# Answer
> 7 votes
# Java (JDK), 70 bytes

```
p->{var s="";for(int i=0;i<=9;)s+=p<0|p>i++*.1?"":"⚪";return s;}

```

Try it online!

Don't hesitate to correct me, or ask me if this needs explanations!

I've really tried to do this challenge using alternative approaches, but it could never beat the good ol' for :(

---

*Here are my other attempts so far :*

Using the repeat available in Java 11+ (**78 bytes**) :

```
p->{int n=(int)(p<0|p>1?0:10-p*10);return"".repeat(10-n)+"⚪".repeat(n);}

```

Using a single inline Stream (**85 bytes**) :

```
p->"0123456789".chars().mapToObj(e->p<0|p*10>e-48?"":"⚪").reduce("",(a,b)->a+b)

```

Creating a 11-bits binary (the "1" to the left end is to protect the "ten zeroes" case) and mapping 1's as , and 0's as ⚪ (**109 bytes**) :

```
p->Integer.toString(2048-(1<<(int)(p<0|p>1?0:10-p*10)),2).substring(1).replace("0","⚪").replace("1","")

```

Creating a number of exactly 10 digits composed exclusively of 9's mapped as , and 8's mapped as ⚪ (**110 bytes**) :

```
p->(""+(long)(Math.pow(10,10)-Math.pow(10,(int)(p<0|p>1?0:10-p*10))/9)).replace("8","⚪").replace("9","")

```

Dirty recursion with optional parameter to match original function call signature (**113 bytes**) (fails if called without parameter) :

```
String f(Double... p){return p.length<2?f(p[0],10d):p[1]>0?f(p[0],--p[1])+(p[0]<0|p[0]>p[1]*.1?"":"⚪"):"";}

```

# Answer
> 7 votes
## Excel formula, 58 ~~82~~ ~~104~~ bytes

> -22 bytes thanks to @DominicvanEssen massive optimizations !
>
> -24 bytes thanks to @TaylorAlexRaine even more massive optimization !

```
=LEFT(REPT("",-INT(-10*A1^(A1>=0)))&REPT("⚪",10),10)

```

Put the formula in any cell, and the parameter in the "A1" cell

---

Alternative solution : Creating a number of exactly 10 digits composed exclusively of 9's mapped as , and 8's mapped as ⚪ (**82 bytes**) :

```
=SUBSTITUTE(SUBSTITUTE(10^10-1-INT(10^INT(10*(1-A1^(A1>=0)))/9),9,""),8,"⚪")

```

# Answer
> 6 votes
# Japt, 34 bytes

```
*A c mA         : multiply input by 10, round up to nearest whole n, max of this and 10. Store this result in U
<0?A:U          : If U is negative, 10, else U. Store in V
""pV +"⚪"pVnA : Blue dot repeated V times, white dot repeated 10-V times
                : Implicit output

```

Try it

## Japt `-E""`, 24 bytes \+ 13 = 37

`-E"s"` implicitly outputs "s" if an error is thrown, but is considered a cheating flag.

```
*A c            : Multiply input by 10, round up to whole number. Store in U
""pU +"⚪"pUnA : Blue dot repeated U times, white dot repeated 10-V times
                : Implicit: Output that, or 10 dots if (0 < input < 1) is false

```

Try it

# Answer
> 6 votes
# C(gcc/clang) 86 characters (126 bytes)

returns a constant string of 30 bytes, same as the original and not a null terminated string as is common in C.

```
const char*p(double f){return"●●●●●●●●●●○○○○○○○○○○"+3*(int)(10.5-10*(f>1?1:f<0?1:f));}

```

```
const char*p(double f){
    return "●●●●●●●●●●○○○○○○○○○○" //the constant string we index into
    +3*                           //each character is three bytes
    (int)(                        //pointers must be integers
        10.5                      //constant offset handling centering and rounding
        -10*(                     //multiply up from the range 0->1 to
            f>1?1:f<0?1:f         //correctly enforce the bounds
        )
    );
}

```

# Answer
> 6 votes
# , 48 bytes

```
function(i)intToUtf8(9898+118411*(0:9<10*i|i<0))

```

Try it online!

# Answer
> 5 votes
# Vyxal `U`, 24 bytes

```
01?ŀ¬∨:⌐"₀*⌈`ǐẏḭ≈≠ṙ₅`½*∑

```

Try it Online!

Utf-8 emojis amiright

## Vyxal, 16 bytes

```
01?ŀ[₀*⌊×*₀↲|×₀*

```

Try it Online!

Uses `*` for and  for ⚪, otherwise I'd have to score this in utf 8.

# Answer
> 5 votes
# PowerShell Core, 59 bytes

```
param($a)-join(0..9|%{("⚪","")[$a-lt0-or$_-lt$a*10]})

```

Try it online!

Fixed the behaviour for negative values, thanks Adám!

# Answer
> 5 votes
# C# (.NET 7), 72 bytes

```
string a(double b,double c=0)=>c<.9?(b<0|b>c?"":"⚪")+a(b,c+.1):"";

```

Try it here!

```
string a(double b,double c=0) =>  //return
    c<.9                           //if counter is less than .9
    ?                             //then
        (                         //this "X"
            b<0|b>c               //if the percentage is less less than 0 or greater than the counter
            ?                     //then
                ""              //blue ball
            :                     //otherwise
                "⚪"              //white ball
        )                         //end "X"
        +                         //plus
        a(b,c+.1)                 //the result of calling the same function again with the counter increased by .1
    :                             //otherwise (counter is greater than or equal to 1)
        "";                       //return an empty string

```

# Answer
> 5 votes
# Python, 55 bytes

-4 bytes thanks to `l4m2` and -15 bytes thanks to `Dominic van Essen`.

```
lambda n:(10-(b:=int(10-10*n)*(0<=n<1)))*''+b*'⚪'

```

Attempt This Online!

# Answer
> 5 votes
# JavaScript 62 60 57 bytes

## Update. 57 bytes

Slitly shorter version using `[...1e9+'']` to generate an array of 10 elements instead of \[...Array(10)\]

```
i=>[...1e9+''].map((_,b)=>i<0|b<i*10?'':'⚪').join``

```

```
f=i=>[...1e9+''].map((_,b)=>i<0|b<i*10?'':'⚪').join``

const testCases = [-2, 0, 0.01, 0.20, .666, 0.9, 0.99, 1, 10, NaN];
testCases.forEach(i => console.log(f(i), i))
```

```
.as-console {
  background-color: grey !important;
}
```

## Older version

Thank to @RydwolfPrograms for the `join` tip.

Non recursive solution.

```
    i=>[...Array(10)].map((_,b)=>i<0|b<i*10?'':'⚪').join``

```

This solution does not handle a NaN parameter.

# Answer
> 4 votes
# APL(Dyalog Unicode), 37 bytes SBCS

Tacit function.

```
⎕UCS 128309 9898/⍨10(⊢,-)∘⌈10×1⌊|+0∘>

```

Try it on APLgolf!

`0∘>` is argument negative? (0 or 1)

`|+` add that to the absolute value of the argument

`10×` multiply 10 by that

`10(``)∘⌈` round up and then, with 10 as left argument, apply the following function:

`-` difference between the arguments

`⊢,` prepend the left argument

`128309 9898/⍨` use those counts to replicate the code points

`⎕UCS`  convert to characters

# Answer
> 4 votes
# Pip, ~~33~~ 30 bytes

```
Y!@a?-:-a///tt'Xy.'⚪Xt-y

```

Attempt This Online!

### Explanation

I've replaced and ⚪ with `@` and `o` below so the columns will line up.

```
Y!@a?-:-a///tt'@Xy.'oXt-y
   a                      ; Command-line argument
  @                       ; Get the first character
 !                        ; Negate (truthy for 0, falsey for anything else)
    ?                     ; If that is truthy (which means 0.0 <= a < 1.0):
       -a                 ;  Negate a
         //               ;  Int-divide (rounding down) by
           /t             ;  1/10
                          ;  (i.e. multiply by 10 and round down)
     -:                   ;  Negate the result
                          ; Else:
             t            ;  10
Y                         ; Yank that value into y
              '@Xy        ; String of y copies of @ character
                   'oXt-y ; String of 10-y copies of o character
                  .       ; Concatenate the two strings

```

# Answer
> 4 votes
# Factor, 56 bytes

```
[| x | 10 iota [ x 10 * < x 0 < or 128309 9898 ? ] map ]

```

Try it online!

```
[| x |              ! a quotation taking an argument x
  10 iota           ! the range [0..9]
  [                 ! start map quotation
    x 10 * <        ! is the range number less than x times ten?
    x 0 < or        ! or is x less than zero?
    128309 9898 ?   ! 128309 if so; 9898 if not
  ] map             ! map each number in the range to something
]                   ! end quotation

```

# Answer
> 4 votes
# 05AB1E, 19 bytes

```
•
#*Γ•6ôç9ÝT/I@Id*è

```

Output as a list of characters, since strings are basically sequences of characters. But since the challenge does ask to mimic the output *exactly*, a trailing `J`oin could be added for +1 byte.

Try it online or verify all test cases.

**Explanation:**

```
•\n#*Γ•    # Push compressed integer 1283099898
       6ô  # Split it into parts of size 6: [128309,9898]
         ç # Convert both to a character with this codepoint: ["","⚪"]
9Ý         # Push list [0,1,2,3,4,5,6,7,8,9]
  T/       # Divide each by 10: [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]
I@         # Check for each value in the list whether it's >= the input
  I        # Push the input-decimal again
   d       # Check that it's non-negative (1 if >=0; 0 if <0)
    *      # Multiply that to each check, so negative inputs will become a list of 0s
     è     # 0-based index each 0 or 1 into the pair of unicode characters
           # (after which the list of characters is output implicitly as result)

```

See this 05AB1E tip of mine (section *How to compress large integers?*) to understand why `•\n#*Γ•` is `1283099898`.

# Answer
> 4 votes
# Julia 0.6, 49 bytes

```
~x=rpad(""^ceil(Int,10(0<=x<1?x:1)),20,"⚪")

```

Try it online!

If the input `x` falls outside the range \[0,1), it's replaced with `1`. The value ⌈10x⌉ determines the number of `""`, and the output is padded to length with `"⚪"`.

Using the ternary operator without spaces is deprecated in Julia 0.7 and disabled in Julia 1.0. The padding length passed to `rpad` has to be adjusted for Julia 0.6, probably because `textwidth` was added in Julia 0.7.

# Answer
> 4 votes
# Swift, 70 84 bytes

-2 bytes thanks to @hatcyl suggestion

```
var f={i in(0...9).map{i<0||i>Float($0)/10 ?"":"⚪"}.joined()}

```

Try it online!

# Answer
> 4 votes
# C# (Visual C# Interactive Compiler), 69 bytes

```
void a(double b){for(int c=0;c<10;)Write(b<0|b*10>c++?"":"⚪");}

```

Try it online!

**Iterative Solution**

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

```
string a(double b,int c=0)=>c<10?(b<0|b*10>c?"":"⚪")+a(b,++c):"";

```

Try it online!

**Recursive Solution**

# Answer
> 4 votes
# Perl, ~~52~~ 54 bytes

**Edit** : Change condition with \>=&\<= to handle NaN + add note

```
sub k($c){join'',map$c>=0&$c<=$_/10?"⚪":"",0..9}

```

Try it online!

#### Note

It is possible to remove the join part, because Perl default behavior when you print an array is to join it, but it feel cheaty. What you guys think ?

##### Perl Cheaty version - 47 Bytes

```
sub k($c){map$c>=0&$c<=$_/10?"⚪":"",0..9}

```

Try it online!

It uses "signatures 15 years beta" feature (activable via commande line -Mfeature=signature) or via import. The old school perl take 2 bytes more :

```
sub j{join'',map@_[0]<0|@_[0]>$_/10?"":"⚪",0..9}

```

#### Explaination :

```
sub j{
  join ('', # Join each element of a list with the string ''.
      map( # Return a list of what the block return for each element of the list passed in second argument
          {@_[0]<0|@_[0]>$_/10?"":"⚪"} , #@_[0] is the function first parameter, $_ the current iterated element
          (0..9)) # Simple list
}

```

### Other interesting solution :

### The substr 61|59(signatures) Bytes,

probably fastest and lightest solution, (OK NaN)

```
sub b{substr''x(10).'⚪'x(10-(@_[0]<0?10:@_[0]*10)),-10}
sub p($c){substr''x(10).'⚪'x(10-($c<0?10:$c*10)),-10}

```

### The for loop 55|57 Bytes

Work only once, dunno if it can be improve without too many bytes (KO NaN):

```
sub l($c){$a.=($c<0|$c>$_/10?"":"⚪")for 0..9;$a}

```

### Recursive 81|62 Bytes

Not very interesting at first, juste a copy cat of JS. But i run into a small bug on the "old perl" version (KO NaN):

```
sub a{(@_[1]//=10)?a(@_[0],@_[1]-1).(@_[0]<0|@_[0]>(@_[1]-1)/10?"":"⚪"):''}
sub t($n,$i=10){$i?t($n,--$i).($n<0|$n>$i/10?"":"⚪"):''}

```

I expected this to work :

```
sub z{(@_[1]//=10)?z(@_[0],--@_[1]).(@_[0]<0|@_[0]>(@_[1])/10?"":"⚪"):''}

```

But it does not. --@\_ do not work and i dont understand why.

# Answer
> 3 votes
# Jelly, 19 bytes

```
>⁵Ḷ÷¤»⁻A$ị“¢€:“&Ɠ’Ọ

```

A monadic Link that accepts a double precision floating point number and yields a list of characters.

**Try it online!** Or see the test-suite.

### How?

```
>⁵Ḷ÷¤»⁻A$ị“¢€:“&Ɠ’Ọ - Link: double D
    ¤               - nilad followed by link(s) as a nilad:
 ⁵                  -   ten
  Ḷ                 -   lowered range -> [0, 1, 2, ..., 9]
   ÷                -   divided by (ten) -> [0, 0,1, 0.2, ..., 0.9]
>                   - (D) greater than (that) (vectorised) -> G
        $           - last two links as a monad - f(D):
       A            -   absolute value (D)
      ⁻             -   (D) not equal to (that)? -> K   (K = (x<0 or x is nan)?)
     »              - (G) maximum (K) (vectorised)
                       -> L = list with 1 at blue and 0 at white
          “¢€:“&Ɠ’  - list of base 250 compressed numbers = [128309, 9898]
         ị          - (L) index into (that) (vectorised)
                  Ọ - cast to characters

```

# Answer
> 3 votes
# Retina 0.8.2, 67 bytes

```
^[^0]|^0.9.
10$*@
T`_d`d`....
\d(..)?
$1$*@10$*⚪
1M!`.{10}
@

```

Try it online! Link includes test cases. Explanation:

```
^[^0]|^0.9.
10$*@

```

Unless the input is from `0` to `0.9` inclusive, put 10 `@`s at the start. (I use `@` as it's a single UTF-16 character and  isn't.)

```
T`_d`d`....

```

Increment the digits if there are at least three (not including the decimal point) i.e. leave `0`, `0.1` ... `0.9`.

```
\d(..)?.*
$1$*@10$*⚪

```

Convert the number of tenths (if any) into `@`s and also add 10 s.

```
1M!`.{10}

```

Keep just the first 10 characters. This removes any surplus s and also spurious `@`s or  arising from later digits.

```
@

```

Turn `@`s into s.

# Answer
> 3 votes
# C (gcc) with `-lm`, ~~86~~ 85 Unicode characters (~~91~~ 90 bytes)

* -1 thanks to ceilingcat

Converts the value to an integer to avoid floating-point rounding issues. Although `float` would be sufficient for this task, the original specified a `double`, so I used that type instead.

```
b,c;f(double a){for(b=c=fmin(a<0?:a,1)*10;b--;)printf("");for(;c++<10;)printf("⚪");}

```

Try it online!

# Answer
> 3 votes
# Arturo, 54 bytes

```
$[x][join map 0..9'n[(or? n<x*10x<0)?->""->"⚪"]]

```

Try it

```
$[x][                 ; a function taking an argument x
  join                ; join a block of strings into a string
  map 0..9'n[         ; map over 0..9 and assign current element to n
    (or? n<x*10x<0)?  ; is n<x*10 or x<0?
    ->""            ; blue orb if so
    ->"⚪"            ; white orb if not
  ]                   ; end map
]                     ; end function

```

# Answer
> 3 votes
# Japt `-P`, 22 bytes

```
AÇ¨A*U©ÎÌ?9898d:# 309d

```

Try it

```
AÇ¨A*U©ÎÌ?9898d:# 309d     :Implicit input of float U
A                          :10
 Ç                         :Map the range [0,A)
  ¨A*U                     :  Is greater than or equal to A*U
      ©                    :  Logical AND with
       Î                   :    Sign of U
        Ì                  :    Sign of difference with -1
         ?                 :  If true
          9898d            :    Character at codepoint 9898
               :           :  Else
                # 309d     :    Character at codepoint 128309
                           :Implicitly join and output

```

# Answer
> 3 votes
# JavaScript, 68 bytes

Without recursion:

```
(p,i=0)=>'⚪'.repeat(10).replace(/⚪/g,e=>p>=0&i++>=p*10?e:'')

```

Try it:

```
f=(p,i=0)=>'⚪'.repeat(10).replace(/⚪/g,e=>p>=0&i++>=p*10?e:'')

console.log(f(-2));
console.log(f(0));
console.log(f(1));
console.log(f(2));
console.log(f(0.1));
console.log(f(0.4));
console.log(f(0.68));
console.log(f(0.9));
console.log(f(0.99));
console.log(f(NaN));
```

```
.as-console {
  background-color: grey !important;
}
```

## UPD 96 -\> 86

Thanks to mousetail for the tip to reduce bytes count

## UPD 86 -\> 70

Thanks to Dominic van Essen for the tip to reduce bytes count

## UPD 70 -\> 68

Thanks to Rydwolf Programs for the tip to reduce bytes count

# Answer
> 3 votes
# Scala, ~~81~~ 78 bytes

saved 3 bytes thanks to comment.

Try it online!

```
def f(p:Double):String=(0 to 9).map(i=>if(p<0|p>i*.1)""else"⚪").mkString

```

Ungolfed version

```
object Main {

   def f(p: Double): String =
    (0 to 9).map(i => if (p < 0 || p > i * 0.1) "" else "⚪").mkString

   def main(args: Array[String]): Unit = {
    println(f(-10.0))   // expected :
    println(f(-0.01))   // expected :
    println(f(0.0))     // expected : ⚪⚪⚪⚪⚪⚪⚪⚪⚪⚪
    println(f(0.001))   // expected : ⚪⚪⚪⚪⚪⚪⚪⚪⚪
    println(f(0.1))     // expected : ⚪⚪⚪⚪⚪⚪⚪⚪⚪
    println(f(0.11))    // expected : ⚪⚪⚪⚪⚪⚪⚪⚪
    println(f(0.5))     // expected : ⚪⚪⚪⚪⚪
    println(f(0.9))     // expected : ⚪
    println(f(0.91))    // expected :
    println(f(1.0))     // expected :
    println(f(10.0))    // expected :
  }
}

```

# Answer
> 2 votes
# Charcoal, 21 bytes

```
Ｎθ⭆χ§⚪‹ι×χ∨‹θ⁰θ

```

Try it online! Link is to verbose version of code. Explanation:

```
Ｎθ                  First input as a number
   χ                Predefined variable 10
  ⭆                 Map over implicit range and join
     ⚪             Literal string `⚪`
    §               Indexed by
        ι           Current value
       ‹            Is less than
          χ         Predefined variable 10
         ×          Multiplied by
             θ      Input number
            ‹       Is less than
              ⁰     Literal integer `0`
           ∨        Logical Or
               θ    Input number
                    Implicitly print

```

Although  and  are not in Charcoal's code page it can still represent them using special byte sequences which take 3 and 4 bytes respectively as you can see in its `xxd`-style dump: Try it online!

# Answer
> 2 votes
# Nibbles, 22.5 bytes (45 nibbles)

```
+.*10`,10=`$?@]~-$@@%`D-256~f09f94b500e29aaa

```

Nibbles uses only integers, so input to the 'getpercentagerounds' function is a percentage value 0-100 (and values outside this range mimic the behaviour of the digid-app reference implementation).

Nibbles also doesn't natively handle multibyte characters, but here we work around this by outputting multi-character strings that re-create the encoding of the multibyte "" and "⚪" characters.

Note that if we take input as integers in the range 0-10 (and handling values outside this appropriately), the Nibbles code can be reduced to 19.5 bytes (39 nibbles: `.,10=`$?@/$@@%`D-256~f09f94b500e29aaa`) but this doesn't seem a very faithful match to the input/output of the digid-app reference function.

# Answer
> 2 votes
# TypeScript’s Type System, ~~122~~ 143 bytes

```
//@ts-ignore
type F<N,A=[],C="",X=A["length"]>=N extends`0.${X}${infer R}`?F<1,R extends""?A:[...A,C],"⚪">:X extends 10?A:F<N,[...A,C],C>

```

Try it at the TypeScript playground!

+21 bytes because I read the challenge wrong :(

This is a generic type F that takes a string type N like `"0.52"` or `"-1.2"`.

This runs with no compiler errors. If compiler errors are OK, as in @Asleepace’s 186 byte submission, the `//@ts-ignore` comment can be removed for -13 bytes, but that’s not something I’m comfortable with using as a default since it breaks precedent of many other submissions.

Takes input as a string like `"0.0"` rather than a number type like `0`.

```
type F<
  N,              // N is the input string
  A = [],         // A is the list of dots we will add to recursively
  C = "",       // C is which dot to append
  X = A["length"] // X is an alias for the length of A
> =
  // does N match the pattern 0.{X}{R = anything else} ?
  // N = 0.52, A = [b,b,b,b,b] -> R = "2"; A = [b] -> no match
  N extends `0.${X}${infer R}`
  ? F<1,                           // if it matched, recurse with N = 1,
      R extends "" ? A : [...A,C], // append C to A if R is empty,
      "⚪"                         // C = w
    >
  : X extends 10       // else: if X is 10,
  ? A                  // return A
  : F<N, [...A, C], C> // otherwise: recurse with C appended to A

```

# Answer
> 1 votes
# Zsh, 60 bytes (55 chars)

```
1=$[$1<0?1:$1];b=${(l:$1*10+.9:::)a};<<<${(r:10::⚪:)b}

```

Try it online!

# Answer
> 1 votes
# Lua, 85 bytes

```
n=math.ceil(...*10)n=(n<0or n>10)and 10or n print((''):rep(n)..('⚪'):rep(10-n))

```

Try it online!

```
n=math.ceil(...*10)
n=(n<0or n>10)and 10or n                -- if n is outside range, set to 10
print((''):rep(n)..('⚪'):rep(10-n)) -- print 10 circles, n of them blue

```

---
Tags: code-golf, number
---


title: Is it true? Ask Jelly!

text:
# Question
Title: Is it true? Ask Jelly!
### Background

Inspired by Octave's (and, by extension, MATL's) very convenient interpretation of truthy/falsy matrices, Jelly got the Ȧ (Octave-style *all*) atom.

Ȧ takes an array as input and returns **1** if the array is non-empty and does not contain the number **0** (integer, float, or complex) **anywhere in the tree structure**; otherwise, it returns **0**.

For example, the array **\[\[\]\]** is truthy because it is non-empty and contains no zeroes, but **\[\[0\]\]** is falsy because it contains a **0** at the innermost level.

### Task

In a programming language of your choice, write a full program or a function that takes a possibly empty, possibly jagged array of *integers* as input and prints or returns a truthy or falsy value that indicates if Ȧ would return **1** or **0**, respectively.

Your submission must abide to the following rules.

* The truthy and falsy values **must be consistent for all inputs**, i.e, all arrays for which Ȧ returns **1** must map to the same truthy value, and all arrays for which Ȧ returns **0** must map to the same falsy value.
* Since full programs can only take string representations of arrays as input, this is allowed. However, you must use the canocical representation of your language, as returned by `repr` or similar.

In particular you cannot assume that the first element of the array will be preceded by a space.
* If (and only if) your language cannot represent jagged arrays natively, you may take a string representation of the input, using the canonical syntax of any pre-existing programming language.
* If your language has several ways of representing jagged arrays (e.g., lists and tuples), you only have to support one of them.
* If your language has a built-in that is itself a valid submission to this challenge, **you may not use it in your answer**. All other built-ins are allowed.
* You are encouraged to post answers using both array and string manipulation, even if one is significantly shorter than the other.
* All standard rules apply.

May the shortest code in bytes win!

### Truthy test cases

```
[1]
[10]
[[]]
[[[[1]]]]
[[], [1], [1, 2]]
[[1], [1, [2]], [1, [2, [3]]]]
[[8], [8, [9]], [8, [9, [10]]]]

```

### Falsy test cases

```
[]
[0]
[0, -1]
[-1, 0]
[[[[0]]]]
[[0], [1, 2], [3, 4, 5]]
[[8], [8, [9]], [8, [9, [1, 0]]]]
[-1, 0, 0, 0]

```

# Answer
# Jelly, 3 bytes

```
ṭFẠ

```

`F` flattens the input list.

tacks on the original input list as an element, which is falsy if and only if it is empty.

then checks if any element in the flattened list, or the original list itself, is falsy.

---

(Original answer)

```
FẠ^Ṇ

```

Thanks to Dennis for encouraging finding a solution matching his.

`FẠ` gives 0 if the input contains a falsy value at any depth, else 1. This is what `Ȧ` does, except for empty lists.

gives 1 if the input is a falsy value, else 0. The only falsy list is the empty list.

XOR-ing the two gives the answer.

---

```
F;WẠ

```

This is much in the same spirit as Dennis's `F;LẠ`, but instead of using `L` to put a zero in the list when the list is empty, it uses `W` to put the empty list into itself (producing `[[]]`), making it contain a falsy element.
> 39 votes

# Answer
## Retina, 10 bytes

```
A`\b0
^...

```

Try it online!

First we remove the input if it contains a zero. The we try to match at least three characters from the beginning of the string (to ensure that the input hasn't been eliminated in the previous stage, or was only `[]` to begin with).
> 16 votes

# Answer
## Ruby, ~~25~~ ~~24~~ ~~23~~ ~~18~~ 16 bytes

```
p$_!~/\D0|^..$/

```

Requires the `-n` flag on the command line (+1 byte, `-e` -\> `-ne`).

Try it online!

This is a full program that takes input in Ruby's canonical array format on STDIN and outputs `true` or `false` on STDOUT.

```
 $_              # line of input that was read automatically (-n)
   !~/        /  # does not match the regex...
      \D0        #   a non-digit followed by a 0
         |       #   or...
          ^..$   #   a 2-length string (which must be [], the empty array)
p                # output the result

```

**23 byte** function version:

```
->a{"#{a}"!~/\D0|^..$/}

```

This is a proc that takes one argument, the array to be tested.

Thanks to Martin Ender for a byte and to Ventero for two bytes!
> 12 votes

# Answer
# 05AB1E, ~~9~~ 8 bytes

-1 bytes thanks to Emigna

```
)Q¹˜0å~_

```

Explanation:

```
)Q        Is the length of the input 0?
  ~    _  ... NOR ... (just for you, Dennis)
   ¹˜     Input deep flattened
     0å   Contains 0

```

Try it online!
> 8 votes

# Answer
# APL (Dyalog), ~~21~~ ~~12~~ 7 bytes

*Golfed 5 bytes thanks to Adám by using forks*

```
⍬∘≡⍱0∊∊

```

Try it online!

This is my first try at Dyalog. Golfing tips are welcome!

### Explanation

```
⍬∘≡                   Fork; Is the argument a null set
   ⍱                  Nor
    0∊∊               0 belongs to the enlisted form of the argument
                      For example, (1 (2 (3 (0)))) would become
                      1 2 3 0 using the ∊ monad
                      Then we check if zero belongs to this vector

```
> 8 votes

# Answer
# Jelly, 4 bytes

```
FẠ_Ṇ

```

**Try it online!**

`Ȧ` yields `0` if the input is empty or contains a `0`, otherwise it is `1`.

`FẠ` yields `0` if the flattened input contains a `0`, leaving only the edge case of an empty array (since the input is guaranteed to be an array).

is a non-vectorising logical not monad, and hence returns `0` for any non-empty list and `1` for the empty list. As such this can simply be subtraced from the result of `FẠ` using `_`.
> 8 votes

# Answer
## Mathematica, 17 bytes

```
#!={}&&#~FreeQ~0&

```

`FreeQ` does the check against `0` for us, but of course it would return `True` for input `{}`, so we need to check that case separately.
> 7 votes

# Answer
# Operation Flashpoint scripting language, ~~199~~ 188 bytes

```
A={f={private["_i","_r"];_r=1;_i=0;while{_i<count _this}do{o=_this select _i;if(o in [o])then{if(o==0)then{_r=0}}else{_r=o call f};_i=_i+1};_r};if(count _this==0)then{0}else{_this call f}}

```

Call with:

```
[3,6,4,[4,6],[3,6,[],[2,4,[0],3]]] call A

```

or with:

```
hint format["%1", [3,6,4,[4,6],[3,6,[],[2,4,[0],3]]] call A]

```

Explanation:

In the game's scripting language, any string containing code can be called. The curly braces `{}` denote the beginning and the end of a string. (Quotation marks work too, but that gets messy when they are nested.) So, `A={...}` assigns a string to variable `A`, and the variable can then be called like a function with: `<argument> call A`. Basically any string can be treated as a block of code.

Then, inside the "function" `A`, we define another function `f`. `private` declares the two variables `_i` and `_r` local to function `f`. A local variable's name has to start with an underscore.

`while {} do {}` is a loop, where the first string (denoted by `{}`) contains the code for the loop condition and the second one for the loop body.

`_this` is the argument that was passed with the `call` function. `_this` can be of any type, but here we assume it is an array.

In the loop, `o=_this select _i` accesses the \_i:th element of the array and assigns it to variable `o`. `if (o in [o])` is a trick to determine if the `o` is another array or not. If `o` is a number (or anything other than an array), `o in [o]` will evaluate to `true`, because the `in` function finds a value matching `o` from the array `[o]`. If `o` is an array, the expression yields `false`, because the `in` refuses to compare arrays.

If `o` is not an array, we check if it equals zero, and if it does, we'll set the variable `_r`, which we'll use as the return value, to zero. Otherwise, if `o` is an array, we assign to `_r` the return value of the recursive call to `f` with the new array `o` as the argument.

After the loop, at the end of function `f`, we evaluate the expression `_r`, which yields the value of `_r`, and as this is the last expression to be evaluated, this is what the call to function `f` returns.

Now that we have defined `f` (`f` need not be inside `A`, but this way we could have declared it a local variable/function (no difference really) of `A` if we didn't want to save some bytes), let's get back `A`. `if (count _this == 0)` checks if `A`'s input array is empty, and if it is, `A` returns 0. Otherwise the function `f` is called and its return value will be `A`'s return value.

One might notice that it seems that a semicolon would be missing from a few of places, but this is not the case, because a semicolon is only needed after a statement if another statement follows it inside the same block of code (i.e. string).
> 7 votes

# Answer
# Perl 5, 15 bytes

Saved 2 bytes by using the same technique as Doorknob's Ruby answer.

14 bytes of code + `-p` flag

```
$_=!/\b0|^..$/

```

Try it online!

`/.../` ensures that the array isn't empty (it will match on any array but `[]`.
`/\b0/` will only match if there is a `0` in the array. (the `\b` ensures that the `0` isn't a part of another number but a whole number).
> 5 votes

# Answer
# Haskell, 48 bytes

```
f x=or[elem c"[,"|c:'0':_<-scanr(:)[]x]<(x<"[]")

```

Try it online!

Thanks to Lynn for the test cases and the `x<"[]"` trick.

The outer inequality requires `(x<"[]")` to be True (nonempty list) and `or[elem c"[,"|c:'0':_<-scanr(:)[]x]` to be False (no zeroes).

Characters of `0` are detected as following a `,` or `[`, as opposed to a number like `20`. The expression `scanr(:)[]x` generates all suffices of `l`, and `c:'0':_<-` captures those whose second character is `'0'`. Then, `elem c"[,"` checks whether the first character is `,` or `[`.

I assume here that Haskell-style lists don't have spaces, but if so `','` can just be replaced by `' '`.

Here's a more direct 48-byte method, though it produces `0`'s and `1`'s which aren't Truthy/Falsey in Haskell.

```
f"[]"=0
f(c:'0':_)|elem c"[,"=0
f(_:t)=f t
f _=1

```
> 5 votes

# Answer
# Jelly, 4 bytes

```
F;LẠ

```

Try it online!

### How it works

```
F;LẠ  Main link. Argument: A (array)

F     Flatten A.
  L   Yield A's length.
 ;    Concatenate.
   Ạ  All; Tell if all elements of the resulting 1D array are truthy.

```

Note that the Ạ atom behaves like Python's `all` and thus is rather different from the banned Ȧ.
> 5 votes

# Answer
# Grime, ~~16~~ ~~14~~ 11 bytes

*Thanks to Zgarb for saving 5 bytes.*

```
e`s\0v#|!..

```

Try it online!

The `e` tells Grime to try and match the entire input and print `0` or `1` depending on whether that's possible.

The `|!` is effectively a "neither" operator, because `x|!y` is shorthand for `(x|y)!`. So we make sure that the input neither contains a zero preceded by a symbol nor is a string of only two characters (`[]`).

A note about the second half: `P#` matches a rectangle that contains at least one match of `P`. However, in our case `P` consists of both `s` and `\0` so that would normally require parentheses: `(s\0)#` (because the precedence of `#` is too high). But Grime has a really neat feature where you can modify the precedence of operators with `^` and `v`. So by using `v#` we lower `#`'s precedence so that it's lower than that of any other operator (including concatenation), which lets us save a byte on the parentheses.
> 4 votes

# Answer
# Julia, 45 bytes

```
a(x)=all(a,x);a(x::Int)=x!=0;g(x)=x!=[]&&a(x)

```

This creates a function `g` that indicates whether Ȧ would be 1 or 0 by calling a recursive function `a`. To make a suitable `a`, we use multiple dispatch:

```
# A method for scalar values
a(x::Int) = x != 0

# A recursive fallback for arrays
a(x) = all(a, x)

```

The function `all` takes a function argument, so we're calling `a` on each element of the input. Then we simply define the function for the submission as

```
g(x) = x != [] && a(x)

```

Basically we just need `a` but with a check to correctly handle `[]`.

Try it online!
> 4 votes

# Answer
# Haskell, 62 bytes

```
import Data.List
(%)=isInfixOf
f x=not(",0"%x||"[0"%x)&&x<"[]"

```

Try it online!

This is a function `String -> Bool`. Haskell’s lists are heterogenous, so there’s no built-in way to represent lists like `[0, [0]]`.
> 3 votes

# Answer
## JavaScript (ES6), 34 bytes

```
a=>a.length&&+!~`,${a}`.search`,0`

```

### Test cases

```
let f =

a=>a.length&&+!~`,${a}`.search`,0`

console.log('Truthy:')
console.log(f([1]))
console.log(f([10]))
console.log(f([[]]))
console.log(f([[[[1]]]]))
console.log(f([[], [1], [1, 2]]))
console.log(f([[1], [1, [2]], [1, [2, [3]]]]))
console.log(f([[8], [8, [9]], [8, [9, [10]]]]))

console.log('Falsy:')
console.log(f([]))
console.log(f([0]))
console.log(f([0, -1]))
console.log(f([-1, 0]))
console.log(f([[[[0]]]]))
console.log(f([[0], [1, 2], [3, 4, 5]]))
console.log(f([[8], [8, [9]], [8, [9, [1, 0]]]]))
```
> 3 votes

# Answer
# Wonder, 15 bytes

```
@&#0! iO0flat#0

```

Usage:

```
(@&#0! iO0flat#0)[1;2;3;[8;9;0]]

```

Flatten input, get all occurrences of 0, logical NOT, logical AND with input.
> 3 votes

# Answer
# Python 2, ~~45 39~~ 38 bytes

```
lambda a:(a>[])^(' 0'in`a`or'[0'in`a`)

```

Try it online!

-6 thanks to @BenFrankel

---

### previous version, without converting list to string repr, 68 bytes:

```
lambda a:(len(a)and g(a))*1
g=lambda b:all(map(g,b))if b>[]else b!=0

```
> 3 votes

# Answer
# Pip, 12 bytes

```
#Va&`\b0`NIa

```

Takes the array as a command-line argument in Pip's repr form, like `[1;[2;3]]`. Returns `1` for truthy, `0` for falsey. Try it online or verify all test cases.

### Explanation

```
              a is 1st cmdline arg (implicit)
 Va            Eval a (converting from a string to a list)
#              Take the length (0 if empty, nonzero if nonempty)
   &          Logical AND
    `\b0`      Regex pattern: word boundary followed by 0 (avoids things like 10)
         NIa   Not in a (0 if `\b0` matches in a, 1 if it doesn't)
              Autoprint

```

### Bonus answer, 12 bytes

Here's a function that takes a list instead:

```
#_>0=0N_Js^s

#_            Len(arg)
  >0          is greater than 0
    =         which also equals the following (comparison operators chain like Python's):
     0N       Count of 0's in
       _Js^s  arg, joined on space and then split on space (a hacky way to flatten)

```

TIO
> 3 votes

# Answer
# Röda, ~~59~~ 44 bytes

```
f a{[1]if{g(a)[[]!=a]}}g a{[a!=0];try a|g _}

```

Try it online!

`f` takes the input from its stream as a list that can contain other lists and integers. It returns `1` if `a` is truthy and nothing otherwise. The helper function `g` checks if `a` contains zeros.

Explanation:

```
f a{[1]if{g(a)[[]!=a]}}
f a{                  } /* Function declaration */
          g(a)          /* Call g -> pushes some booleans to the stream */
              [[]!=a]   /* Push value []!=a to the stream */
       if{           }  /* If all booleans in the stream are true: */
    [1]                 /*   Push 1 to the stream */
                        /* Otherwise return nothing */

g a{[a!=0];try a|g _}   /* Helper function */
g a{                }   /* Function declaration */
    [a!=0];             /* Push value a!=0 to the output stream */
           try          /* Ignore errors in the following if a is not a list */
               a        /* Push values in a to the stream */
                |g _    /* Pull values from the stream and */
                        /*   call g for each of them */
                        /*   (pushes boolean values to the output stream) */

```

A solution that makes use of regexes could very likely be shorter.

This answer could have been shorter if it were allowed to return multiple values. This has been discussed in one of my answers before, and it was concluded that it is allowed in the default rules to return different truthy and falsy values for different inputs, but for some reason OP forbid it here and there. :(
> 3 votes

# Answer
# MATLAB, 49 bytes

As MATLAB (as well as Octave) does not allow these kind of nested arrays, we interpret it as a string.

First we replace all non-digit characters with a space. Then we use `str2num` to convert it to an (1D) array, on which we can apply `all` (which is allowed, as it does not completely solve this task by itself.)

```
s=input('');s(s<45|s>57)=32;disp(all(str2num(s)))

```
> 2 votes

# Answer
# egrep, 7+3=10 bytes

```
\<0|^.]

```

+3 bytes for the required `-v` flag to invert the result.

Grep doesn't have any concept of arrays, so this uses a string representation as given in the question. Takes input on one line from stdin, returns via the exit code (ignore stdout).

(Now using a version which doesn't account for `01` and similar, since word-of-god is that it's OK)

### Original bash/grep entry:

```
grep -Ev '\<0+\>|^.]'

```

Finds `0`s anywhere (using the word boundary checks `\<` and `\>` to discount things like `10` or `a1`), or a whole string matching `[]`, then inverts the match.

### Breakdown:

```
grep
     -E \    # extended regular expression syntax
     -v \    # invert match
     \<0+\>  # a number of 0s with alphanumeric boundaries on both sides
     |^.\]   # or ']' as the second character (implies '[]')

```
> 2 votes

# Answer
# Javascript ES6, ~~24~~ 23 chars

Works with array, returns `true` or `false`:

```
a=>!!a[0]>/\b0/.test(a)

```

Test:

```
f=a=>!!a[0]>/\b0/.test(a)

console.log([
  [1],
  [10],
  [[]],
  [[[[1]]]],
  [[], [1], [1, 2]],
  [[1], [1, [2]], [1, [2, [3]]]],
  [[8], [8, [9]], [8, [9, [10]]]],
].every(x => f(x)===true))

console.log([
  [],
  [0],
  [0, -1],
  [-1, 0],
  [[[[0]]]],
  [[0], [1, 2], [3, 4, 5]],
  [[8], [8, [9]], [8, [9, [1, 0]]]],
].every(x => f(x)===false))
```
> 2 votes

# Answer
# √ å ı ¥ ® Ï Ø ¿ , ~~12~~ 4 bytes

```
i0Bu

```

## Explanation

```
i            › Take input as a list and automatically flatten it. If empty, push 0.
 0           › Push 0 to the stack
  B          › Pop 0 and push the number of times it appears
   u         › convert top value to its boolean

```

If result needs to be outputted ...

```
i0Buo        › same as above; o outputs the top value on the stack

```

# Previous solution

I had posted this before realising that stack based languages could leave the value on the stack as a form of output

```
i0B¿0oP?!¿o?

```

## Explanation

```
i            › Take input as a list and automatically flatten it. If empty, push 0.
 0           › Push 0 to the stack
  B          › Pop 0 and push the number of times it appears
   ¿         › If the top value is true ...
    0        › Push 0
     o       › Output the top value on the stack
      P      › Pop the top value from the stack
       ?     › End if statement
        !    › Boolean opposite of top value
         ¿   › If the top value is true ...
          o  › Output the top value
           ? › End if statement

```
> 2 votes

# Answer
## Haskell, 45

As Lynn and xnor remarked, Haskell does not come with a heterogeneously-nested list type. But it's easy to add them as a custom data type and let the function operate on that type, and this is much preferrable to operating on (urgh!) *strings*.

```
data L=L Int|T[L]
f(L n)=n/=0
f(T l)=all f l

```

To actually be able to write out such lists as literals with `[1, [2]]` syntax, you also need some typeclass fu. Full test case:

```
{-# LANGUAGE OverloadedLists, TypeFamilies #-}
import GHC.Exts (IsList(..))

instance Num L where
  fromInteger = L . fromInteger
  negate (L n) = L $ negate n
instance IsList L where
  type Item L = L
  fromList = T
main = mapM_ (print . f) (
                    [ [1]
                    , [[[[0]]]]
                    , [[8], [8, [9]], [8, [9, [1, 0]]]]
                    ] :: [L])

```

Try it online!
> 2 votes

# Answer
# Vim, 23 bytes

```
:g/0\|^..$/d
:s/.\+/1/<CR>

```

Try it online!

Outputs an empty string for false, or `1` for true. This could be shorter if I can output an empty string *or* `[]` for false (both of which are falsy values in vim).
> 2 votes

# Answer
# Stacked, 20 bytes

```
:size\flat,0 eq none

```

Try it online!

Alternatively, using a string:

```
:tostr'\d+'match'0'has¬\size¬>

```

Try it online!
> 1 votes

# Answer
## Lithp, 74 bytes

```
(def f #L::((foldl(flatten L)(?(>(length L)0)1 0)#N,A::((?(== N 0)0 A)))))

```

Try it online!

Well, this turned out longer than I'd hoped. The `[]` case tripped me up and added a few bytes. It simply flattens the list and does a fold left over it, and if it finds a 0 it sets the accumulator to 0.
> 1 votes

# Answer
# Ruby, ~~24~~ 22 bytes

```
->a{a[0]&&a*?!!~/\b0/}

```

Try it online!

Yes I know there's a better solution in Ruby but I wanted to find one taking the array in input instead of a string.
> 1 votes

# Answer
# VIM: ~~16 keystrokes~~ ~~28 keystrokes~~ 26 keystrokes

Had to add a bunch of keystrokes to take care of multiple zeros and the empty array \[\].

```
i[] 0<enter><esc>A 0<esc>h#dd0%r602x<C-x>$hd0<C-a>

```

Expects the array to be in the first and only line of the file and the cursor to be on the first character. Leaves `0` for false and a `1` for true.

Explanation

1. `i[] 0<Enter><esc>` Writes some stuff preceding the array
2. `A 0<esc>` Writes some stuff preceding the array
3. `#dd` search for the word "0", going backwards in the document and delete the line it's containing.
    * If 0 is in the array, this will stop on the second line.
        1. This leaves `[] 0` on the first line, which is an empty array.
    * Else, this will stop on the first line, leaving the line `(array) 0`

At this point, all that's left to do is to identify the empty array and output 0 if it's present, otherwise ignore it.

The possible way for a 0 to be at the third position is if it is the empty array. Thus, it's just a problem for identifying if the third character is a 0.

1. `3|a01<esc>` Writes `01` after the third character
2. `0df0` Deletes up to the first zero.
3. `lD` saves the next character, then deletes the rest of the line.

Try it online!
> 1 votes

# Answer
# tinylisp, ~~70~~ 64 bytes

```
(load library
(d _(q((X)(i(c()X)(all(map _ X))X
(q((L)(i L(_ L)0

```

The last line is an unnamed lambda function that takes a list and returns `1` for "truthy-under-Ȧ" and `0` for falsey. Try it online!

### Ungolfed

```
(load library)

(def _Ȧ
 (lambda (val)
  (if (equal? (type val) List)
   (all (map _Ȧ val))
   val)))

(def Ȧ
 (lambda (ls)
  (if ls
   (_Ȧ ls)
   0)))

```

The recursive helper function  does most of the work. If its argument is a list, we `map`  to its elements and return `1` if they are `all` truthy, `0` if any are falsey. (Conveniently, `all` returns `1` when given the empty list.) Otherwise, the argument must be an integer; we return it as-is (`0` is falsey and all other integers are truthy in tinylisp).

The main function `Ȧ` checks if the list is nonempty. If so, it calls ; if not, it returns `0`.

The golfed version takes advantage of some undefined behavior: rather than using `(e(type X)List)` to test whether `X` is an integer or a list, it does `(c()X)`, which attempts to `cons` (prepend) the empty list onto `X`. If `X` is a list, this results in a nonempty list, which is truthy. If `X` is an integer, tinylisp outputs an error message and returns an empty list, which is falsey. Since stderr is ignored, this approach is valid.
> 1 votes

# Answer
# Zsh, 19 bytes

```
egrep '\b0\b|^\[]$'

```

Try it online!

zsh doesn't have any support for nested arrays, so there is no "canonical" representation. I've used Python-style square bracket notation, but this could fairly trivially be modified for most other syntaxes.
> 1 votes

# Answer
# R, 35 bytes

```
function(x)all(unlist(x))&length(x)

```

Try it online!
> 1 votes

# Answer
# 05AB1E, 4 bytes

```
gªĀß

```

Try it online or verify all test cases.

**Explanation:**

```
g     # Push the length of the (implicit) input-list
 ª    # Append this length to the (implicit) input-list
  Ā   # Check for each inner-most integer that it's NOT 0 (0 if 0; 1 otherwise)
   ß  # Pop and push the flattened minimum of the list
      # (after which it is output implicitly as result)

```
> 1 votes

# Answer
# Fig, \\$4\log\_{256}(96)\approx\\$ 3.292 bytes

```
AfJL

```

Try it online!

-3 thanks to Steffan

```
AfJL
  JL # Prepend the length of the input
 f   # Flatten
A    # All truthy?

```
> 1 votes

# Answer
# Vyxal `r`, 3 bytes

```
fpA

```

Try it Online!

I don't think there's a flagless 3-byter. Tons of 4-byters though.
> 1 votes

# Answer
# CJam, ~~10~~ 9 bytes

*-1 byte by replacing `#)` with `&`*

```
_,\e_0&!&

```

Try it online!

Link includes all test cases

# Explanation

```
_,\e_0&!& # function
_,        # dup and push the length of the input array
  \e_     # flatten the input array
     0&   # AND the array with 0, essentially check if 0 in list
       !  # logical negate (0 IS in list => returns 0, 0 is NOT in list => returns 1
        & # bitwise AND (of the length and the 0 check)

```
> 1 votes

# Answer
# PHP, ~~63~~ 54 bytes

9 bytes saved by @user63956

```
function a($a){return$a&&!strpos(print_r($a,1)," 0");}

```

takes an array as input; returns `true` or `false`: If `$a` is not empty,
check if `print_r` output contains a `0` value.

**array solution, 83 bytes**

```
function b($a,$r=0){$r|=$a;foreach($a as$v)$r|=is_array($v)?b($v,1):!!$v;return$r;}

```

recursive function returns `1` or `0`.

**breakdown**

```
function b($a,$r=0)
{
    $r|=$a;         # if $a is not empty, set $r (no effect in recursion)
    foreach($a as$v)    # loop through elements:
        $r&=is_array($v)    # 2. if test failed, clear $r
            ?b($v,1)        # 1. if array, recurse
            :!!$v;          #    else test element <>0
    return$r;           # return $r
}

```
> 0 votes

# Answer
# Scala, 53 47 44 bytes

A lambda (assign to a variable or value of type `String=>Boolean`, and call that variable/value).

```
x=> !(x=="[]"|x.split("\\D+") contains "0")

```

I collapsed the filtering logic by splitting the input string at any non-digit character, and then checking if the resulting sequence has a 0 anywhere. We do this via string manipulation because Scala (or Java) cannot represent arbitrarily jagged arrays uniformly at the type level.

I do not handle the case of an empty string `""` as that is an illegal representation for a jagged list, the legal empty jagged list would be `"[]"`, which has to be special-cased.

The input format is exactly the OP's input format.
> 0 votes

# Answer
# CJam, 12 bytes

```
l~a_e_+:e&!!

```

Try it online! or verify all test cases

**Explanation**

```
l~            e# Read and eval a line of input
  a           e# Wrap the array in an array
   _          e# Duplicate it
    e_        e# Flatten it
      +       e# Concatenate; results in adding the input array to the beginning of itself
       :e&    e# Reduce the array using logical AND: if any element of the array is falsy,
              e#   the result will be that falsy element, otherwise a truthy element
          !!  e# Double negation (coerce to boolean)

```
> 0 votes

# Answer
## QBIC, 41 bytes

```
;?-(_lA|<3)+instr(A,@[0`)+instr(A,@,0`)=0

```

Maybe it's time to put `instr` on the to-do list... Explanation:

```
;                   Get a string from the cmd line
 -(_lA|<3)          Check the length ( _lA| ) and yield 0 for
                    strings longer than 2, 1 for shorter ones;
                    this checks for the empty array []
 +instr(A,@[0`)     Then check if the string "[0" is present,
 +instr(A,@,0`)     or the string ",0"
                    If any of the above is true, these statements give a 1.
                    Those are summed: invalid arrays have a sum > 0
?              =0   Print a -1 for 'true' arrays, and '0' for false.

```

QBIC cannot do a list-based version of this challenge.
> 0 votes

# Answer
# Pyth, 9 Bytes

```
!|/.nQ0!l

```

Takes an array and outputs True or False.

The double ! (Not) is needed so that the output is consistently true or false.

### Explanation:

```
!|/.nQ0!l
        l     - The length of the input array (input implicit on the right)
       !l     - Negate it: True if 0 else False
     Q        - Evaluate the input string to a array
   .nQ        - flatten the array
  /   0       - How often does 0 appear?
 |            - logical OR: If zero does appear return True else the length of the array
!             - Negate the result

```

Try it online!

more boring same length alternative:

```
!|}0.nQqY

```
> 0 votes

# Answer
# Prolog, 23 bytes

```
\(0^_).
\(A^B):- \A;\B.

```

Takes a list with `^/2` as the pair constructor, terminated by anything and nested if necessary. *Succeeds* if it contains `0` and *fails* if it doesn't.

## Invocation

SWISH it online!

```
?- \(5^4^3^2^1^end).
false.
?- \(5^4^3^2^1^0^end).
true.
?- \(5^4^(1^0^ -1^end)^2^1^end).
true.

```
> 0 votes

# Answer
# Pyth, 5 bytes

```
.Aa.n

```

Test suite

Uses the same approach as hvd's Jelly answer, which is fairly different from the existing Pyth answer.

Explanation:
```
.Aa.n   | Full program
.Aa.nQQ | with implicit variables
--------+-----------------------------------------------------------------
.A      | print whether all the elements of the following list are truthy:
  a   Q |  append the input to
   .nQ  |  the flattened input

```
> 0 votes

# Answer
# Haskell \+ free, 8 bytes

In order to represent a ragged list in Haskell we use a free monad of lists. We use the free library to get these free monads.

```
all(/=0)

```

Try it online!

Luckily the library implements an instance of `Foldable` for the new type so `all` from the base library works. We just check that all the elements are not equal to zero.

If the input array were of booleans, the actual truthy type of Haskell this could be `and`.

This is neat but what if we didn't have this instance?

# Haskell \+ free, 18 bytes

```
(/=0).iter product

```

Try it online!

Here we use `iter` to tear down the array. We call it with `product` so that we get the product of the entire thing in the end. If there were any zeros then the result is `0`, so to convert to a boolean we just check if it is equal to zero.
> 0 votes

# Answer
# Japt, 6 bytes

```
ÊmUc e

```

Try it

I think there's probably a way to not need the explicit `U`. There might also be a shorter way to handle the empty list case, `c e` alone is right for all other cases.

```
ÊmUc e #
 m     # Get the minimum of:
Ê      #  The length of the input
       # and:
  U    #  The input
   c   #  flattened
     e #  all elements are truthy

```
> 0 votes

# Answer
# Raku, 45 bytes

```
{?$_&&!$_».List.flat».List.flat.grep: *==0}

```

Try it online!
> 0 votes

# Answer
# Nibbles, 6.5 bytes

```
^0?`=@\$D"0"

```

Attempt This Online!

Nibbles doesn't support heterogenous arrays, so this takes the input as a string in any reasonable format.
> 0 votes

# Answer
# Nekomata \+ `-e`, 2 bytes

```
NZ

```

Attempt This Online!

```
NZ
N   Check that the list is not empty
 Z  Check that it does not contain any zeros

```
> 0 votes

---
Tags: code-golf, string, array, decision-problem, ragged-list
---