text:
Counting valid Binary Sudoku rows
Background
Binary Sudoku, also known as Takuzu, Binario, and Tic-Tac-Logic, is a puzzle where the objective is to fill a rectangular grid with two symbols (0s and 1s for this challenge) under the following constraints:

Each row/column cannot have a substring of 000 or 111, i.e. one symbol cannot appear three times in a row, horizontally or vertically.

A row/column of 1 0 0 0 1 1 violates this rule since it contains three copies of 0 in a row.

Each row/column should contain exactly as many 0s as 1s, i.e. the counts of two symbols must be the same.

A row/column of 1 0 1 1 0 1 violates this rule since it has four 1s but only two 0s.
Some examples of rows that meet the first two requirements include:
[1 0 0 1]
[1 1 0 0]
[1 1 0 1 0 0]
[1 1 0 0 1 0 0 1]

(Not relevant to this challenge) The entire grid cannot have two identical rows or columns.

Note that the constraint 2 enforces the grid size to be even in both dimensions.
Here are some examples of completed Binary Sudoku:
(4x4, using 0s and 1s)
1 1 0 0
0 1 1 0
1 0 0 1
0 0 1 1

(6x8, using Os and Xs)
O O X O X O X X
X X O X O X O O
X O X O X X O O
O O X X O O X X
X X O X O O X O
O X O O X X O X

Challenge
Given a positive integer n, calculate the number of distinct valid Binary Sudoku rows of length 2n; that is, the number of permutations of n 0s and n 1s which do not have 000 and 111 as a substring.
The sequence is A177790, leading 1 removed and 1-based.
Test cases
Here are the first 20 terms of this sequence (1-based):
2, 6, 14, 34, 84,
208, 518, 1296, 3254, 8196,
20700, 52404, 132942, 337878, 860142,
2192902, 5598144, 14308378, 36610970, 93770358

Scoring and winning criterion
Standard code-golf rules apply. The shortest submission in bytes wins.

Related (rule 2): https://oeis.org/A000984 -- number of numbers that follow the rule for any given N

Related (rule 1): 4*n-4 or 4*(n-1). The number of numbers that don't follow the rule for any given N. Inverse is 2^(2*n)-(4*n-4).

AFAIK it's not possible to reach a solution via. these two because some of the exclusions conflict.

I think this can also be called "Unruly" or "Tohu wa Vohu" (see Simon Tatham's Portable Puzzle Collection)

Jelly,  13 12  9 bytes
ŻcṚ$+Ḋ$²S

Try it online! Or see the test-suite.
How?
This code is calculating
$$\sum_{k=\lceil\frac{n}{2}\rceil}^{n}\big(\binom{k}{n-k}+\binom{k+1}{n-(k+1)}\big)^2$$
(where \$k\$ starts at \$0\$ rather than \$\lceil\frac{n}{2}\rceil\$ ...the additional terms are \$0\$ but allows a reversal trick)
ŻcṚ$+Ḋ$²S - Link: integer, n       e.g. 7
Ż         - zero range                  [0,  1,  2,  3,  4,  5,  6,  7]
   $      - last two links as a monad:
  Ṛ       -   reverse                   [7,  6,  5,  4,  3,  2,  1,  0]
 c        -   n-choose-k                [0,  0,  0,  0,  4, 10,  6,  1]
      $   - last two links as a monad:
     Ḋ    -   dequeue                   [0,  0,  0,  4, 10,  6,  1]
    +     -   add                       [0,  0,  0,  4, 14, 16,  7,  1]
       ²  - square                      [0,  0,  0, 16,196,256, 49,  1]
        S - sum                         518

Where does this formula come from?

@Jonah http://oeis.org/A003440

I think the correct formula is adding the 2 binomial

@J42161217 ah yes missed the plus sign, thanks

Pari/GP, 77 bytes
n->polcoeff([x,0,1,0]*[0,x,1,0;0,0,1,0;x,0,0,1;x,0,0,0]^(2*n-1)*[1,1,1,1]~,n)

Try it online!
This uses a nice method involving automata and is quite efficient.
Consider the automaton that checks if a string satisfies condition one. Besides the initial state and a sink state, it has four interesting states. They signify that everything is still okay, what the last letter was and whether it was the same as the one before. When we replace the x with 1 in the matrix that occurs in the program, it describes the possibilities to get from one of these states to another.
Usually we should not ignore the initial state, but since it will not be entered again, we can handle it by starting with the vector [1,0,1,0] that describes all the states that can be reached after one step. Multiplying this vector with the matrix raised to the (m-1)th power gives a vector that tells us how many words of length m lead to each state. To get their sum, we multiply with the transpose of the all-one vector. There doesn't seem to be a shorter way to get the sum of the entries of a vector.
However, we still have condition two. It could be handled by the automaton, but that would need more states, depend on n and be complicated to create. Instead, we change the matrix (and starting vector) to have an x for each transition that corresponds to reading a 1. This way, the computation will not compuite a number, but a polynomial where each term a*x^k means that there are a words accepted by the automaton (i.e. satisfying condition one) that contain k 1s. For example, for n=3 (words of length 6) that polynomial is 6*x^4+14*x^3+6*x^2. So we just have to take the coefficient of x^n.

Interesting. Can you explain what is going on here?

@Bubbler Done, I hope it's understandable.

Bash + GNU utilities, 123 121 119 bytes
dc<<<[sD1q]so[sD0q]szz`seq -f"%0.fdsK$1lK-[dsk0>zdsndlk>z[d2>od1-d2<F*]dsFxlklFxlnlk-lFx*/]dsCx1lK+d$1r-lCx+d*+" 0 $1`p

Try the test suite online!

I've added an explanation of this obscure-looking code at the end of the answer!

Shaved off 2 bytes by moving the definitions of macros F and C to the first place they're used, and then another 2 bytes by eliminating two single-quotes that were no longer required after the macros were moved.
This is another, completely different bash solution.  Unlike my other (shorter) solution, this one is very fast -- TIO can compute the value for 1800 in just under its 60-second limit.  Because it uses dc, it can handle arbitrarily large integers.
The program is based on the binomial coefficient formula from OEIS, which is computed using dc.  Since loops are such a pain to write in dc, I use seq instead to unroll the loop into a giant dc script to compute the specific number requested, and the dc script is then executed.
If you're curious (and don't want to wait the 60 seconds at TIO), here's the 1800th term in the sequence:
105480721405474718567404887164925416724980133926539712143845881075284\
901677297738964136155557073029386229070488343605298871231397783837622\
530014641802254048917232853438125993571007137377212907244683700588015\
444444467026455576839621404814982031106756318549435412359204504183866\
493764320992226326910391777276272125030010740526937030702909019208912\
640538519829602971756125307274565635138616156817423412863412177199151\
055856207069714084657310495058759139542900519171388443547871558507573\
948937524889911140590562675224573515451638678334944353358816689952838\
021105461897807233248789972151274044554176393928054238190520484054350\
689148029614875765339478833688339093323537661478061731620258929292671\
03260220166411748225093782409130224917917686956257637269268564

How it works:
Overall, the structure of the program is: dc<<<..., so bash calls dc with a script to run.
But the dc script part isn't written out fully; it's actually generated itself by a program (the dc script is customized for the specific argument n that was passed in $1 to bash).
The dc script starts with a prologue string that's taken verbatim, then a call to seq to generate the bulk of the dc code, and then a final command to print the result.
PROLOGUE
The prologue is: [sD1q]so [sD0q]sz z (spaces added for clarity -- they don't affect the code).

[sD1q]so
This defines a macro o which replaces the item at the top of the stack with 1.  It's intended to be called from another macro.

In more detail:
[    Start a string (to be used as a macro definition).
sD   Pops an item from the stack and stores it in register D.
     (I only do this because dc doesn't provide a way to just pop an item from the stack without doing something with it, and storing it an otherwise unused register is innocuous.)
1    Push `1` onto the stack.
q    Return from this macro and the macro which called it.
]    End the string.
so   Save the macro in register o.

[sD0q]sz
This defines a macro z which replaces the top of the stack with 0.  It works the same way as macro o above.
z

This pushes the current stack depth onto the stack.  But the stack is currently empty, so it just pushes 0 onto the stack.  This initializes the running total for the binomial coefficient sum that we're going to be computing.  (The reason for using z instead of 0 for pushing a 0 is that a number is coming next; so if I used a 0 to push the 0 here, I'd need to put an extra space after it to separate it from the number coming up.  So using z saves a byte.)
CALL TO seq
The seq command is of the form seq -f %0.f... 0 $1, where the ... is dc code.  This takes each number k from 0 to n (the bash argument $1), replaces %0.f (in the first argument to seq) with k, and writes each of those strings on a line:
0...
1...
2...
.
.
.
n...

where the ... at the end of each line is the dc code in the argument to seq.
So the loop that one would imagine for computing $$\sum_{k=0}^n \big( \binom{k}{n-k}+\binom{k+1}{n-k-1}\big)^2$$ is actually unrolled into a simple but long computation for the specific \$n\$ that we have.
There are actually two macro definitions embedded in the dc code. (You can often a save a byte in dc by waiting to define a macro until the first time you use it.)
I'm going to describe those macros first, because I think it's clearer that way.
The first of the two embedded macros, [d2>od1-d2<F*] computes the factorial of the number at the top of the stack.  The macro is saved in register F, so it calls itself recursively:
Assumption: The argument x is on the stack when the macro is called.
[    Start macro definition
d    Duplicate the item at the top of the stack, so x is there twice.
2>o  Pop that number. If it's < 2, call macro o to pop the extra copy of the argument, and return from F with 1 on the stack.  (This is the right answer for x! when x<2.)
If it's >= 2:
d    Pop the argument.
1-   Subtract 1.
d    Duplicate the top of the stack, so x-1 is there twice.
2<F  If it's > 2, call F recursively to compute (x-1)!.
*    Multiply the top of stack, which is (x-1)!, by the 2nd item on the stack, which is x, yielding x! as desired.
]    End macro definition

The above macro will be saved in register F.
The second of the two embedded macros computes the binomial coefficient $$\binom{n}{k} = \frac{n!}{k! (n-k)!},$$ where \$k\$ is the number on the top of the stack and \$n\$ is the second number on the stack.
The binomial coefficient macro is:
[dsk0>zdsndlk>z[d2>od1-d2<F*]dsFxlklFxlnlk-lFx*/], which is saved in register C.  (Note that the definition of macro F is actually embedded inside the definition of C.)
Here's how C works (when it's called, k is at the top of the stack, and n is second):
[    start of macro
d    Duplicate k at the top of the stack.
sk   Pop one k and save it in register k.
0>z  Pop the other k, and if it's < 0, call macro z to return 0 from C (which is the right value for the binomial coefficient when k<0).
If k >= 0:
d    Duplicate n (so there are now two n's at the top of the stack).
sn   Pop one n and save it in register n.
d    Duplicate n (so there are now two n's again at the top of the stack).
lk>z If n<k, call macro z to return 0 from C (which is the right value for the binomial coefficient when k>n).
[d2>od1-d2<F*]  This is the definition of macro F, as described earlier, embedded in C.
d    Duplicate the F macro string on the stack.
sF   Pop one copy of the macro F string, and save it in register F.
x    Pop the stack to get a copy of the macro string F and call it.  So now the n at the top of the stack has been replaced by n!
lk   Load k.
lFx  Compute k!.
lnlk- Compute n-k.
lFx   Compute (n-k)!
*     Multiply k! (n-k)!.
/     Compute n!/(k! (n-k)!).
]     End of macro C.

So now let's go back to see what the dc code does with each value k from 0 to n.  (Below I've written C(n,k) for \$\binom{n}{k}\$ since TeX doesn't seem to work inside code-sample formatting.)
%0.f seq replaces this with k, so k is pushed on the stack.
d    Duplicate the top of the stack, so k is now on the stack twice.
sK   Pop one of the k's off the stack and store it in register K.
$1   Push n on the stack.  ($1 has already been replaced by n due to bash's parameter expansion.)
lK   Push k back on the stack (load it from register K).
-    Pop n and k, and push n-k onto the stack.
[dsk0>zdsndlk>z[d2>od1-d2<F*]dsFxlklFxlnlk-lFx*/]   This is the embedded defintion of C, with the definition of F embedded in it.
d     Duplicate the string defining C, so it's there twice.
sC    Save the macro for C in register C.
x     Call the macro C.  This pops k and n-k, and replaces them with C(k,n-k).
1     Push 1.
lK    Push k.
+     Compute k+1.
d     Duplicate k+1 on the stack.
$1    Push n.
r     Swap n and the k+1 that comes next.  (So the stack now has k+1 at the top, then n, then k+1 again.)
-     Replace k+1 and n at the top of the stack with n-k-1.
lCx   Replace n-k-1 and k+1 with C(k+1,n-k-1).
+     Add the two binomial coefficients.
d*    Square the sum of the two binomial coefficients.
+     Add it onto the running total.

The above is done for each k, so after they're all done, the top of the stack contains the value we want.
EPILOGUE
The epilogue is fixed code that's hit last.  It just consists of the single dc command
p
which prints the result, with a newline after it.
It may be worth mentioning that the macro F is redefined every time C is called (because the definition of F is embedded in C), but that's OK -- it's defined the same way every time.

All I see is a whole bunch of random characters. Must've been hard to write.

@S.S.Anne If I have time, I’ll add an explanation today.

@S.S.Anne I've added an explanation.  It took me longer than I expected!

Wolfram Language (Mathematica), 46 bytes
a(n) = Sum_{k=0..n} (C(k, n-k) + C(k+1, n-k-1))^2
Sum[Tr@Binomial[{k,k+1},{#,#-1}-k]^2,{k,0,#}]&

Try it online!

Perl 5 -p, 50 48 bytes
@Grimmy saved 2 bytes
$_=grep!/000|111/&&y/1//==y/0//,glob"{0,1}"x2x$_

Try it online!

Python 3, 114 \$\cdots\$ 93 89 bytes
Saved 15 bytes thanks to Bubbler!!!
Saved 4 bytes thanks to Jitse!!!
lambda n:sum([*map(bin(i).count,('000','111','1'))]==[0,0,n]for i in range(4**n//8,4**n))

Try it online!
Brute force!

93 bytes.

@Bubbler Wow,! Very nice summing the test and streamlining the binary conversion - thanks! :-)

89 bytes

@Jitse Nice one - thanks! :=)

05AB1E, 13 8 bytes
Port of Jonathan Allan's Jelly answer
ÝÂcDÀ+nO

Try it online!
Old 13-byter:
xLÉœêʒü3€ËË}g

Try it online!

Charcoal, 35 bytes
ＮθＩＬΦＥＸ⁴θ⭆◧⍘ι²⊗θΣλ›⁼№ι0№ι1ΣＥ²№ι×³Ｉλ

Try it online! Link is to verbose version of code. Explanation:
ＮθＩＬΦＥＸ⁴θ

Loop from 0 to 2²ⁿ.
⭆◧⍘ι²⊗θΣλ

Generate all binary strings of length 2n.
›⁼№ι0№ι1

Check that the number of 0s and 1s is the same.
ΣＥ²№ι×³Ｉλ

Check that the string does not contain 3 repeated digits.

Bash + GNU utilities, 86 75 bytes
n=$1;e()(egrep "(21*){$n}"|grep -v 111);seq $[10**(2*n)]|e|tr 12 21|e|wc -l

Try it online!
The input is passed as argument, and the output is written to stdout.
It's very slow -- TIO times out at \$n=5\$.

How it works:
The function e is a filter; it only allows a line through if:
(a) it doesn't have 3 1s in a row,
and (b) it has a substring consisting of just 1s and 2s, with exactly n 2s.
The seq command counts from \$1\$ to \$10^{2n}\$.  These are all numbers of at most \$2n\$ digits (except for the \$10^{2n}\$ at the end).
We'll count numbers consisting of just 1s and 2s, not 1s and 0s, since otherwise we wouldn't get numbers starting with 0s.
The filter e is applied, and then it's applied to the same string with the 1s and 2s switched around.  So a number is allowed through if:
(a) it doesn't have 3 1s in a row;
(b) it doesn't have 3 2s in a row;
(c) it has a substring consisting of just 1s and 2s, with exactly n 2s;
and (d) it has a substring consisting of just 1s and 2s, with exactly n 1s.
Since the numbers being produced are decimal numbers with at most \$2n\$ digits, it follows that we're only letting through numbers with exactly \$n\$ 1s and exactly \$n\$ 2s.  (The \$10^{2n}\$ at the end is an exception with \$2n+1\$ digits, but it won't have passed through the filter anyway.)
Finally, wc -l counts the lines remaining.

The earlier 86-byte version used dc instead of seq, so it can handle arbitrarily large numbers, not limited by bash's maximum integer size.  But that's more or less moot because it's too slow anyway.
Here's the old version:
n=$1;e()(egrep "(21*){$n}"|grep -v 111);dc<<<"O$1d+^[d1-pd0<f]dsfx"|e|tr 12 21|e|wc -l
You can see more about that one (including a faster version that's 2 bytes longer, counting in base 3 instead of base 10) in the edit history.

APL (Dyalog Unicode), 18 bytes
+.×⍨1,2+/⊢(-!⊢)⍳,⊢

Try it online!
Bubbler's port of the Jelly solution(-14 bytes!).
APL (Dyalog Unicode), 35 32 bytes
{+/(×⍨((⍵-1+⊢)!1+⊢)+⊢!⍨⍵-⊢)⍳1+⍵}

Try it online! or Verify all test cases
Uses the formula from the Bash answer(which is very, very cool, go upvote it!).
Requires ⎕IO←0 for 0-indexing.
-3 bytes from ovs (Converted inner dfn to train, removing assignment to n).
Explanation
{+/{×⍨((n-⍵+1)!⍵+1)+(n-⍵)!⍵}⍳1+n←⍵}
                               n←⍵  store input in n
                            ⍳1+     range 0..n
   {                       }        apply the following to it's elements k:
                    (n-⍵)!⍵         k C (n-k)
                   +                plus
      ((n-⍵+1)!⍵+1)                 (k+1) C (n-(k+1))
    ×⍨                              squared
 +/                                 sum the resulting array

APL (Dyalog Extended), 42 bytes
{+/(≢=2×+/)¨{⍵/⍨{⍱/0 3∊⍵}¨3+/¨⍵}↓⍉⊤⍳2*2×⍵}

Try it online!
Brute force method, which is much slower and longer.

From what I could tell, the combinatorial formula is actually from Jonathan Allan's Jelly answer, no?

@RGS The bash formula is closer to what I've implemented.

The inner dfn can be written as a train like (×⍨((n-1+⊢)!1+⊢)+⊢!⍨n-⊢). This removes the need for the assignment: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/6u19TUOT3/Uu0JD41HvVl1D7UddizQVIRSIUARKgSRA/Ee9m4ESvVtr/6cB9T7q7XvU1fyod82j3i2H1hs/apsINDU4yBlIhnh4Bv9PUzAFAA

More directly porting the Jelly solution can lead to much fewer bytes (I got 18). Can you find it? Hint: 2+/

@Bubbler I got {+/1,×⍨2+/(⊢!⍨⍵-⊢)⍳1+⍵} which is 23. Nice hint.

Nice job. Then extract ⍵ in (⊢!⍨⍵-⊢) to the left, make entire function a train, and swap with equivalent forms to get this.

@Bubbler Using inner product there is really neat.

JavaScript (ES6),  80 76  70 bytes
A port of the Maple solution presented on OEIS.
f=(i,j=i,k=2)=>i*j<0?0:i|j?(k<4&&f(i-1,j,k<3?3:4))+(k&&f(i,j-1,k>1)):1

Try it online!

Japt -x, 15 bytes
Far too long and extremely inefficient! :\
çA á â Ë«ø56¤ò3

Try it

Ruby, 75 bytes
->n{([0,1]*n).permutation.uniq.count{|r|r.chunk{|n|n}.all?{|k,v|v.size<3}}}

Try it online!
Explanation
This is a naive solution that generates the permutations and counts the valid ones.
->n{([0,1]*n).permutation.uniq.count{|r|r.chunk{|n|n}.all?{|k,v|v.size<3}}}

# This gets all the unique permutations of `0`s and `1`s of size `2n`.
    ([0,1]*n).permutation.uniq

# This counts all instances where the inner block evaluates to true
                               count{                                     }

# This chunks together consecutive `0`s and `1`s.
                                     |r|r.chunk{|n|n}

# This checks that all consecutive `0`s and `1`s are shorter than 3
                                                      all?{|k,v|v.size<3}

C (gcc), 79 bytes
f(i,j,k){i=i*j<0?0:i|j?(k<4)*f(i-1,j,3+k/3)+!!k*f(i,j-1,k>1):1;}a(x){f(x,x,2);}

A port of Arnauld's solution, and, by extension, the Maple solution on the OEIS page.
I spent way too much time working on an alternate solution. Here's what I came up with that didn't work:

The number of numbers that don't meet the requirements of rule 1 is 2(x-1), or 4(x-1) in this challenge's input scheme.
The number of numbers that do meet the requirements of rule 2 is (n)!/(floor(n/2)!)^2, or (2n)!/(n!)^2.
These cannot be combined because some numbers meet both the requirements, some meet neither, and the rest meet only one.

-6 bytes thanks to ceilingcat!
Try it online!


text:
Generate this expanding series
Challenge
Your task is to generate a string using this sequence:
1,1,2,1,1,2,3,2,1,1,3,2,4,2,3,1,....

Which is more understandable in this format:
1
1 2 1
1 2 3 2 1
1 3 2 4 2 3 1
1 4 3 2 5 2 3 4 1

The pattern increases the number of Digits in the string by two for each increment in the Value of N
For each integer value up to the total N, aside from 1 the string is centred on the current value of N and bookended by the previous values of N in decreasing order on the left, and increasing order on the right - with the exception of the value 1, which bookends the entire string.
Input
Number of steps
Output
The series separated by comma

What is the expected output for $n=3$? [1,1,2,1,1,2,3,2,1]? [[1],[1,2,1],[1,2,3,2,1]]? [1,2,3,2,1]? Or any of those?

"Your task is to generate a series like this" implies $n=3$ should give [1, 1, 2, 1, 1, 2, 3, 2, 1]. For some reason, people are submitting solutions for the row of the "more understandable in this format".

I suggest removing the "separated by a comma" text, which appears to override site defaults - most languages will at least wrap a list in some kind of brackets and many will delimit with both space and comma, some may use semi-colons or just spaces. We prefer not to ask answerers to format their output unless it's a core part of the challenge, and as you can see none of the six answers (including mine) have actually followed this instruction.

I can't understand the way the sequence is generated.

@JonathanAllan it's unclear at present, so most of us have gone for the option which has the shortest code. I had the )F version prepared anyway so have added it to my answer.

@RGS it seems to be [1, n -1, n - 2, n - 3, ..., 2, n, 2, ..., n - 3, n - 2, n - 1, 1] if I've understood it correctly.

This description: A middle number is incremented by 1 and being surrounded by its previous number. in your challenge does not appear accurate with regards to the sequence provided. Additionally, it would be more accurate to say the number of digits in the string increments by 2 as opposed to Here is a pattern that numbers in each step is increasing by 2

Think if Jonathan's ,Nick's and T3RROR's comments were integrated into the challenge we'd be good to go.

@JonathanAllan I used said that because not for the formatting and just showing the list.

@T3RR0R then you mean I need to express it matmetically?

@Noodle9 yes their comments are appropriate please go with them!

@NickKennedy thanks for the mathmetical expression of the series.

@RGS please see NickKennedy comment.

@Arnuald output for n = 3 is [1,1,2,1,1,2,3,2,1]

@WasifHasan You need to edit the challenge incorporating those comments. Then I (and I'm sure others) will vote to reopen.

The pattern increases the number of Digits -> ...integers (e.g when we get to 10). Also still - why a string and why the strict formatting and not just allow any list construct to be output?

I still don't understand this: "bookended by the previous values of N in decreasing order on the left, and increasing order on the right"

Similar to A006968

05AB1E, 7 bytes
Port of the Jelly answer.
L¦ÁR1šû

Try it online!
Explanation
L       1 .. N
 ¦      Tail
  Á     Shift right
   R    Reverse
    1š  Prepend 1
      û Palindromize

05AB1E, 9 bytes
If the whole format is necessary, here's one with 9 bytes. (Question: Does 05AB1E have any sort of implicit range?)
LεL¦ÁR1šû

Try it online!

To myself 2 months ago. Yes there is, take a look at the Loops section in the 05AB1E wiki. But it doesn't seem to work.

Jelly, 10 10 ?8 bytes
Ḋṙ-U1;ŒB

Try it online!
I’m assuming you want the \$n\$th row of the pyramid. If you actually want the full sequence for the \$n\$th step, then it would be 10 bytes.
A monadic link taking an integer and returning a list of integers.
Explanation
Ḋ        | List 1..(n-1)
 ṙ-      | Rotate right 1
   U     | Reverse list
    1;   | Prepend 1
      ŒB | Bounce (mirror

Python 3.8 (pre-release), 86 81 58 53 bytes
lambda n:[[1],[1,*(l:=range(2,n))[::-1],n,*l,1]][n>1]

Try it online! Hats off to @Noodle9 for saving me a whooping 23 bytes and thanks to @squid for saving me 5 bytes!

58 bytes

@Noodle9 I was so sure the f-string formatting was going to be the way to go... xD

53 bytes

@squid nice one, doing the *l inside the list to return!

Far too much later, another -3

Erlang (escript), 182 bytes
Unfortunately this became the longest solution over here...
q(I)->lists:join(" ",[integer_to_list(X)||X<-lists:seq(2,I-1)]).
x(0)->"";x(I)->x(I-1)++"\n"++if I>1->"1 "++lists:reverse(q(I))++" "++integer_to_list(I)++" "++q(I)++" 1";1<2->"1"end.

Try it online!

JavaScript (ES6),  68  65 bytes
Returns the whole sequence after \$n\$ iterations.
f=n=>--n?[...f(n),1,...(g=k=>k>1?[k,...g(k-1),k]:[n+1])(n),1]:[1]

Try it online!

JavaScript (ES6),  53  46 bytes
Returns the \$n\$th row of the pyramid.
n=>(g=k=>k>1?[k%n||1,...g(k-1),k%n||1]:[n])(n)

Try it online!

C# (Visual C# Interactive Compiler), 145 bytes
n=>{var s= "";for(int i=0;i++<n;){for(int j=1;++j<=i;)s+=(j>2?i-j+2:1)+",";s+=i;for(int j=i;j-->1;)s+=","+(j>1?i-j+1:j);s+=i<n?",":"";}return s;}

Try it online!
Function generating whole series.

135 bytes

Jelly, 11 bytes
(9 if we only require the \$n^{\text{th}}\$ row of the "understandable format" - remove )F)
,2œṖRUFŒB)F

A monadic link accepting an integer, the number of steps, which yields a list of integers, the series up to and including that step.
Try it online!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Quotes around sequence of chars
Challenge
Your goal is to write a function that puts quotes around a sequence of capital letters in a string.
So some examples (everything on the left (before function) and right (after function) are STRINGS):
Hello the name's John Cena -> "H"ello the name's "J"ohn "C"ena
I got BIG OLD truck -> "I" got "BIG" "OLD" truck
[OLD, joe, SMOE] ->["OLD", joe, "SMOE"]
'BIG') -> '"BIG"')
fOOd -> f"OO"d
"78176&@*#dd09)*@(&#*@9a0YOYOYOYOYOYOOYOYOYOY28#@e -> "78176&@*#dd09)*@(&#*@9a0"YOYOYOYOYOYOOYOYOYOY"28#@e
Assumptions and Clarifications

The sequence of capital letters can have a length of one (e.g. a string containing one character: H -> "H")
You can assume there will be only a string inputted.

Winning Criteria
Code golf, fewest bytes wins.

Great first question, well specified!

@xnor thx for the compliment

Quite similar to Put in the quotes.

What is the domain - is it ASCII only?

I'm having difficulties seeing that first test case... :P. Probably because the time is now!

@Lyxal word wordd can't see sumthing that ain't dere

I'm unable to see the words "John Cena"... Must be something to do with his phrase "you can't see me, my time is now". :P

@Lyxal exactly, me either Its the franchise, Boy, I'm shining now

@Lyxal btw who's answer do I choose?

Well, we usually don't choose anyone as the winner, as we just leave competitions infinitely open in case new answers become the winning answer. But if you want to choose someone, it's the answer with the shortest byte count. From the looks of things, that'd be the Gema answer, which is 8 bytes (correct at the time of posting this comment).

@Lyxal sounds good

Does this answer your question? Put in the quotes

@S.S.Anne what question do u speak of, this is a challenge

@Quora Sorry, it's duplicate flag boilerplate.

@S.S.Anne ah didn't know that, first time coding mb

Perl 5, 15 bytes
s/[A-Z]+/"$&"/g

Try it online!

05AB1E, 13 bytes
0.ø.γ.u}'"ý¦¨

Try it online!
0.ø              # surround input string with 0s
   .γ  }         # group characters by:
     .u          #  is uppercase?
        '"ý      # join groups with quotes
           ¦¨    # remove the first and last characters (0s)

JavaScript (ES6),  32  30 bytes
Using a reference to the last match
Version suggested by @Grimmy
Saved 2 bytes thanks to @Shaggy
s=>s.replace(/[A-Z]+/g,'"$&"')

Try it online!
JavaScript (ES6), 35 bytes
With a callback function
s=>s.replace(/[A-Z]+/g,s=>`"${s}"`)

Try it online!

amazing nice job

32 with backrefs

Why not just $&?

Gema, 8 characters
<K>="$0"

Sample run:
bash-5.0$ gema '<K>="$0"' <<< 'Hello the name’s John Cena'
"H"ello the name’s "J"ohn "C"ena

Try it online!

Python 3, 47 bytes
lambda s:re.sub('([A-Z]+)',r'"\1"',s)
import re

Try it online!

Japt, 11 bytes
r"%A+"`"$&"

Try it

sed, 26 21 bytes
Saved 5 bytes thanks to Xcali!!!
s/[[:upper:]]\+/"&"/g

Try it online!

Using & cuts down on the byte count: Try it online!

@Xcali Nice one - thanks! :-)

Pyth, 20 bytes
Blatant port of RGS's Python answer. (I relized that I posted to the wrong challenge, whoops!)
:Q"([A-Z]+)""\"\\1\"

Try it online!

A shorter way to write the second string is s[N\\1N

Retina, 11 bytes
[A-Z]+
"$&"

Try it online!
I thought Retina has a shortcut for [A-Z] but apparently that only works in transliterations and not substitutions? Hmm...

R, 34 bytes
gsub("([A-Z]+)","'\\1'",scan(,''))

Try it online!
Simple use of Regular Expressions.
39 bytes
cat(gsub('([A-Z]+)','"\\1"',scan(,'')))

Try it online!
This method is the only way I can get the double quotes to work.

@JoKing Seems inconsequential to me. There was no specification on the type of quotes, but shockingly enough, the R code to switch it would be longer.

V (vim), 9 bytes
Í¨õ«©/"±"

Try it online!
This instructs Vim to replace all occurrences on all lines (Í)
...using the substitution \(\u\)\+/"\1". Each \x may be replaced by x with the high-bit set, thus \1 becomes ±, etc...

C (gcc), 100 \$\cdots\$ 74 72 bytes
Saved 21 23 bytes thanks to ceilingcat!!!
Saved a byte thanks to S.S. Anne!!!
t;u;f(int*s){for(t=1;*s;printf(s++),t=u)(u=*s<65|*s>90)^t&&putchar(34);}

Try it online!
Uses wchar_t strings for input.

@ceilingcat Wow! That's a great golf! Very readable in a golfy way: print quotes when we 're about to move in or out of caps. And of course that makes the putchar refactoring redundant - thanks! :-)

-1 with widechar

Try adding an L before the string to make it a widechar string.

@S.S.Anne Ah, that's a good one - thanks! :-)

@ceilingcat Huh, that's very interesting - thanks! :-)

QuadR, 10 bytes
Port of @Adám's answer.

[A-Z]+
"&"

Try it online!

yo didn't realize ur question so similar my bad bro, got notified

Keg, 31 bytes
0&?(:A$Z$•[⑻[|1⑼\",],|⑻[\",]0⑾,

Try it online!
But seriously, don't ask who Joe is.

wait, but, who's joe?

Joe mama! (I warned you not to ask! :P)

LLLLLLLLLLOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL

Ha! Got'em! Haha XD lol!

Ruby, 64 bytes
->s{s.chars.chunk{|c|c<c.downcase}.map{|u,c|u ??"+c*''+?":c}*''}

Try it online!
Longer than the other Ruby solution, but one that doesn't use regex. I also love an excuse to use chunk.
This groups successive characters of the string depending on whether or not they're uppercase, and then surround the ones that are uppercase with ". I had to do the downcase check rather than checking with upcase, because otherwise non-character strings (spaces, punctuation, etc.) would also be considered uppercase letters.
Golfy Tricks:

*'' instead of .join
< instead of !=

AWK, 22 bytes
gsub("[A-Z]+","\"&\"")

Try it online!

Charcoal, 20 bytes
Ｆ⁺Ｓ «ω✂"⁼№⪪α¹ω№αι≔ιω

Try it online! Link is to verbose version of code. Port of my answer to the question linked by @manatwork in the comments.

Jelly, 11 bytes
e€ØAŻIœṗj”"

Try it online!
A monadic link taking a string and returning a string.

perl -pE, 16 bytes
s/\p{Lu}+/"$&"/g

Unicode compliant, unlike the s/[A-Z]+/"$&"/g solution presented earlier.

Needs a -CS to actually be unicode compliant. Without the flag, outputs garbage.

Ruby, 30 bytes
->s{s.gsub(/([A-Z]+)/,'"\1"')}

Try it online!
A simple regex substitution.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Numbers by Position
Challenge
Print the numbers:
1
22
333
4444
55555
666666
7777777
88888888
999999999

In that order.
I/O
Takes no input. The numbers can have any delimiters desired (or none). That includes lists, cell arrays, .jpeg, etc.... Example outputs:
122333444455555666666777777788888888999999999

[1,22,333,4444,55555,666666,7777777,88888888,999999999]

etc....

Code Example
This is an un-golfed example that may perhaps act as algorithm guide (or maybe not):
Turing Machine Code, 535 bytes
0 * 1 r L
L * _ r 2
2 * 2 r a
a * 2 r M
M * _ r 3
3 * 3 r b
b * 3 r c
c * 3 r N
N * _ r 4
4 * 4 r d
d * 4 r e
e * 4 r f
f * 4 r O
O * _ r 5
5 * 5 r g
g * 5 r h
h * 5 r i
i * 5 r j
j * 5 r P
P * _ r 6
6 * 6 r k
k * 6 r l
l * 6 r m
m * 6 r n
n * 6 r o
o * 6 r Q
Q * _ r 7
7 * 7 r p
p * 7 r q
q * 7 r r
r * 7 r s
s * 7 r t
t * 7 r u
u * 7 r R
R * _ r 8
8 * 8 r v
v * 8 r w
w * 8 r x
x * 8 r y
y * 8 r z
z * 8 r A
A * 8 r B
B * 8 r S
S * _ r 9
9 * 9 r C
C * 9 r D
D * 9 r E
E * 9 r F
F * 9 r G
G * 9 r H
H * 9 r I
I * 9 r J
J * 9 r halt

Try it online!
This prints out the numbers with a space delimiter:
1 22 333 4444 55555 666666 7777777 88888888 999999999

Challenge Type
code-golf, so shortest answer in bytes (by language) wins.
Based on a submission in the sandbox.

Can the delimeters be numbers?

@AdHocGarfHunter, No. Good catch. Edit: Actually, I think '0' should be acceptable.

Could you verify that they "strange delimiters" version of this answer, is valid?  It definitely seems cheaty.

Honestly I think it's a clever 'outside-of-the-box' solution. I'd upvote, but I'm out of votes until tomorrow.

Is [1,2,2,3,3,3...] a valid output? What about the same but as a list of characters? Does it matter if the language displays lists of characters as a string or as a list? What about [[1],[2,2],[3,3,3],...] or the character version of it?

@xnor, All looks fine to me. I thought I'd sort of implied that lists were ok with one of my example outputs. But to make it clear, yes, Output of lists of characters are entirely acceptable.

@ouflak Thanks for the algorithm guide! How did you know I always write my prototypes with Turing Machines :p

Is a leading empty list in the output allowed?

@Razetime, Yes.

Deadfish~, 194 bytes
{{i}ddddd}dc{d}{d}iiic{i}{i}ddcc{d}{d}iic{i}{i}dccc{d}{d}ic{i}{i}cccc{d}{d}c{i}{i}iccccc{d}{d}dc{i}{i}iicccccc{d}{d}ddc{i}{i}iiiccccccc{d}{d}dddc{i}{i}iiiicccccccc{d}{d}ddddc{i}{i}iiiiiccccccccc

Try it online!

Understandable.

@lyxal ???? (filler)

@wasif the reason it was accepted

159 bytes, and 128 separating by zeros.

Actually, 61 since delimiters aren't even required.

@Steffan Go post that yourself, this was probably metagolfed

Google Sheets, 35 bytes
=ArrayFormula(Rept(Row(1:9),Row(1:9

Sheets will automatically add three trailing parentheses when you exit the cell. Output is one line per row.

I've run out of votes.

@ouflak Darn...

Bash + Core utilities, 27, 25 bytes
seq -f8d%f*7-v1+2/n 45|dc

Try it online!

Changed seq formatting from %0.f to %f for a 2-byte savings.
Modified to print on one line, with no delimiters, instead of having a newline after each number, just because I like that better.  Same number of bytes.

This uses the formula $$\left\lfloor\frac{\big\lfloor\sqrt{8n-7}\big\rfloor+1}2\right\rfloor$$
for the \$n^{th}\$ digit, where \$n\$ goes from 1 to 45.

05AB1E, 3 bytes
9L×

Try it online!
9L    Build a list from 1 to 9 {1, 2, 3, 4, 5, 6, 7, 8, 9}
×     copy each number that many times

Python 2, 28 bytes
i=1;exec"print`i`*i;i+=1;"*9

Try it online!

APL (dzaima/APL), 6 bytes
Full program, requiring ⎕IO←0.
⍋⍛⌿⍨⎕D

Try it online!
⎕D on the string "0123456789",
⍛⌿⍨ replicate the characters by
⍋ their grade (0, 1, 2, …, 9)

Isn't \⍨⍳9 at 4 bytes sufficient? I've added it as my own answer, though it doesn't seem to be gaining any traction. Would love feedback!

@AviF.S. It wasn't clear that this was a permitted format, but now that OP has clarified, you have my upvote.

Kotlin, 30 bytes
{(1..9).map{"$it".repeat(it)}}

Try it online!

R, 18 bytes
a=1:9;(10^a-1)/9*a

Try it online!
Use the formula \$\frac{10^n-1}{9}\times n\$ for the \$n\$th number.

Hmm, I may be out of date but isn't the usual ruling that it needs cat() or equivalent to print the output?

@user2390246 yeah, the consensus was changed...a while ago? Late 2017 by my quick search of meta. This is probably what you're aware of but taking that approach with this meta post on compiler flags basically means all R answers are just "R invoked with source(...,echo=TRUE)"

@Giuseppe thanks for the clarification, I've not been around for a while! Seems like the trend for cat()-type answers ended up being quite a short phase then.

Beat you with a string-only approach! :-)

@Giuseppe Ooh, nice!

APL (Dyalog Unicode), 4 bytes
\⍨⍳9

Try it online!
How it works
⍳9        ⍝ Integers 1..9
   ⍨      ⍝ Duplicate argument on each side
     \    ⍝ Replicate each element *n* times

Examples
Index Generator:    ⍳5          =  1 2 3 4 5
Expand:             2 3 \ 1 4   =  1 1 4 4 4
Commute:            +⍨4         =  4 + 4 = 8

Feedback: I'd use /⍨⍳9 as it is simpler. / is really "replicate" while \ is the more complex "expand".

Perl 5, 18 bytes
map{say$_ x$_}1..9

Try it online!

brainfuck, 56 bytes
+++++++[>+++++++<-]+++++++++[<+[>>.<<-<+>]<[>+<-]>>>+<-]

Try it online!
+++++++[>+++++++<-]     49 (ASCII "1")
+++++++++[              do 9 times
  <+                    add 1 to output counter
  [                     do that many times
    >>.<<               print character
    -<+>                move value of output counter to temp
  ]
  <[>+<-]               move value of temp back to output counter
  >>>+                  increment character
  <-                    decrement loop counter
]

50 bytes

Thank you. Your code is so different from mine, you should post it as a separate answer.

Retina, 12 bytes

9*

$.`*$.`

Try it online! Outputs a leading _ to each number, which appears to be acceptable (would cost 2 bytes to fix if not). Explanation:

9*

Insert 9 _s.

$.`*$.`

Around each _, insert its position repeated appropriately.

The leading _ is absolutely acceptable.

Haskell, 30 29 bytes
(<$)<*>g<$>g '9'
g c=['1'..c]

Try it online!

APL (Dyalog Unicode), 7 bytesSBCS
⎕D/⍨⍳10

Try it online!
Uses ⎕IO←0.
How it works
⎕D/⍨⍳10
⎕D       ⍝ The string '0123456789'
  /⍨     ⍝ Replicate each of them the following times...
    ⍳10  ⍝ 0..9

Brain-Flak, 90 82 bytes
([(()()())({}){}]){((({})()<([{}]((((()()()){}){}){}){})>)<{({}()<(({}))>)}{}>)}{}

Try it online!
Explanation:

Compare this with the output of JoKing's autogolfer
Brain-Flak, 142 bytes
(((((((((((((((((((((((((((((((((((((((((((((((((()()()){}){}){}){}())()))())))()))))())))))()))))))())))))))()))))))))()))))))))){({}<>)<>}<>

Try it online!

Strange delimiters, 78 bytes
([(()()())({}){}]){((({})()<([{}]((((()()()){}){}){}){})>)<{({}()<(({}))>)}>)}

Try it online!
If we decide to play around with our delimiters a bit, we can shave off 4 bytes.  This version outputs the correct stuff but with two leading null bytes and null bytes between the chunks:
This is a tiny bit cheaty but it meets the specs of the challenge.

And for posterity here is the old super cheaty version that has been made obsolete by my golfs.

Husk, 5 bytes
d´Ṙḣ9

Try it online!
Output: 122333444455555666666777777788888888999999999.

Welcome to Code Golf!

Thank you a lot! :)

J, 18 bytes
echo u:(#48+])i.10

Try it online!
K (oK), 11 10  bytes
-1 byte thanks to ngn!
,/${x}#!10

Try it online!

,/${x}#!10 - using filter ({ }#) for replication

@ngn Thanks, of course!

I think echo#~1+i.10 is ok too since any delimiter is allowed.

Jelly, 5 bytes
9ẋ`€Ḍ

Try it online!
A niladic link returning a list of integers. If a program printing the numbers is preferred, subsitute Y for Ḍ.
Explanation
9     | Literal 9
 ẋ`€  | Repeat each that many times
    Ḍ | Convert from decimal digits to integer

You can drop the trailing Ḍ, based on the comments below the challenge description between xnor and OP.

Perl 6, 13 bytes
{1..9 Zx^9+1}

Try it online!
Anonymous code block that returns a list of strings by zip string multiplying the range 1 to 9 with itself.

Java 11 (JDK), 60 59 bytes
Not sure if thats the shortest approach but couldn`t make it shorter even without System.out.print.
Output is without delimiters.
-1 byte thanks to Kevin Cruijssen
v->{for(int i=0;i++<9;System.out.print((i+"").repeat(i)));}

Try it online!

You can save 1 byte changing the ()-> to v->, by taking an empty unused (Void null) argument, which is allowed when it's completely unused.

@Kevin Cruijssen Thanks for the suggestion, didn't know about that. I now use an Object as parameter and pass null, is this the intended way or can you actually do it with Void?

Object null is fine as well. As long as the argument isn't used in any way, not even for static calls, it's ok. That's why I personally use Void, since it has no available static calls anyway. :)

Well thats awkward, could've sworn that it just didn't compile with type Void, changed it again and now it works, thanks.

C (gcc), 46 bytes
s;main(n){n>9||main(puts(memset(&s,n+48,n)));}

Try it online!

can't be called twice

Thanks for catching that :)

Haskell, 21 bytes
[c<$[1..c]|c<-[1..9]]

Try it online!
A list of lists of numbers.
23 bytes
replicate<*>id=<<[1..9]

Try it online!
A flat list of numbers.

I think that the delimiter has to be in between differing digits (e.g. 1 and 2 as opposed to 8 and another 8).

@AdHocGarfHunter Looking again at the challenge, I'm not clear on this so I asked. I think it would be unfortunate if the flat list in the second version were invalid too.

R, 15 bytes
strrep(1:9,1:9)

Try it online!

Just rep(1:9,1:9) is shorter (and gives exactly the output of the first example)?

x86-16 machine code, IBM PC DOS, 18 16 bytes
Binary:
00000000: b839 0ab2 09b1 2dcd 1048 2aca 4a75 f8c3  .9....-..H*.Ju..

Listing:
B8 0A39     MOV  AX, 0A39H              ; AH = 0AH, AL = '9'
B2 0A       MOV  DL, 10                 ; DL as counter value
B1 2D       MOV  CL, 1+2+3+4+5+6+7+8+9  ; start digit repeat 45 times
        NLOOP:
CD 10       INT  10H                    ; call BIOS - write digit * CX times
48          DEC  AX                     ; decrement ASCII digit
4A          DEC  DX                     ; decrement counter value
2A CA       SUB  CL, DL                 ; reduce digit repeat value by counter
75 F8       JNZ  NLOOP                  ; loop until 0
C3          RET                         ; return to DOS

Try it online!
Explanation:
This uses the PC BIOS API's INT 10H / 0AH function to write the ASCII char in AL to the screen CX number of times.  However, this function does not update the cursor position to the end of the output -- it just stays where it started.  In other words, the next call simply overstrikes existing characters writing over them.  Making a BIOS call to advance the cursor is expensive byte-wise.
Since going forward isn't going to work, we go backwards starting from '9'.  It writes '9' 45 times, then '8' 36 times, '7' 28 times, etc -- each time starting from the first column overwriting like so:
999999999999999999999999999999999999999999999
888888888888888888888888888888888888999999999
777777777777777777777777777788888888999999999
666666666666666666666777777788888888999999999
555555555555555666666777777788888888999999999
444444444455555666666777777788888888999999999
333333444455555666666777777788888888999999999
222333444455555666666777777788888888999999999
122333444455555666666777777788888888999999999

Output:

Fig, \$6\log_{256}(96)\approx\$ 4.939 bytes
Mcd'*_

Try it online!
Lyxal tried to outgolf me in my own language again.
Mcd'*_ # Full program
 cd    # Digits
M  '   # Map each digit string
    *  # Repeat the digit
     _ # By the number form of it

Julia, 22 bytes
1:9 .|>i->show("$i"^i)

Attempt This Online!
prints
"1""22""333""4444""55555""666666""7777777""88888888""999999999"

Relying on the repl for printing output we can get to 17 bytes
~i="$i"^i;.~(1:9)

PowerShell, 15 bytes
1..9|%{"$_"*$_}

Try it online!

Icon, 27 bytes
write(1(i:=1to 9,1to i))&\z

Try it online!

JavaScript (ES8), 33 bytes
f=n=>n>9?'':''.padEnd(n,n)+f(-~n)

Try it online!
Commented
f = n =>            // n = counter, initially undefined
  n > 9 ?           // if n is greater than 9:
    ''              //   stop recursion
  :                 // else:
    ''.padEnd(n, n) //   pad an empty string with n digits n
                    //   this leaves the empty string unchanged for n undefined
    + f(-~n)        //   add the result of a recursive call with n + 1

Building in reverse order (38 bytes)
A somewhat funny alternate method is to build the string from \$n=9\$ to \$n=1\$ and pad the recursive call instead of an empty string.
By doing it this way, the required padding length is:
$$L_n=\left\lfloor\frac{n^2}{2}+1\right\rfloor$$
f=(n=9)=>n?f(n-1).padEnd(n*n/2+1,n):''

Try it online!

T-SQL, 69 bytes
SELECT top 9replicate(1+number,1+number)FROM spt_values WHERE'p'=type

Try it online

Nice code. Sometimes I wonder how well T-SQL would do in these challenges if we had a built-in number table or some equivalent to PostgreSQL's generate-series() function.

@BradC normally SQL will not win in these golfing questions even with improved features. When we use a command like replicate(a,b), some of the other languages can solve problem with fewer characters than the 14 characters(minimum) it takes to call that function. The best we can do it solve the problems using a language which usually isn't optimal, and hope some people are impressed enough to up-vote those solutions.

jq (-nr), 20 19 characters
range(9)+1|"\(.)"*.

Thanks to:

2x-1 for pointing out that range() does not produce array, so operators will see separate numbers.

Sample run:
bash-5.0$ jq -nr 'range(9)+1|"\(.)"*.'
1
22
333
4444
55555
666666
7777777
88888888
999999999

Try it online!

range(9)+1 is one byte shorter.

Wow! Thank you, @2x-1. I was never aware that parsing rules lead to that behavior.

Charcoal, 5 bytes
⭆χ⭆ιι

Try it online! Link is to verbose version of code. Outputs without separators. The first StringMap could be changed into a for statement for the same byte count. Explanation:
 χ       Predefined variable 10
⭆        Map over implicit range and join
   ι     Current index
  ⭆      Map over implicit range and join
    ι    Outer index
         Implicitly print

C (gcc), 54 53 bytes
i;j;f(){for(i=0;9/++i;)for(j=0;j++<i;)putchar(48+i);}

Try it online!
No delimiters between the numbers.

Would be 64 bytes with the delimiter https://tio.run/##S9ZNT07@/z/TOss6TUOzOi2/SCPT1sDaUl9bO9O6oLQkOSOxSMPYSFMTJJMFlMnS1rbJtNaESZlYaGdqWtf@z03MzAPq5wIaYs1V@x8A

W 5 4 3 bytes
@π┐

Uncompressed:
$*9N

Repeat 1..9 N times.
Explanation
     M % Map in the range
9      % From 1 to 9
  a$   % Stringify the current counter
 a  *  % Repeat that string by the current counter

Just curious, why do you have the meta link to the command line flags answer? Is that related to your implementation?

@ouflak No,that's was part of the copy-pasted template.

@ouflak Why is this accepted? The 05AB1E solution is posted before this answer. You should accept that instead.

Both were 3 bytes. I just flipped a coin. I can swap them....

@ouflak The general consensus is that you shouldn‘t accept an answer anyway. (Appreciate I‘m a few months late, and that you can do as you please, just spreading the consensus view)

Japt -P, 5 4 bytes
AÇçZ

Test it

Erlang (escript), 49 bytes
f()->[X*(math:pow(10,X)-1)/9||X<-lists:seq(1,9)].

Try it online!

C (gcc), 50 bytes
n;f(i){for(i=0;i++<9;)for(n=i;n--;)putchar(48+i);}

Try it online!

Japt, 4 bytes
AÇîZ

Try it
NaN

This is my dumbest code golf submission ever, but here it goes
SQLite, 53 bytes
SELECT'122333444455555666666777777788888888999999999'

Try it online!

Stax, 5 bytes
╜├ìíy

Try it online or try it online unpacked (6 bytes).
Explanation (of the unpacked version):
Vd      # Push constant "0123456789"
  A     # Push 10
   r    # Pop and push a list in the range [0, 10)
    :B  # Repeat the characters in the string the integer amount of times:
        #  "122333444455555666666777777788888888999999999"
        # (after which the top of the stack is output implicitly as result)

[VBA] 58 bytes
i=1:While i<0:For x=1 to i:Debug.Print i:Next x:i=i+1:wend

Can be ran in Immediate

you appear to have a typo in your code (while i<0->while i<10)

You can get your code down quite a bit by using nested for loops and by using ? in place of debug.print - For i=1To 9:For j=1To i:?i:Next j,i for 35 bytes

Oh - or better yet, if we use an approach similar to that of Mitchell Spector's we can get it down to 32 bytes as For i=1to 45:?(3.1*i^.48)\2:Next (or 33 bytes as For i=1to 45:?(3.1*i ^.48)\2:Next for 64-bit installs)

C (gcc), 47 bytes
k;main(i){for(;9>printf("%d",i*++k);i=i*10+1);}

Try it online!
C (gcc), 49 bytes
main(i){for(;9>printf("%lX",(i*1L<<4*i++)/15););}

Try it online!

46 bytes

COW, 75 bytes
MoOMoOMoOMoOMoOMoOMoOMoOMoOMOOmoOMoOMMMmoOMMMMOOmOoOOMmoOMOomoomOomOoMOomoo

Try it online!
Uncowed
moo ]    mOo <    MOo -    oom o
MOO [    moO >    MoO +    MMM =

+++++++++[>+=>=[<o>-]<<-]

Brainetry, 451 bytes
This is the golfed version, ungolfed version below.
a b c d
a b c d e f g h
a b c d e f g h
a b c
a b c d
a b
a b c d e
a b
a b c d
a b c d
a b c d
a b c d
a b c d
a b c
a b c d e f g h i
a b
a b c d
a b c d e f g h i
a b c
a b c
a b c d e
a b c d e
a b c
a b c d e
a b c d e f g h
a b
a b
a b c d
a b c d e f g h
a b c
a b c d e f g
a b
a b c d e
a b
a b c d
a b c
a b c d e f g h i
a b
a b c d e f g h
a b c
a b c d
a b
a b c d e
a b c d e f g h i
a b c
a b c
a b c d
a b c
a b c d e
a b c d e f g h i

To try this online, follow this link and paste the code in the btry/replit.btry file, then hit the green "Run" button.
Golfed version of the program below:
Let me explain what
is going on with this brainetry program: this
program will print the digits one to nine
and each of
those is going to
be repeated
as many times as its
own value.
Makes sense, doesn't it?
To achieve such result
we have to play
around with some nice
values in our tape.
That, and we
also have to play smart with our program pointer.
Of course
I would be delighted
to actually explain the algorithm used by this program.
The only problem
is I really
have no idea whatsoever about
what is actually going on.
Let me explain:
brainetry's instructions are a superset
of brainfuck, which means any brainfuck program can
be translated
to brainetry
and it will work.
So this is what I did, I found
a brainfuck program
that completed this task I described and
I just
translated it from brainfuck to
brainetry. Probably
there are simpler approaches
if we take
into consideration the extended operations that brainetry provides ...
However, brainetry
is still in its early stages of development
and I am
still trying to figure
out exactly
what operations to add to
brainetry. Once that set of operations becomes more well-defined
it will be
easier to harness
brainetry's power to write
computer programs. And
once that is finally done,
I will not have to steal random brainfuck programs.

This brainetry answer built on top of this answer

Scala, 35 26 bytes
-9 bytes thanks to user!
()=>1 to 9 map(i=>s"$i"*i)

Try it online!

This challenges allows you to return a list, so you can do this. Also, you don't need a for loop

Vyxal j, 3 bytes
9ƛẋ

Try it Online!
-1 thanks to lyxal

3 bytes

@lyxal I frogot it worked like that :p

Add++ -i, 14 13 bytes
L,9Rdz£XbUBvn

Try it online!
This is making me cry. A fun feature of like 99% of stack commands is that it applies to the whole stack rather than the top of the stack. Very very helpful.
-1 thanks to caird which kinda makes up for the suffering of this
Explained
L,9Rdz£XbUBvn
L,              # Start a lambda which is called implicitly by the -i flag
  9R            # Push the range [1...9]
    dz          # and zip it with itself, giving [[1, 1], [2, 2] ... [9, 9]]
      £X        # repeat x[0] by x[1] times for each x in that
        bU      # dump the contents of that onto the stack. This is a very important part because as I said, 99% of lambda stack commands map over to the whole stack, even when using quicks and stuff.
          Bv    # join each item (on the stack...) into a single integer
            n   # and join (the stack...) on newlines

-1 byte by replacing €¦ with £: Try it online!

Malbolge, 175 bytes
(C%;_#"~[}43WVxwuRt+*NMLmlljGig}CBAc?=vNtLr[v64m321/RzP+Ncha&&Gc#EDBX|{zx=vv:bs6p^]nllk/iVgfdvD'`N#?\\6YY3WUwvvQtPOqLo,JIHGihfCddcx>=<;:9[Y6XVl210/.-O+MLJ`&HG\[!~}|{z>=wv998rp

Try it online!

Julia, 24/21 bytes
w/o
(a=1:9).*(10 .^a.-1).÷9

and w/ macro:
a=1:9;@.a*(10^a-1)÷9

array of numbers, nothing new

shouldn't the answer also include a print statement?

maybe :-) when i got the the numbers as in the decription, i took it solved...

actually evaluating it in the REPL or running w/ julia -E you get what you want.
(i focused to get numbers not strings as You)

Using the repl is considered as a separate language https://codegolf.meta.stackexchange.com/a/7844/98541 and the same applies when using a flag https://codegolf.meta.stackexchange.com/a/14339/98541

Regenerate -a, 15 bytes
([1-9])$1{$1-1}

Outputs 1 through 999999999 on separate lines. Attempt This Online!
Explanation
The -a flag outputs all possible matches on separate lines.
([1-9])$1{$1-1}
 [1-9]           Pick a digit 1 thru 9
(     )          Store it in group 1
       $1        Match group 1 again
         {    }  this many times:
          $1       Group 1 contents
            -1     minus 1

Alternate -a solution, also 15 bytes:
([1-9])(){1,$1}

Outputs digits on separate lines. Attempt This Online!
([1-9])(){1,$1}
 [1-9]           Pick a digit 1 thru 9
(     )          Store it in group 1
       ()        Match empty string
         {    }  this many times:
          1,       Minimum of once
            $1     Maximum of (group 1 contents) times

Deadfish~, 61 54 bytes
ioiooioooiooooioooooiooooooioooooooiooooooooiooooooooo

Try it online!
-7 bytes thanks to Bubbler.
Separating by zeros:
Deadfish~, 128 bytes
{iiiii}dcdciiccddciiicccdddciiiiccccddddciiiiicccccdddddciiiiiiccccccddddddc{i}dddccccccc{d}iiic{i}ddcccccccc{d}iic{i}dccccccccc

Try it online!
By spaces:
Deadfish~, 159 bytes
{iiiii}dc{dd}iiic{ii}ddcc{dd}iic{ii}dccc{dd}ic{ii}cccc{dd}c{ii}iccccc{dd}dc{ii}iicccccc{dd}ddc{ii}iiiccccccc{dd}dddc{ii}iiiicccccccc{dd}ddddc{ii}iiiiiccccccccc

Try it online!

60 using shorter sequence to get to 49, and incidentally it also works in plain Deadfish. Also there's 54 using o.

Nibbles, 4 bytes (8 nibbles)
,9^$`p

,9^$`p
        # implicitly map over
,9      # integers from 1 to 9
  ^     # replicating
   `p   # the character of each
        # by itself times

Knight (v2.0-alpha), 21 bytes
;=i@W>10=i+1iO*+""i i

Try it online!

Labyrinth, 21 bytes
" }*!@
9 : {
:(1""
""

Try it online!
Intro
9    Push 9

Loop 1
:(""    Duplicate and decrement; exit when top is 0

[9 8 7 6 5 4 3 2 1 0]
Loop 2
1:}     Use the 0 as the basis for repunit;
        append 1, copy to aux.stack  [... i "1"*i | "1"*i]
*!      Multiply i and "1"*i and print; exit when the stack is empty
{       Pull the repunit back  [... i+1 "1"*i]

@       Halt

Labyrinth, 21 bytes
1:#
: (*
;  !
%9_:@
"

Try it online!
Loop: [... "1"*i] -> [... "1"*i "1"*(i+1)]
1     Append 1 (multiply by 10 and add 1)
:     Dup
#(    Stack size - 1 (== i+1)
*!    Multiply and print
:_9%  Test if the current repunit % 9 is 0 and exit loop if so
;:    Discard the test value and dup to increase the stack size by 1

9_:@  Halt

Keg, 45 11 9 8 bytes
9Ï^⑷:⅍*⑸

Try it online!

Pure Bash, 41 37 bytes
for k in {1..9};{ echo $[10**k/9*k];}

Try it online!

Io, 38 bytes
Range 1 to(9)map(i,i*(10**i-1)/9)print

Try it online!
Io, 47 bytes
Range 1 to(9)map(i,i asString repeated(i))print

Try it online!

Python 3.8, 34 bytes
i=0
while i<9:print(str(i:=i+1)*i)

Try it online!

Wolfram Language (Mathematica), 17 bytes
Table[,{,9},{a,}]

Try it online!
thanks @att

18 bytes (list of lists of digits, which based on comments should be fine)

17 bytes

Bubblegum, 23 bytes
00000000: 3334 3232 3636 3601 0253 1030 0303 7308  3422666..S.0..s.
00000010: b080 024b 1800 00                        ...K...

Try it online!

PHP, 37 36 35 bytes
for(;10>$j=++$i;)for(;$j--;)echo$i;

Try it online!
-1 byte thanks to @Night2

Do you need the input?

Nope, removed thanks. I'm so used to using the -F option, I did it without thinking.

35 bytes

Interesting lesson in precedence rules.

Python 2, 32 bytes
print[i*`i`for i in range(1,10)]

Try it online!

Batch, 74 bytes
@set s=
@for /l %%i in (1,1,9)do @call set s=%%s%%0&call echo %%s:0=%%i%%

Outputs on separate lines. Extends the string length by 1 and replaces the character with the current digit for each output.
The call commands are required so that the variable s is processed inside the loop instead of before parsing the loop.

Ruby, 30 25 bytes
1.upto(9){|i|p 10**i/9*i}

Try it online!
10**i/9 gives a number with i digits, all 1s. Multiply by i for the required output.

21 bytes: 1.upto(9){|i|p [i]*i}. Going by the comments on the OP I think the output this gives is acceptable.

naz, 36 bytes
1a1o1a2o1a3o1a4o1a5o1a6o1a7o1a8o1a9o

Outputs all the numbers with no extra delimiter, using the same functionality described in this answer.

Zsh, 30 bytes
repeat 9 echo ${(pl[++i][$i])}

Try it online!
The (l[width][fill]) flag does the heavy lifting.

Red, 30 bytes
repeat a 9[repeat b a[prin a]]

Try it online!
Well, the most obvious way to do it is the shortest in Red.

Factor, 42 39 bytes
9 [1,b] [ dup 1array swap cycle ] map .

Try it online!
Displays a list ot lists

IBM/Lotus Notes Formula Language, 56 bytes
@For(x:=1;x<10;x:=x+1;@Set("o";o:@Repeat(@Text(x);x)));o

Formula in a multi value form field, once again showing that the only real use for @For in Notes is Code Golf!

SNOBOL4 (CSNOBOL4), 47 bytes
O OUTPUT =DUPL(X,X)
 X =LT(X,9) X + 1 :S(O)
END

Try it online!
Prints with a leading newline.

Gol><>, 8 bytes
aFLRL|D;

Try it online!
aF   |   For Loop, from 0 to 10 excluding 10
  L      Push the current loop iteration to the stack
   RL    Pop the current iteration and repeat pushing the loopiterator value so many times
      D; Print the entire stack content as numeric values with the debug operation and halt

MathGolf, 6 5 bytes
9{îÄí

-1 byte thanks to @maxb.
Try it online.
Explanation:
9{     # Loop 9 times:
  î    #  Push the 1-based loop index
   Ä   #  Do an inner loop that many times, using a single command:
    í  #   Push the total number iterations of the outer loop
       # (after the loops, the entire stack is joined together and output implicitly)

Without a separator, you could do 9{îÄí, where í pushes the loop limit within a for loop.

@maxb Ah, nice golf. Out of curiosity, why doesn't it work when the Ä is {?

@maxb It does seem to work if I add two trailing }: try 9{î{í}} online.

There are some issues with implicit block closure with nested loops. you can omit the last } at the end of the script if you have a single loop, but not if you have two or more nested loop blocks which are opened by {.

Whitespace, 109 bytes
[S S S T    S S T   N
_Push_9][N
S S N
_Create_Label_LOOP][S N
S _Duplicate_top][N
S S S N
_Create_Label_INNER_LOOP][S S S T   N
_Push_1][T  S S T   _Subtract][S N
S _Duplicate_top][N
T   S T N
_If_0_Jump_to_Label_DONE_INNER_LOOP][S T    S S T   N
_Copy_0-based_1st][S N
T   _Swap_top_two][N
S N
S N
_Jump_to_Label_INNER_LOOP][N
S S T   N
_Create_Label_DONE_INNER_LOOP][S N
N
_Discard_top][S N
S _Duplicate_top][S S S T   N
_Push_1][T  S S T   _Subtract][S N
S _Duplicate_top][N
T   S S S N
_If_0_Jump_to_Label_DONE_LOOP][N
S N
N
_Jump_to_Label_LOOP][N
S S S S N
_Create_Label_DONE_LOOP][S N
N
_Discard_top][N
S S S T N
_Create_Label_PRINT_LOOP][T N
S T _Print_top_as_integer][N
S N
S T N
_Jump_to_Label_PRINT_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Try it online (with raw spaces, tabs and new-lines only).
Explanation in pseudo-code:
Push n=9
Start LOOP:
  Duplicate top (Integer i = n)
  Start INNER_LOOP
    i = i - 1
    if(i == 0):
      Jump to DONE_INNER_LOOP
    Copy n (0-based index 1)
    Swap
    Go to next iteration of INNER_LOOP
  DONE_INNER_LOOP:
    Discard i
    n = n - 1
    if(n == 0):
      Jump to DONE_LOOP
    Go to next iteration of LOOP
DONE_LOOP:
  Discard n
  Start PRINT_LOOP:
    Print top as integer
    Go to next iteration of PRINT_LOOP

Funny thing is, is that outputting with the additional single leading 0 as the challenge in the Sandbox initially had, this could have been 11 bytes shorter: try it online. xD

I'm still mulling over some kind of challenge that involves an index....

Batch, 85 Bytes
@for /L %%A in (1 1 9)do @For /L %%B in (1 1 %%A)do @Call Set O=%%O%%%%A
@Echo(%O%
TIO not available.

even longer than hardcode @echo 122333444455555666666777777788888888999999999

Fortran (GFortran), 38 28 bytes
print*,(10**i/9*i,i=1,9)
end

Try it online!
Edit: Turns out the program statement is optional, saving 10 bytes!

I'm glad somebody did a Fortran answer.

Python 3, 38 bytes
print([str(x)*x for x in range(1,10)])

Try it online!
C++ (gcc), 59 bytes
for(int i=1;i<10;++i){for(int x=1;x<=i;++x){std::cout<<i;}}

Try it online!
Started learning c++ an hour ago, tried codegolf :)

@ceilingcat so all the imports and func names must be in the code? Thanks for pointing this out!

67 bytes

vJASS, 126 bytes
//! zinc
library q{function onInit(){integer x,y;string s="";for(1<=x<10){for(0<=y<x){s+=I2S(x);}}BJDebugMsg(s);}}
//! endzinc

Javascript, 48 bytes
for(x=1;x<=9;x++){console.log((x+'').repeat(x))}

Try it online!

You can save 2 bytes with :
for(x=0;x++<9;){console.log((x+'').repeat(x))}

C++ (gcc), 93, 65 bytes
int a;void n(){int b=a;while(b){std::cout<<a;b--;}if(a++!=9)n();}

Try it online!
The loop work is essentially the same as the previous version, but instead its own function.
It sets the starting digit -> 1 -> counter then it prints digits until the counter reaches 0. At that point it increments the digit and recalls the function until 9.
C++ (gcc), 93 bytes
int main(int n){static int a=1;int b=a;if(b>9)return 0;while(b){std::cout<<a;b--;}main(a++);}

Try it online!
Don't mind the main...

60 bytes

51 and 59 bytes

50 bytes

dc, 25 24 22 bytes
1[ddIr^9/*n1+dA>m]dsmx

Try it online!

Common Lisp, 50 bytes
(loop for x from 1 to 9 do(dotimes(n x)(write x)))

Try it online!

cQuents, 6 bytes
#9&$D$

Try it online!
Oh cool, another way to use cQuents!

International Phonetic Esoteric Language, 21 bytes
{A}1ɑee0ɑbue1søɒe1søɒ

Prints 122333444455555666666777777788888888999999999.
Explanation:
{A}1ɑee0ɑbue1søɒe1søɒ
{A}1                  (push loop bounds, 1 to 10)
    ɑ                 (start loop)
     e                (push the current index)
      e0              (push loop bounds for current digit, 0 to index)
        ɑ             (start loop)
         bu           (DUP and CPRINT current digit)
           e1sø       (increment index)
               ɒ      (end loop)
                e1sø  (increment index)
                    ɒ (end loop)

Python 3, 34 bytes
for i in range(10):print(str(i)*i)

Try it online!

You can get your answer formatted in the standard format used on this site, over here. Just put your code in and click on the link symbol above. That will take you to another page where you will find the Code Golf format option (pasted into your clipboard). You can then just paste that into your answer.

Ok, thanks! I'll remember that.

MAWP 0.1, 22 20 bytes
[![~!:~1A]%!9A?.%1M]

Explanation:
[      start of loop
!      duplicates top of stack
[      start of loop
~!:~   prints bottom stack value
1A     subtracts 1
]      end of loop
%      removes top of stack (0 from the counter in the previous loop)
!9A    diffeence between top value and 9
?.     if top 0, then terminate program
%      removes top value
1M     adds 1 to top value
]      end of loop

C# (Visual C# Interactive Compiler), 45 bytes
for(int j,i=0;i++<9;)for(j=i;j-->0;Write(i));

Try it online!

Clojure, 32 bytes
(for[i(range 1 10)](repeat i i))

This results in a lists of numbers:
((1) (2 2) (3 3 3) (4 4 4 4) (5 5 5 5 5) (6 6 6 6 6 6) (7 7 7 7 7 7 7) (8 8 8 8 8 8 8 8) (9 9 9 9 9 9 9 9 9))

Rust, 77 75 73 72 57 56 bytes
fn main(){for k in 1..10{for j in 0..k{print!("{}",k)}}}

Try it online!
And I thought Lua was verbose!
Thanks to ovs for saving 15 bytes.

You don't need i, 0..k and println!("{}",i) works just fine. Then you can use a closure instead of a full program like this: ||for i in 1..10{for j in 0..k{println!("{}",k)}}.

And returning an iterator instead of printing the result is a little shorter: https://tio.run/##FcrBCoMwDADQ@76i85TACHrtnPuLXUspLQhpFRdHwfjt3XZ88Lb9LS0Vk/1cAI/GUUx6qMJANPRIib247FfQqtATVaS/8vKJ6rQi3tu6zUW4XKE77PPsbiYBUliYYxBrx1cMo5sm@NXL2b4

@ovs, Wow. This is the first time I've coded anything in Rust (we've just adopted it at my workplace), so it's clear I've got a lot to learn. I'm still trying to wrap my head around how the closures work. I'm using print! instead. That seems to work.

brainfuck, 50 bytes
+[>+<+++++]+++++++++[>-->+[<.>>+<-]>[<+>-]<<+++<-]

Try it online!
Assumes byte cells; does not go out of bounds to left.

Poetic, 222 bytes
THE NUMERICAL I/O RULES
i saw a digit,o yes
o,again,i saw a number;too many
i do the I/O rules,i get a repeat
i now count to zeros
o,from one right to nine,i do digits,e.t.c
seldom a newline,since i know i am swayed not to

Try it online!

Husk, 7 bytes
mod´Rḣ9

Try it online!
Husk, 7 bytes
mdg´Ṙḣ9

Try it online!

Canvas, 6 bytes
９｛：ŗ×］

Try it here!

Excel, 29 24 bytes
Saved 5 bytes thanks to Taylor Raine
=REPT(ROW(1:9),ROW(1:9))

ROW(1:9) returns an array of the numbers 1 through 9 so the REPT() function repeats each of those numbers itself-many times.

You can make this shorter by dropping the Let and using Row(1:9) instead - =REPT(ROW(1:9),ROW(1:9))

APOL, 21 bytes
ⅎ(9 p(*(t(∈) ∈)))

Could you provide a link to an interpreter for APOL?

@cairdcoinheringaahing https://replit.com/@GingerIndustries/APOL

Pip, 5 bytes
,tX,t

Attempt This Online!
Explanation
,t     Range(10)
  X    String-repeat (itemwise)
   ,t  Range(10)

That is, for each number in [0; 1; 2; 3; 4; 5; 6; 7; 8; 9], repeat it a number of times equal to itself. The result is the list [""; 1; 22; 333; 4444; 55555; 666666; 7777777; 88888888; 999999999], which is by default concatenated together and printed.

Desmos, 21 bytes
l=[1...9]
l10^l/9-l/9

Try It On Desmos!
Try It On Desmos! - Prettified
Uses the following formula for the \$n\$th number:
$$\frac{10^n-1}9\times n$$
[1,22,333,4444,55555,666666,7777777,88888888,999999999] is the value of the list in the second line.
Made it look "obfuscated" for fun but it's really just the same as:
l=[1...9]
l(10^l-1)/9

which is also 21 bytes.

Fig, \$7\log_{256}(96)\approx\$ 5.762 bytes
Ma9'*+D

Try it online!
Explained
Ma9'*+D
Ma9'    # To each item n in the range [1, 9]
    *+D # Repeat the stringified n, n times

Regenerate, 15 bytes
(#1{#1} ! ){10}

Outputs space-separated runs of digits, with a leading and a trailing space. Attempt This Online!
Explanation
Spaces are replaced with underscores for clarity.
(#1{#1}_!_){10}
           {10}  Repeat 10 times
(         )      and store as group 1 after each match:
 #1                Length of previous match of group 1
   {#1}            repeated (length of previous match of group 1) times
       _           followed by a space
        !          Or, if that failed because there was no previous match of group 1,
         _         just a space

The first match of group 1 is a space, which has length 1, so the second match is one 1 followed by a space, which has length 2, so the third match is two 2's followed by a space, and so forth.

Headass, 31 bytes
+^{{D^(]<)PN][}:(+++[]]]>)N^-[}

Try It Online!
Beats the naive solution (+P+PP+PPP... and so on for 54 bytes) by 23 bytes.
Outputs individual digits separated by newlines
Breakdown:
+^{{D^(]<)PN][}:(+++[]]]>)N^-[}  full program

+^                               initialize r1 to be 1
                                 r2 is already initialized to 0
  {                           }  repeat
    D^(  )     :(        )       until r1
                 +++[]]]>        fails to be less than 9
   {          }                    repeat
    D^(  )                         until r1
       ]<                          fails to be more than r2
    D     P                          print r1
           N][                       increment r2
                                   end repeat
                          N^       increment r1
                          N -[     set r2 to 0
                                 end repeat

this 25 byter takes n and outputs the number n*(n 1s in a row): U({D+^-)DD]P:]]]]]]]]]][}. I don't think I can iterate from 1-9 with just 5 bytes though...

Prolog (SWI), 43 bytes
:-between(1,9,N),between(1,N,_),\+write(N).

Try it online!

-1 byte

yup, 43 41 bytes
0e:{~:{~:#~0e-}0e--:0ee00e--|00e--e0e-~-}

Try it online.
Explanation:
0e           # Push 1 (push 0; pop and push exp(0))
  :          # Duplicate it
   {         # Loop while the top of the stack is >0 (without popping):
    ~        #  Swap the top two values on the stack
     :       #  Duplicate the top
      {      #  Inner loop while the top of the stack is >0 (without popping):
       ~     #   Swap the top two values on the stack
        :    #   Duplicate the top
         #   #   Pop and print it as number
       ~     #   Swap the top two values on the stack back
        0e-  #   Decrease it by 1 (push 0; pop and push exp(0); subtract)
      }      #  Stop the inner loop if the top of the stack is <=0 (without popping)
       0e--  #  Increase the current value by 1 (using the 0 that was still on the
             #  stack as: push 0 → exp(0)=1 → 0-1=-1 → --1=+1)
       :     #  Duplicate the top again
        0ee00e--|00e--e0e-
             #  Push 9.107... (see below)
         ~   #  Swap the top two values again
          -  #  Subtract the current value from the 9.107...
   }         # Stop the outer loop if the top of the stack is <=0 (without popping)
             # (which it will be once we've reached 10)

0ee00e--|00e--e0e- # Push 9.107...:
0                  #  Push 0        - STACK: 0
 e                 #  exp(0)        - STACK: 1
  e                #  exp(1)        - STACK: 2.718...
   0               #  Push 0        - STACK: 2.718...,0
    0              #  Push 0        - STACK: 2.718...,0,0
     e             #  exp(0)        - STACK: 2.718...,0,1
      -            #  Subtract      - STACK: 2.718...,-1
       -           #  Subtract      - STACK: 3.718...
        |          #  ln(3.718...)  - STACK: 1.313...
         0         #  Push 0        - STACK: 1.313...,0
          0        #  Push 0        - STACK: 1.313...,0,0
           e       #  exp(0)        - STACK: 1.313...,0,1
            -      #  Subtract      - STACK: 1.313...,-1
             -     #  Subtract      - STACK: 2.313...
              e    #  exp(2.313...) - STACK: 10.107...
               0   #  Push 0        - STACK: 10.107...,0
                e  #  exp(0)        - STACK: 10.107...,1
                 - #  Subtract      - STACK: 9.107...

F# (.NET Core), 59 58 57 bytes (thanks ouflak!)
for i=1 to 9 do String.replicate i (string i)|>printf"%s"

or
for i=1 to 9 do printf"%s"(String.replicate i (string i))

Try it online!

Welcome to Code Golf! This is a nice submission. As this is a golfing challenge though, white space is among your first enemies, 58 bytes. It does not matter if the program exits with an error or slew of warnings as long as it meets the criteria of the challenge.

Vyxal 3, 3 bytes
9ƛY

Try it Online!
Edit, the three byter is valid

This is great. Would you provide a link to the 'lists of digits' solution, maybe here in the comments? It might actually meet the conditions of the challenge which are pretty broad as far as the output is concerned.

it's just 9ƛY

Yes! That's definitely within the output rules.

Uiua SBCS, 9 bytes
▽:+@0.⇡10

Try it!

mlochbaum/BQN, 7 bytes
⥊˜¨1+↕9

Try it!
Explanation
⥊˜¨1+↕9
     ↕9 range from 0 to 8
   1+   add 1 to each
  ¨     for each element n,
⥊˜      replicate n times

Alternative 7 bytes (with different format): ∾⥊˜¨↕10. Also, ⥊˜¨↕10 (6 bytes) could be used if a leading empty list is fine (it probably is).

AWK, 32 or 37 bytes
This code needs an EOF at the prompt, or a file with an empty line.
{for(;++i<10;)print(10^i-1)/9*i}

Try it online!
To substitute the input, one can use the BEGIN pattern, adding 5 more bytes to the code.
BEGIN{for(;++i<10;)print(10^i-1)/9*i}

JavaScript, 50 bytes
_=>{for(i=0;++i<10;)console.log((''+i).repeat(i))}

Factor, 29 bytes
9 [1,b] [ dup <array> ] map .

Try it online!

A0A0, 46 bytes
O122333444455555666666777777788888888999999999

Literally prints the example output. I'd be very surprised if you can get something smaller in A0A0. The first O outputs the number following it and the number following it is the output. The language specification does not state any restriction on the size of the number, just "signed integer", so this works. (Although an interpreter may not handle this correctly, because this is a 147 bit number and not every language may support numbers that large.)

TI-Basic, 17 bytes
seq(I(₁₀^(I)-1)/9,I,1,9

Output is stored in Ans as a list and displayed.

Lua, 37 bytes
for i=1,9 do print((""..i):rep(i))end

Try it online!

Pure Zsh, 27 bytes
eval ';s+=1;<<<$[s*'{1..9}]
Attempt This Online!

GolfScript, 9 bytes
10,{.`*}/

Explanation
     /  # for each element in...
     10,{ # 0-9
     . # duplicate it
     ` # stringify it
     * # push to the stack the stringified version of the number, repeated that many times
    }  # end block
       # implicitly output the stack

Try it online!

><>, 28 bytes
1:\   >~1+:a=?;!
n$>:?!v1-$:

Try it online!

Thunno N, \$ 8 \log_{256}(96) \approx \$ 6.58 bytes
9R1+eDJ*

Attempt This Online!
Explanation
9R        # Push range(0, 9)
  1+      # Add one to each
    e     # To each number:
     D    #  Duplicate
      J   #  Cast to string
       *  #  Repeat that many times
          # N flag joins by newlines
          # Implicit output

JavaScript, 50 bytes
_=>'122333444455555666666777777788888888999999999' // 50
_=>eval("for(s='',i=0;i<11;s+=''.padEnd(++i,i))s") // 50
n=>eval("for(s='';(n=-~n)<11;s+=''.padEnd(n,n))s") // 50
_=>'123456789'.replace(/(\d)/g,(d,i)=>d.repeat(i)) // 50

Try it:

f1=_=>'122333444455555666666777777788888888999999999' // 50
f2=_=>eval("for(s='',i=0;i<10;s+=''.padEnd(++i,i))s") // 50
f3=n=>eval("for(s='';(n=-~n)<11;s+=''.padEnd(n,n))s") // 50
f4=_=>'123456789'.replace(/(\d)/g,(d,i)=>d.repeat(i)) // 50

console.log(f1());
console.log(f2());
console.log(f3());
console.log(f4());

Pyt, 6 bytes
ɳąĐƖ*ǰ

Try it online!
ɳ           pushes string containing all digits ("0123456789")
 ą          converts to ąrray of characters
  Đ         Đuplicates on stack
   Ɩ        casts top of stack to array of Ɩntegers
    *       string multiplication
     ǰ      ǰoin with no delimiter; implicit print

Uiua, 15 bytes
∵(⋕/⊂∵°⋕↯).+1⇡9

Pad

TypeScript’s type system, 94 bytes
type F<N extends 1[]=[1],L=N["length"]>=L extends 10?[]:[...{[_ in keyof N]:L},...F<[...N,1]>]

Try it at the TS Playground

YASEPL, 24 bytes
=a$`1=b)""ſa;b,a<!+}4,9

explanation (in pseudocode)
=a$`1=b)""ſa;b,a<!+}4,9          packed
=a$                              a = 1
   `1            !+}4,9          for(i = 0; i < 9; i++)
     =b)""ſa;b,a<                  print(str(a).repeat(a))


text:
Ones and Twos for days
Inspiring myself on a recent challenge, we ought to compute a sequence that is very close to A160242.
Task
Your task is to generate the sequence \$ \{s_i\}_{i=0}^\infty \$:
1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, ...
Which is more easily understandable in this format:
      1 2 1
    1 2 2 2 1
  1 2 2 2 2 2 1
1 2 2 2 2 2 2 2 1 ...

Another way to think of it is, this sequence is the concatenation of blocks \$b_i, 0 \leq i\$ where block \$b_i\$ is a 1, followed by \$2i + 1\$ 2s, followed by another 1.
Input
If your program takes input, the input is a non-negative integer n, telling you how far you should go in computing the sequence.
The sequence can

be 0-indexed, so that \$s_0 = 1, s_1 = 2, s_2 = 1, ... \$
be 1-indexed, so that \$s_1 = 1, s_2 = 2, s_3 = 1, ... \$

Output
Your code may do one of the following:

indefinitely print the sequence
print/return the term n as given by the input
print/return all the terms up to the term n as given by the input

Test cases
(the test cases are 0-indexed)
0 -> 1
1 -> 2
2 -> 1
3 -> 1
4 -> 2
5 -> 2
6 -> 2
7 -> 1
8 -> 1
9 -> 2
10 -> 2
11 -> 2
12 -> 2
13 -> 2
14 -> 1
15 -> 1
16 -> 2
17 -> 2
18 -> 2
19 -> 2
20 -> 2
21 -> 2
22 -> 2
23 -> 1
24 -> 1
25 -> 2
26 -> 2
27 -> 2
28 -> 2
29 -> 2

This is code-golf so the shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!

If I do my answer in 1-index, can I treat the test cases as 1-indexed as well?

@JeffZeitlin of course!

You should leave the IO formats as the default rather than override them. If you meant to re-iterate the defaults, then you left a couple out (like a few of the options for functions)

@JoKing I was pretty confident I had seen a fair share of sequence challenges where the 3 standard outputs were these. What did I leave out?

I may be taking indefinitely print the sequence  too literally, but the tag wiki for [tag:sequence] allows returns an infinite lazy iterator/generator

JavaScript (ES7),  25 24  23 bytes
Returns the \$n\$-th term, 1-indexed.
n=>n>(++n**.5|0)**2?2:1

Try it online!
How?
We have \$a(n)=2\$ iff the difference between \$n+1\$ and the previous square is greater than \$1\$:
$$n+1-\left\lfloor \sqrt{n+1}\right\rfloor^2>1$$
which boils down to:
$$n>\left\lfloor \sqrt{n+1}\right\rfloor^2$$

Jelly, 6 bytes
,‘Æ²E‘

Try it online!
Explanation
,‘Æ²E‘  Main Link:                  N
,       pair with
 ‘                increment         [N, N + 1]
  Æ²    is it a square?             [issq(N), issq(N + 1)]
    E   are both equal (N and N+1 cannot both be square, so if one is square, it will return 0, and if both are not square, it will return 1)
     ‘  increment (if N or N+1 is square, return 1; otherwise, return 2)
        (implicit input)

1 indexing is fine, Ty for your comment.

Python 2, 24 bytes
lambda n:2-(-n%n**.5<.5)

Try it online!
Outputs the \$n\$'th value one-indexed.
We use an arithmetic expression to identify indices n that are either perfect square or one below a perfect square. To do so, we use a measure that's roughly of the distance between n and the next perfect square, given by -n%n**.5.
For squares, we have -n%n**.5==0 because n is an even multiple of its square root, that is for n=k*k, -(k*k)%k==0. If n is one less than a perfect square, then the remainder is <0.5, if it's two less, it's be between 0.5 and 1, and so on. So, the condition -n%n**.50.5 accepts only perfect squares and numbers one less.

This gives the wrong output for n=8, 15, 24,...

@PoonLevi Thanks, that's embarrassing I missed that.

Fixed and undeleted

Python 3.8 (pre-release), 31 bytes
i=0
while i:=100*i+121:print(i)

Try it online!
Print the sequence infinitely, with a questionable format.

The following version output the first n terms of the sequence:
Python 3, 56 bytes
lambda n:"".join(f"{1:2<{-~i*2}}1"for i in range(n))[:n]

Try it online!
Input: Non-negative integer n
Output: the first n terms of the sequence, concatenated into a string.
Explanation
A different approach using only string formatting instead of @Arnauld's closed-form formula.

f"{1:2<{x}}1" evaluates to "122..21" with x-1 characters "2". (The first "1" is left justified to a block of width x, with "2" being the fill character).
-~i*2 is equivalent to (i+1)*2

Thus f"{1:2<{-~i*2}}1" evaluates to the string "122..21" with i*2+1 characters "2".

I like your 31 byter a lot! Really clever way of building the sequence.

You can get rid of the questionable format by adding ,end=''.

@L.F. yeah... but that will takes more bytes on something not absolutely necessary. I'd prefer keeping the format as it is if it saves some characters.

now 3.8 is stable.

R, 27 25 bytes
-1 byte thanks to Giuseppe
1+all((scan()+1:2)^.5%%1)

Try it online!
Uses the fact that \$s_n=1\$ iff \$n+1\$ or \$n+2\$ is a perfect square.

26 bytes?

@Giuseppe Thanks! I found an extra byte to golf, down to 25.

Symja, 38 33 bytes
f(x_):=If(Mod(-(x^.5),1)*x<1,1,2)

Y'all can try it here
This is just a port of xnor's (who helped me save 5 bytes) Python 2 answer in Symja. This took a while to generate, as I had to properly understand what the formula was, due to operator precedence. Anyhow, enjoy!

I dunno Symja, but I'd guess you could replace the 2- by putting the resulting values in as the outcomes of the If. Also, it doesn't lok like you need parens after the *x.

@xnor You're right. The brackets must have been from failed attempts at porting. Thanks!

Python 2: 52 bytes
def g(n):return(2,1)[not((n+1)**.5%1and(n+2)**.5%1)]

Try it online!
Returns the nth term in the sequence.
Also using the fact that the nth term = 1 <=> (n+1) or (n+2) is square as Robin Ryder pointed out.

You can use lambda to get rid of return statement, and 2-i instead of (2,1)[i]. 43 bytes

APL (Dyalog Unicode), 67 bytes
This answer returns the entire sequence up to the requested value.
f←{(⊃,/1,¨⌽¨1,¨2⍴⍨¨1+2×1-⍨⍳1+⌈⍟⍵)[⍳⍵]}

Try it online!
Decomposition/Explanation:
f←                                     ⍝ assign the name f to
  {                                  } ⍝ a dfn that takes a single argument
                              ⍟⍵       ⍝ The natural logarithm of the argument,
                             ⌈         ⍝ rounded up to the next integer,
                           1+          ⍝ and add 1 (giving N), then
                          ⍳            ⍝ generate the sequence 1..N,
                       1-⍨             ⍝ and subtract 1 from each term (0..N-1)...
                                       ⍝    ⍨ means to swap the arguments to
                                       ⍝    - (the standard subtraction function), so
                                       ⍝    1-⍨N is the same as N-1.
                     2×                ⍝ ... then multiply each term in the sequence by 2,
                   1+                  ⍝ and add 1
                  ¨                    ⍝ then take each term in the sequence, and
               2⍴⍨                     ⍝ generate a vector of that many 2s
                                       ⍝    ⍨ means to swap the arguments to
                                       ⍝    ⍴ the "shape" function. For simple numeric
                                       ⍝    values of A and B, A⍴B means to generate a
                                       ⍝    vector of A repeats of B.
                                       ⍝ We now have a vector of vectors of 2s.
              ¨                        ⍝ For each of those vectors,
            1,                         ⍝ prepend a 1, then
           ¨                           ⍝ for each vector,
          ⌽                            ⍝ reverse it (so that the 1 is on the 'back end'), then
       1,¨                             ⍝ for each (now reversed with a 1) vector, prepend a 1, and
     ,/                                ⍝ concatenate all the vectors. For reasons I don't quite
                                       ⍝    understand, this generates an enclosed object, so
    ⊃                                  ⍝ unenclose (disclose) it into a 'real' vector, and
   (                            )      ⍝ treat all that as an object...
                                 [  ]  ⍝ ...which can be subscripted. If the subscript is
                                       ⍝    a single integer, it will return just that item from
                                       ⍝    the array; if it's a vector, it will return all of the
                                       ⍝    requested values, in the order specified by the vector.
                                  ⍳⍵   ⍝ This subscript is a vector, of the integers 1 to the original
                                       ⍝    argument to the function, so it will generate the entire
                                       ⍝    sequence up to the ⍵th term. If I only wanted the single
                                       ⍝    term, I would omit the ⍳, which would give me only the ⍵th term.

FIRST GOLFING (courtesy ngn):
APL (Dyalog Unicode), 65 bytes
f←{⍵↑(⊃,/1,¨⌽¨1,¨2⍴⍨¨1+2×1-⍨⍳1+⌈⍟⍵)}

Try it online!
Explanation of golfing:
[⍳⍵] is the same as [1 2 3 4 5 6 ... ⍵],
      which is the first ⍵ items of the vector being subscripted.
      That's the same as
⍵↑    "Take" the first ⍵ items.  Savings, 2bytes.

SECOND GOLFING (my own discovery):
APL (Dyalog Unicode), 63 bytes
f←{⍵↑⊃,/1,¨⌽¨1,¨2⍴⍨¨1+2×1-⍨⍳1+⌈⍟⍵}

Try it online!
Explanation of golfing: The expression that was formerly subscripted does not need to be parenthesized if using ⍵↑ instead of [⍳⍵]. Savings, 2bytes.

-13 chars

PowerShell, 23 bytes
for(){$i++;1;,2*$i++;1}

Try it online!
Prints the sequence indefinitely.

Perl 6, 28 27 bytes
{flat (1,2,2 xx$++*2,1)xx*}

Try it online!
Anonymous codeblock returning a lazy infinite list. I wish I could do 2 xx++$++ or some combination of it, but i can't figure it out.

GolfScript, 16 bytes
Port of Surculose Sputum's Python answer.
0{100*121+.p.}do

Try it online!

Python 3, 37 bytes
i=1
while 1:print('1'+'2'*i+'1');i+=2

Try it online!

Husk, 14 12 10 bytes
ṁ`Jḋ3MRİ12

Try it online!
Infinite list.
-1 byte from Dominic Van Essen.
-2 bytes from Zgarb using voodoo magic.

13 bytes I think...

@DominicvanEssen that works with ȯ. nice.

Ah yes!  Well spotted.

10 bytes. It was a bit challenging to get J to choose the right type...

C (clang), 80 75 bytes
j,k=1;main(int a,char**b){for(a=atoi(b[1]);j<a;k+=2,j+=k);return(1<j-a)+1;}

Try it online!
This one takes an input N at the terminal and returns the Nth value.  This is zero-indexed.
C (gcc), 48 44 bytes
j,k=1;f(a){for(;j<a;k+=2,j+=k);a=(1<j-a)+1;}

Try it online!
Same basic function here, but modified to just be a function to not take the hit from main's arg-list and converting a string to an integer.  Switched over to GCC to take advantage of undefined behavior that avoids need for explicit return.

Hey there, welcome to this community! Can you please provide a TIO link with your code?

@RGS Added TIO.

Thanks, nice first post!

Suggest j+=k+=2 instead of k+=2,j+=k

39 bytes by removing j and using 1-based indexing.

@ceilingcat Ah, good catch for golfing the algorithm without changing it.

@Bubbler When I have time, I have a couple questions about how your changes work.  For starters, though, I'm curious why the k=1 assignment is necessary in the for-loop rather than initialization.

@ChristianGibbons the k=1 assignment needs to be moved so the function can be called again.

Oh, right, I was still in the mind-space of my original design that didn't separate it out into its own function.

C (gcc), 56 bytes
i,c;main(){main(i--<-2?i=c+=2:putchar(49+(c+~i&&i+3)));}

-1 byte thanks to RGS!
-8 bytes thanks to ceilingcat!
Try it online!
C (gcc), 46 bytes
i;f(n){for(i=0;n--;)printf("%d",i=i*100+121);}

Stretches the rules and only works up to \$n=4\$.
Try it online!

Wolfram Language (Mathematica), 42 bytes
If[#==1||(d=NumberQ@*Sqrt)@#||d[#+1],1,2]&

returns 1 if n=1 or n is a perfect square or n+1 is a perfect square
Try it online!

05AB1E, 6 bytes
>‚Å²Ë>

Port of @HyperNeutrino's Jelly answer, so make sure to upvote him!
Outputs the result for the 1-based input \$n\$.
Try it online or verify all the first \$n\$ outputs.
Printing the infinite sequence is 9 8 bytes (based on the 6-byter above):
∞ü‚Å²€Ë>

Try it online.
Previous 9 bytes variations for the infinite sequence:

Y∞иXδš€û˜: Try it online.
ÅÉÅ2Xδ.ø˜: Try it online.

Explanation:
>         # Increase the (implicit) input-integer by 1
 ‚        # Pair it with the (implicit) input-integer: [input, input+1]
  Å²      # Check for both whether they're a square (which will be either both falsey,
          # or just one of the two is truthy)
    Ë     # Check if both are equal (so both falsey) (1 if truhy; 0 if falsey)
     >    # And increase that by 1 (2 if truthy; 1 if falsey)
          # (after which the result is output implicitly)

∞         # Push an infinite positive list: [1,2,3,...]
 ü‚       #  Pair each overlapping pair together: [[1,2],[2,3],[3,4],...]
   Å²     # Check for each whether it's a square
     €Ë   # Check for each pair whether they're equal
       >  # Increase it by 1
          # (after which it is output implicitly as result)

 ∞        # Push an infinite positive list: [1,2,3,...]
Y и       # Repeat a 2 that many times as list: [[2],[2,2],[2,2,2],...]
    δ     # For each inner list:
   X š    #  Prepend a 1: [[1,2],[1,2,2],[1,2,2,2],...]
      €   # For each inner list:
       û  # Palindromize it: [[1,2,1],[1,2,2,2,1],[1,2,2,2,2,2,1],...]
        ˜ # Flatten the list of lists: [1,2,1,1,2,2,2,1,1,2,2,2,2,2,1,...]
          # (after which it is output implicitly as result)

ÅÉ        # Push all odd numbers equal to or less than the given argument,
          # which will be an infinite sequence without argument: [1,3,5,...]
  Å2      # Create for each value a list with that many 2s: [[2],[2,2,2],[2,2,2,2,2],...]
     δ    # For each inner list:
    X .ø  #  Surround it with 1s: [[1,2,1],[1,2,2,2,1],[1,2,2,2,2,2,1],...]
        ˜ # Flatten the list of lists: [1,2,1,1,2,2,2,1,1,2,2,2,2,2,1,...]
          # (after which it is output implicitly as result)

Charcoal, 11 bytes
↷²1Ｗ¹«2Ｐ1Ｄ2

Try it online! Link is to verbose version of code. Prints the infinite sequence. Explanation:
↷²

Change the default direction to downwards, so that everything now prints vertically by default.
1

Output 1 to the canvas.
Ｗ¹«

Loop forever.
2

Output 2 to the canvas.
Ｐ1

Output 1 to the canvas, but don't move the cursor.
Ｄ

Copy the canvas to STDOUT.
2

Replace the 1 with a 2.

dc, 18 bytes
?d2+vd*rvd*-d/2r-p

Try it online!
This uses 0-based indexing, and it computes the nth value in the sequence for index n.  Input is on stdin, and output is on stdout.
It computes $$2 -K_{\neq0}\big(\lfloor{\sqrt{n+2}}\rfloor-\lfloor{\sqrt{n}}\rfloor\big),$$ where \$K_{\neq0}\$ is the function that maps 0 to 0, and any non-zero number to 1.  (\$K_{\neq0}\$ isn't built into dc, but you can compute it by dividing a number by itself, as long as you're careful with the stack when its argument is 0.)
There may be spurious output on stderr (due to division by 0).
Here's a TIO link to the test suite.

W, 7 bytes
The long length doesn't really matter to me. W doesn't have a square-checking built-in.
φßéW!r♀

Uncompressed:
){Q1m!=r)

Explanation
)         % Increment the input. [input + 1]
 {        % Pair with the input. [input, input + 1]
  Q       % Find the square root.[sqrt(input), sqrt(input + 1)]
   1m     % Modulo 1. (Find the digits after the decimal point.)
     !    % Are the digits 0? (True, it's a square number. Otherwise,
          % it can't be a square number.)
      =r  % Reduce by equality.
        ) % Increment the result.

PowerShell, 55 bytes
$i=0;1.."$args"|%{$i+=2;write-host "1,$('2,'*$i)1," -n}

Try it online!

MAWP 0.0, 16 bytes
[1:![2:1A]%1:2M]

Python 3, 39 34 bytes
i=1
while 1:print(1,*[2]*i,1);i+=2

Prints the sequence infinitely. Thanks to @SurculoseSputum for saving me 5 bytes.
Try it online!

I forgot that printing the sequence infinitely is an option... 34 bytes

33 bytes by using the print statement as conditional

Bash, 64 61 41 bytes
Saved 20 bytes thanks to S.S. Anne!!!
s=2;while :;do echo 1 $s 1;s+=' 2 2';done

Try it online!
Infinitely prints the sequence.

41 bytes you don't need the quotes for bash strings without spaces, and some other major fixes

maybe 37

@S.S.Anne Yeah, was trying to get at it from the wrong angle (originally printf with string padding) . Nice one - thanks! :-)

C (gcc) -lm, 57 \$\cdots\$ 52 50 bytes
Saved 2 bytes thanks to ceilingcat!!!
t;s(n){t=sqrt(n);n=n!=t*t;};f(n){n=1+s(n)*s(n+1);}

Try it online!
Returns the nth term in the sequence.

Brainfuck, 72
+++++++[>+++++++<-]>[>+>+<<-]>>+[<.>>+[>+>+<<-]>[<<.>>-]>[<<+>>-]<<<<.>]

Might be able to make it shorter but here's my shot. Prints indefinetly

Initialize first two cells with (ASCII values for) 1 and 2
Start a loop (looping on the 2 cell but it doesn't really matter)

Print the 1
Increase the count, and then copy the count to the next two cells
Use one of the counts to print the twos (decreases the count until 0, then exits loop)
Copy the second copy of the count back to where it was before
Print a final 1

Can you please provide a TIO link?

66 bytes using Brainfuck constants.

42 bytes by just using 1 cell for ASCII 1

Perl 5, 35 + 1 (-p) = 36 bytes
$_=(map{(1,2,(2,2)x$_,1)}0..$_)[$_]

Try it online!
Reads input n from stdin. Simplisticly builds a list of the first at least n elements (actually the first 2n+3 elements), then prints the nth element.
Perl 5, 30 + 1 (-p) = 31 bytes
$_=$_+1>(($_+2)**0.5|0)**2?2:1

Smarter and more efficient way of doing it with Arnauld's formula from above (but adjusted to be 0-indexed instead of 1-indexed, because that's how I like it).
Try it online!

dirt (verbose mode), 17 bytes
"1
2
1"|1"
2
2".*

Run as dirt ones_and_twos.dirt -v -i ""
Outputs each element of the sequence on a new line.
Alternatively, if we allow new lines between some but not all elements,
dirt (verbose mode), questionable format, 13 bytes
"121"|1"22".*

prints
121
12221
1222221
122222221
12222222221
1222222222221
122222222222221
12222222222222221
...

cQuents, 21 bytes
_+(Tr$)%1)=Tr_+$)%1))

Try it online!
Port of the jelly answer.
Explanation
    r$)     r_+$)     # Root (defaults to square root)
       %1        %1   # Modulo 1 (only taking the decimal part)
   T     ) T       )  # Ceiling (round up if there is a decimal part)
  (       =         ) # Equal (same as jelly answer)
_+                    # Successor (same as jelly answer)

List output, 15 bytes
1,D2)*_-(k*2),1

Try it online!
Playing with the output a bit, we can golf off 6 bytes.
Instead of outputting 1,2,2,2,1, it outputs 1,[2,2,2],1.
Explanation
1,              # A one
  D2)           # Digits of 2 (which is of course, just 2)
     *_-(k*2)   # Multiplied by k*2-1 (it's multiplying a list)
             ,1 # Another one

Why is it cheating?

It outputs a list instead of outputting the sequence. It only works for indefinitely printing, whereas other normal cQuents code could work for all 3 cases (the third requiring an &).

Indefinite printing is fine but the lists in the middle of the numbers look weird

Hold on, I just found the jelly answer. Gonna port.

Haskell, 36 bytes
do n<-[0..];'1':([1..n]>>"22")++"21"

Try it online!
This expression evaluates to an infinite string.

APL+WIN, 31 bytes
Prompts for integer. Index origin=1
Returns single term of the series.
2 1[1++/m=1,(n+1),n←+\1+2×⍳m←⎕]

Try it online! Courtesy of Dyalog Classic

Haskell, 51 Bytes
f n=concat['1':['2'|x<-[0..y*2]]++"1"|y<-[0..n]]!!n

Not very competitive, but I thought that I would provide a  Haskell solution.

Wolfram Language (Mathematica), 26 bytes
Count[√#+√(#+1),_@__]&

Try it online!
1-indexed.
√#+√(#+1)           (* sqrt(n)+sqrt(n+1) *)
Count[ % ,_@__]     (* count nonatomic subexpressions at the first level. *)

Haskell, 31 bytes
do n<-[1..];show$div(100^n)9*11

Try it online!
32 bytes
show=<<iterate(\x->x*100+121)121

Try it online!