text:
Draw an ASCII meandering curve
For the purpose of this question a meandering curve is one that follows the general direction from left to right, but makes repeatedly n+1 turns at 90 degrees to the left and then n+1 turns to the right (for n>0).
In fact the meander itself will have n segments.
The turns are denoted with +.
The width of the meanders (the distance between two +) is 3 at the horizon (---) and 1 at the vertical (|)
Here are the single segments a meandering curve with sizes n from 1 to 5:
                                                           +-------------------+
                                                           |                   |
                                       +---------------+   |   +-----------+   |
                                       |               |   |   |           |   |
                       +-----------+   |   +-------+   |   |   |   +---+   |   |
                       |           |   |   |       |   |   |   |   |   |   |   |
           +-------+   |   +---+   |   |   +---+   |   |   |   +---+   |   |   |
           |       |   |   |   |   |   |       |   |   |   |           |   |   |
   +---+   +---+   |   +---+   |   |   +-------+   |   |   +-----------+   |   |
   |   | 1     |   | 2         |   | 3             |   | 4                 |   | 5
---+   +-------+   +-----------+   +---------------+   +-------------------+   +

Challenge:
Given two positive numbers n and m, draw m segments of a meandering curve with size n.
You can write a full program or a function.
Input:
n > 0 The size of the curve
m > 0 Number of segments to draw
Output:
An ASCII representation of the meandering curve.
Examples:
n = 3
m = 2
   +-----------+   +-----------+
   |           |   |           |
   |   +---+   |   |   +---+   |
   |   |   |   |   |   |   |   |
   +---+   |   |   +---+   |   |
           |   |           |   |
-----------+   +-----------+   +

n = 2
m = 5
   +-------+   +-------+   +-------+   +-------+   +-------+
   |       |   |       |   |       |   |       |   |       |
   +---+   |   +---+   |   +---+   |   +---+   |   +---+   |
       |   |       |   |       |   |       |   |       |   |
-------+   +-------+   +-------+   +-------+   +-------+   +

n = 4
m = 4
   +---------------+   +---------------+   +---------------+   +---------------+
   |               |   |               |   |               |   |               |
   |   +-------+   |   |   +-------+   |   |   +-------+   |   |   +-------+   |
   |   |       |   |   |   |       |   |   |   |       |   |   |   |       |   |
   |   +---+   |   |   |   +---+   |   |   |   +---+   |   |   |   +---+   |   |
   |       |   |   |   |       |   |   |   |       |   |   |   |       |   |   |
   +-------+   |   |   +-------+   |   |   +-------+   |   |   +-------+   |   |
               |   |               |   |               |   |               |   |
---------------+   +---------------+   +---------------+   +---------------+   +

Winning criteria:
This is code-golf, so the shortest code in bytes in each language wins.
Please explain your code, if you have time to do it.

Suggestion for future challenge: plot the first figure (the one with increasing meanders), allowing graphical output

Isn't it n left turns?

@LuisMendo Yes, when I composed the 1-5 image, I realised that there is a good challenge within it - given a list L of positive integers, compose a meandering curve with segments of size  L(i)

@LiefdeWen It depends on where you start counting. I think it's n+1 when looking at the examples, especially between the single segments..

Charcoal, 52 34 33 bytes
Ｎθ↶ＦＮＦ⊗⊕θ«+⊖⊗×⊕﹪κ²∨↔⁻θ∧κ⊖κ¹¿›κθ↷↶

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

Input the size of the meander.
↶

Pivot upwards as the drawing starts at the right and works left.
ＦＮ

Loop over the desired number of meanders.
Ｆ⊗⊕θ«

Loop over the segments of the meander.
+

Print a +.
∨↔⁻θ∧κ⊖κ¹

Compute the kth element of the list \$ n, n, n-1, n-2 ... 3, 2, 1, 1, 1, 2, 3, ... n \$.
⊖⊗×⊕﹪κ²...

Alternate between doubling and quadrupling the lengths since the horizontal lines are twice as long, but decrement the result before printing to take account of the + that was just printed.
¿›κθ↷↶

Pivot appropriately for the next segment.

APL (Dyalog Classic), 108 101 95 bytes
' -+|'[⊃,/⎕⍴⊂b/⍨3 1⍴⍨≢⍉b←⌽⊖2@a⌽1@(a←⊂0 0)⊖0,⊃{((4|-⊖⍉⍵),⍉¯2↑⍉⍵)⍪(2/⍪⍳2),¯2↑⍵}/⎕⍴⊂46 16 47⊤⍨3⍴4]

Try it online!

I can confidently say I have never seen an APL answer like this one.

C (gcc), 559 540 523 511 494 484 476 468 456 447 443 bytes
#define S memset
l,o,p,q,r;g(c,d,n)char*d;{q=~c;for(p=n*2;q%2*p;bcopy(n*2-p--?"|   |":"+---+",d-q*l*p,5));p=n-1;c--%2?S(S(d-~l-r*!q,45,r++)-2*l,45,r=n*4-1),d[r*=q-1]='|',d[r-l]=d[r+l]=43,p&&g(c%4,memcpy(q?d+p*4+l:d-l-n*4,q?"+   |":"|   +",5),p):p&&g(c%4,d,p,d[-q]=45,d[q*=l]=43,*(d-=q*(n*2*l-l-2)-2)=32);}f(n,m){char b[(o=n-~n)*(l=n*4+5)];g(0,strcpy(S(S(b,32,l*o),45,l)+l-6,"+   +"),n);for(o*=m;b[o/m*l-1]=0,o--;o%m||puts(""))printf(b+o/m*l);}

Try it online!
Slightly less golfed
#define S memset
l,o,p,q,r;
g(c,d,n)char*d;{
 q=~c;
 for(p=n*2;q%2*p;bcopy(n*2-p--?"|   |":"+---+",d-q*l*p,5));
 p=n-1;
 c--%2?
  S(S(d-~l-r*!q,45,r++)-2*l,45,r=n*4-1),
  d[r*=q-1]='|',
  d[r-l]=d[r+l]=43,
  p&&
   g(c%4,memcpy(q?d+p*4+l:d-l-n*4,q?"+   |":"|   +",5),p)
 :
  p&&
   g(c%4,d,p,d[-q]=45,d[q*=l]=43,*(d-=q*(n*2*l-l-2)-2)=32);
}
f(n,m){
 char b[(o=n-~n)*(l=n*4+5)];
 g(0,strcpy(S(S(b,32,l*o),45,l)+l-6,"+   +"),n);
 for(o*=m;b[o/m*l-1]=0,o--;o%m||puts(""))
  printf(b+o/m*l);
}

Python 3, 371 354 346 328 298 290 bytes
import sys
v=sys.argv
s=int(v[1])
n=range
r="   |"
t="   +---"
h="-"*4
e=" "*4
def C(l):print(l*int(v[2]))
for i in n(-(-s//2)):q=s-i+~i;R=r*i;C(R+t+h*q+"+"+R);C(R+r+e*q+R+r)
for i in n(s//2):q=s//2-i;R=r*~-q;w=2*i+s%2;C(R+t+h*~-w+"+"+r*(q+((i>0)|s%2)));C(R+e*-~w+R+2*r)
C(h*~-s+"---+   +")

-20B Thanks to ceilingcat
Try it online!
Pre-golfing:

import sys

import math

def draw_curve(curve_size, curve_count, out=sys.stdout):
    for i in range(math.ceil(curve_size / 2)):
        for j in range(curve_count):
            out.write("   |" * i)
            out.write("   +---")
            out.write("----" * (curve_size - 2 * i - 1))
            out.write("+")
            out.write("   |" * i)

        out.write("\n")

        for j in range(curve_count):
            out.write("   |" * (i + 1))
            out.write("    " * (curve_size - 2 * i - 1))
            out.write("   |" * (i + 1))

        out.write("\n")

    for i in range(curve_size // 2):
        for j in range(curve_count):
            out.write("   |" * (curve_size // 2 - i - 1))
            out.write("   +---")
            out.write("----" * (2 * i - (0 if curve_size % 2 else 1)))
            out.write("+")
            out.write("   |" * (curve_size // 2 - i + (1 if i or curve_size % 2 else 0)))

        out.write("\n")

        for j in range(curve_count):
            out.write("   |" * (curve_size // 2 - i - 1))
            out.write("    " * (2 * i + (2 if curve_size % 2 else 1)))
            out.write("   |" * (curve_size // 2 - i + 1))

        out.write("\n")

    for j in range(curve_count):
        out.write("----" * (curve_size - 1))
        out.write("---+   +")

if __name__ == "__main__":
    draw_curve(int(sys.argv[1]), int(sys.argv[2]))

Dash - POSIX Shell script, 528 bytes
Try it online!
golfed:
Y=0;p(){ eval A${1}_${2}='$3';};for Z in `seq $2`;do case $1 in 1)L='r3 u1 r3 d1';;2)L='r7 u1 l3 u1 r7 d3';;3)L='r11 u3 l3 d1 l3 u3 r11 d5';;4)L='r15 u5 l7 d1 r3 d1 l7 u5 r15 d7';;5)L='r19 u7 l11 d3 r3 u1 r3 d3 l11 u7 r19 d9'
esac;for A in $L;do d(){ C=-;case "$1" in r*)X=$((X+1));;l*)X=$((X-1));;u*)Y=$((Y+1));C=\|;;d*)Y=$((Y-1));C=\|;;esac;p $X $Y $2 $C;};for I in `seq ${A#*[a-z]}`;do d $A;done;d $A +;done;done;for Y in `seq 20 -1 0`;do for X in `seq 0 99`;do eval F="\"\$A${X}_${Y}\"";L=${L}${F:- };done;echo "$L";L=;done

ungolfed:
#!/bin/sh

# helper function for emulating an array, the language does not know it
p(){ eval A${1}_${2}='$3';}
Y=0

for Z in `seq $2`;do

 # define the possible patterns:
 # list="direction+count direction+count ..."
 case $1 in
  1)L='r3 u1 r3 d1';;
  2)L='r7 u1 l3 u1 r7 d3';;
  3)L='r11 u3 l3 d1 l3 u3 r11 d5';;
  4)L='r15 u5 l7 d1 r3 d1 l7 u5 r15 d7';;
  5)L='r19 u7 l11 d3 r3 u1 r3 d3 l11 u7 r19 d9'
 esac

 for A in $L;do
  # helper function for going into needed direction
  # and plot char into array
  d(){
   C=-
   case "$1" in
    r*)X=$((X+1));;
    l*)X=$((X-1));;
    u*)Y=$((Y+1));C=\|;;
    d*)Y=$((Y-1));C=\|;;
   esac
   p $X $Y $2 $C
  }

  # write char as long as needed into array,
  # append in the same direction as last element the '+'
  for I in `seq ${A#*[a-z]}`;do
   d $A
  done
   d $A +
  done
 done

# echo the array linewise
for Y in `seq 20 -1 0`;do
 for X in `seq 0 99`;do
  eval F="\"\$A${X}_${Y}\"";L=${L}${F:- }
 done
 echo "$L";L=
done

Python 2, 261 bytes
n,m=input()
i=0;h,v,p,s=map(tuple,'hv+ ');k=p;R=[h+s]
exec"h,v=v,h;R=zip(*R)[::-1];R=[s+R[0][:-1]+k+h+p]+[s+r+s+v for r in R[1:]]+[h*2*i+h+p+s+p];i+=1;k=v;"*n
for r in[[(3-i%2*2)*{h[0]:'-',v[0]:'|'}.get(c,c)for i,c in enumerate(l)]*m for l in R]:print''.join(r)

Try it online!
5 bytes from this tip by Esolanging Fruit.

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


text:
Recamán's duplicates
Recamán's Sequence is defined as follows:
\$a_n=\begin{cases}0\quad\quad\quad\quad\text{if n = 0}\\a_{n-1}-n\quad\text{if }a_{n-1}-n>0\text{ and is not already in the sequence,}\\a_{n-1}+n\quad\text{otherwise}\end{cases}\$
or in pseudo-code:
a(0) = 0,
if (a(n - 1) - n) > 0 and it is not
   already included in the sequence,
     a(n) = a(n - 1) - n
else
     a(n) = a(n - 1) + n.

The first numbers are (OEIS A005132):
0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, 8, 25, 43, 62, 42, 63, 41, 18, 42

If you study this sequence, you'll notice that there are duplicates, for instance a(20) = a(24) = 42 (0-indexed). We'll call a number a duplicate if there is at least one identical number in front of it in the sequence.

Challenge:
Take an integer input k, and output either the first k duplicate numbers in the order they are found as duplicates in Recamán's Sequence, or only the k'th number.
This first duplicated numbers are:
42, 43, 78, 79, 153, 154, 155, 156, 157, 152, 265, 261, 262, 135, 136, 269, 453, 454, 257, 258, 259, 260, 261, 262

A few things to note:

a(n) does not count as a duplicate if there are no identical numbers in a(0) ... a(n-1), even if a(n+m)==a(n).
42 will be before 43, since its duplicate occurs before 43's duplicate
The sequence is not sorted
There are duplicate elements in this sequence too. For instance the 12th and the 23rd numbers are both 262 (0-indexed).

Test cases (0-indexed)
k      Output
    0      42
    9     152
   12     262
   23     262
  944    5197
  945   10023
10000   62114

This is code-golf, so the shortest code in each language wins!
Explanations are encouraged!

Related

Why isn't 43 output before 42? It appears first in Recamán's sequence. Do you mean output first the one that is first found to be a duplicate?

@LuisMendo As I understand it, $43$ should appear after $42$ because its duplicate occurrence is later on in the sequence (so the second occurrence of $42$ lies before the second occurrence of $43$).

I also, saw the popular math.SE question recently :P

@orlp huh? Can you link to it? I haven't seen it...

There are duplicate elements in this sequence too. For instance the 12th and the 23rd numbers are both 262 (0-indexed). Are there duplicates in this list of duplicate elements too? How deep does this rabbit hole go?

@StewieGriffin https://math.stackexchange.com/questions/2827702/bijection-f-colon-mathbbn-to-mathbbn-with-f0-0-and-fn-fn-1-n

@DJMcMayhem I wouldn't be surprised if every single one of the top 100 users on this site could answer that better than me!

@StewieGriffin Nitpick: as of writing this, you're in the first page (note: yuck).

Wolfram Language (Mathematica), 88 85 76 bytes
(For[i=k=j=p=0,k<#,i~FreeQ~p||k++,i=i|p;p+=If[p>++j&&FreeQ[i,p-j],-j,j]];p)&

Try it online!
1-indexed.
Explanation
For[

For loop.
i=k=j=p=0

Start with i (\$=\{a_1, a_2, \ldots\}\$), k (number of duplicates found), j (\$=n\$), p(\$=a_{n-1}\$) equal to 0.
k<#

Repeat while k is less than the input.
i=i|p

Append p to i using the head Alternatives (a golfier version of List in this case).
p+=If[p>++j&&FreeQ[i,p-j],-j,j]

Increment j. If p is greater than j (i.e. \$a_{n-1} > n\$) and p-j is not in i (i.e. \$a_{n-1} - n\$ is new), then increment p by -j. Otherwise, increment p by j.
i~FreeQ~p||k++

Each iteration, increment k if p is not in i (the || (= or) short-circuits otherwise).
... ;p

Return p.

Python 2, 91 bytes
k=input();n=0;l=n,
while k:n+=1;x=l[-1]-n;u=x+2*n*(x<1or x in l);k-=u in l;l+=u,
print l[n]

Try it online!
1-indexed.

Python 2, 78 bytes
n=input()
l=[];d=x=0
while n:d-=1;l+=x,d;x+=[d,-d][x+d in l];n-=x in l
print x

Try it online!

APL (Dyalog Unicode), 56 54 49 48 bytes (SBCS)
Saved 2 7 bytes thanks to @ovs!
Saved 1 byte thanks to @Adám
0∘{×⍵:r,⍣d⊢(r,⍺)∇⍵-d←⍺∊⍨r←(⊃((≤∨⍺∊⍨-)⌷-,+)≢)⍺⋄⍬}

Try it online!
Can be f k. Recursively builds up the first k duplicates.
⍺ holds Recamán's sequence (in reverse), and is set to 0 if no argument is given (at the start). If k (⍵) is 0, it returns an empty array (⍬). Otherwise, it computes the next term r. If r is present in ⍺, it calls itself with r,⍺ as the left argument and ⍵-1 as the right argument, and prepends r to the result of that. If not, it just returns (r,⍺) f ⍵, hoping for the next iteration to find a duplicate.
⎕IO←0 has to be used before using this, since it relies on 0-indexing.
0∘          ⍝ Default argument to start off the sequence
{×⍵:       ⍝ If k is greater than 1:
    r←(⊃((≤∨⍺∊⍨-)⌷-,+)≢)⍺
                       ≢     ⍝ Current n is the size of ⍺.
       ⊃                     ⍝ First element of ⍺ (a_{n-1})
                 ⌷           ⍝ Index into
                   -,+       ⍝ a_{n-1} - n, a_{n-1} + n using
         (≤∨⍺∊⍨-)           ⍝ another train to return 1 or 0
          ≤                  ⍝ If a_{n-1} is not greater than n
           ∨                 ⍝ or
               -             ⍝ a_{n-1} - n
            ⍺∊⍨             ⍝ is already in a,
                            ⍝ use a+n, otherwise a-n
    d←⍺∊⍨r                        ⍝ Whether or not r (a_n) is a duplicate

  (r,⍺)∇⍵-d
  (r,⍺)                           ⍝ Add r to ⍺, because it's part of Recaman's sequence
        ⍵-d                       ⍝ Decrement k if r is a duplicate
       ∇                          ⍝ Call itself, find the next duplicates

  r(,⍣d)(r,⍺)∇⍵-d
     ⍣d                           ⍝ If d is 0, just return (r,⍺)∇⍵-d
  r ,                             ⍝ Otherwise, add r to the list of duplicates (which is returned from (r,⍺)∇⍵-d

⋄⍬        ⍝ If k is 0, return an empty array
}
```

You can do 0∘{...} to use 0 as a default left argument.

@ovs Oh, that's smart, thanks!

49 bytes by adding more trains ;). If you don't want to change the index origin, r←(⊃(⊃(≤∨⍺∊⍨-)↓-,+)≢)⍺ works for 50 bytes.

@ovs Wow, thanks! I think I'll use the ⎕IO←0 version

(,⍣d) → ,⍣d⊢

@Adám Nice, thanks!

05AB1E, 25 bytes
Outputs the nth item 1-indexed
¾ˆµ¯D¤N-DŠD0›*åN·*+©å½®Dˆ

Try it online!

JavaScript (ES6), 66 59 bytes
Returns the N-th term, 0-indexed.
i=>(g=x=>!g[x+=x>n&!g[x-n]?-n:n]||i--?g(g[n++,x]=x):x)(n=0)

Try it online!
How?
We use g() as our main recursive function and as an object to keep track of the duplicates.
i => (                    // given i
  g = x =>                // g = recursive function and generic object
    !g[x +=               // update x:
      x > n & !g[x - n] ? //   if x is greater than n and x - n was not visited so far:
        -n                //     subtract n from x
      :                   //   else:
        n                 //     add n to x
    ]                     // if x is not a duplicate
    || i-- ?              // or x is a duplicate but not the one we're looking for:
      g(g[n++, x] = x)    //   increment n, mark x as visited and do a recursive call
    :                     // else:
      x                   //   stop recursion and return x
)(n = 0)                  // initial call to g() with n = x = 0

Pyth, 34 33 bytes
J]0@LJ.f}K+=G-eJZ*yZ|}GJ<G0~+JKQ1

Try it online!
Outputs the n first duplicates.
*waits for Jelly or one of the new stack languages to enter*

Rust, 160 bytes
|k|{let(mut a,mut r,mut n,mut i,mut v)=(vec!(0),0,1usize,0,0);while i<k{v=if v>n&&!a.contains(&(v-n)){v-n}else{v+n};if a.contains(&v){r=v;i+=1}a.push(v);n+=1}r}

Try it online!
Ungolfed:
|k| {
  let mut a=vec!(0);
  let mut r=0;
  let mut n=1usize;
  let mut i=0;
  let mut v=r;
  while i < k {
    v = if v > n && !a.contains(&(v-n)) {
      v - n
    } else {
      v + n
    };
    if a.contains(&v) {
      r = v;
      i += 1
    }
    a.push(v);
    n += 1
  }
  r
}

source: Stack Exchange

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

sort: votes


text:
Spoonerise words... in Finnish
This challenge is based on, and contains test cases from, a programming course I took at Aalto University. The material is used with permission.
Two and a half years ago there was a challenge about spoonerisms in English. However, in Finnish spoonerisms are much more complicated.
Spoonerisms in Finnish
In Finnish, the vowels are aeiouyäö and the consonants are bcdfghjklmnpqrstvwxz. (å is technically part of Finnish, but is not considered here.)
The most basic spoonerisms only take the first vowel of each word, and any consonants preceding them, and exchange the parts:
henri kontinen -> konri hentinen
tarja halonen -> harja talonen
frakki kontti -> kokki frantti
ovi kello -> kevi ollo
Long vowels
Some words contain two of the same consecutive vowel. In those cases, the vowel pair must be swapped with the other word's first vowel, shortening or lengthening vowels to keep the length same.
haamu kontti -> koomu hantti
kisko kaappi -> kasko kiippi
In the case of two different consecutive vowels this does not apply:
hauva kontti -> kouva hantti
puoskari kontti -> kooskari puntti
Three or more of the same consecutive letter will not appear in the input.
Vowel harmony
Finnish has this lovely thing called vowel harmony. Basically, it means that the back vowels aou and front vowels äöy should not appear in the same word.
When swapping front or back vowels into a word, all vowels of the other kind in the rest of the word should be changed to match the new beginning of the word (a <-> ä, o <-> ö, u <-> y):
köyhä kontti -> kouha köntti
hauva läähättää -> läyvä haahattaa
e and i are neutral and may appear with all other letters; swapping them into a word must not cause changes to the rest of the word.
Special cases
Vowel harmony does not apply to some words, including many loan words and compound words. These cases are not required to be handled "correctly".
Challenge
Given two words, output the words spoonerised.
The input words will only contain the characters a-z and äö. You may choose to use uppercase or lowercase, but your choice must be consistent between both words and input/output.
I/O may be done in any convenient format. (Words should be considered strings or arrays of characters.)
This is code-golf, so the shortest solution in bytes wins.
Test cases

henri kontinen -> konri hentinen
tarja halonen -> harja talonen
frakki kontti -> kokki frantti
ovi kello -> kevi ollo
haamu kontti -> koomu hantti
hauva kontti -> kouva hantti
puoskari kontti -> kooskari puntti
köyhä kontti -> kouha köntti
hauva läähättää -> läyvä haahattaa
frakki stressi -> strekki frassi
äyskäri kontti -> kouskari äntti
hattu sfääri -> sfätty haari
ovi silmä -> sivi olma
haamu prätkä -> präämy hatka
puoskari sfääri -> sfäöskäri puuri
puoskari äyskäri -> äöskäri puuskari
uimapuku hajoa -> haimapuku ujoa
ihme baletti -> bahme iletti
uhka lima -> lihka uma
osuma makkara -> masuma okkara
makkara fakta -> fakkara makta
lapsi laiva -> lapsi laiva
firma hajoa -> harma fijoa
dimensio bitti -> bimensio ditti
flamingo joustava -> jomingo flaustava
globaali latomo -> labaali glotomo
trilogia fakta -> falogia trikta
printti maksa -> mantti priksa
riisi bitti -> biisi ritti
sini riisi -> rini siisi
aarre nyrkki -> nyyrre arkki
laavu laki -> laavu laki
kliininen parveke -> paaninen klirveke
priimus kahvi -> kaamus prihvi
spriinen lasta -> laanen sprista
kliimaksi mammona -> maamaksi klimmona
hylky hupsu -> hulku hypsy
kehys fiksu -> fihys keksu
levy huhu -> huvu lehu
tiheys guru -> guheus tiru
nyrkki heiluri -> herkki nyilyri
latomo hajoa -> hatomo lajoa
prisma lehti -> lesma prihti
viina baletti -> baana viletti

Can we choose an input/output encoding? Also, is it acceptable to require that the input use combining diacritics instead of single characters?

@Doorknob You may choose any encoding, but the text will be in NFC (i.e. no combining characters). An encoding may be a case of compatibility with some languages, but NFC/NFD probably won't. (Anything that can handle U+0308 COMBINING DIAERESIS should handle U+00E4 LATIN SMALL LETTER A WITH DIAERESIS just fine.)

Since e and i are neutral, are fihus keksy, huvu lehy and lesmä prihti acceptable answers for kehys fiksu, levy huhu and prisma lehti respectively?

As a side comment: because of long vowels and vowel harmony, Finnish spoonerism is not an involutory function. For instance: puoskari äyskäri --> äöskäri puuskari --> puoskari ääskäri.

@Arnauld No. I'll update the question; neutral vowels should cause no change.

JavaScript (ES6), 196 175 bytes
Takes the words as two strings in currying syntax (a)(b). Returns an array of two arrays of characters.
a=>b=>[(e=/(.*?)([eiäaöoyu])(\2?)(.*)/,g=(a,[,c,v])=>[...c+v+(a[3]&&v)+a[4]].map(c=>(j=e.search(v),i=e.search(c))>9&j>9?e[i&~1|j&1]:c))(a=e.exec(a),b=e.exec(b),e+=e),g(b,a)]

Try it online!
How?
Each input word is passed through the regular expression e, which has 4 capturing groups:
e = /(.*?)([eiäaöoyu])(\2?)(.*)/    1: leading consonants (or empty)
     [ 1 ][     2    ][ 3 ][ 4]     2: first vowel
                                    3: doubled first vowel (or empty)
                                    4: all remaining characters

The helper function g() takes all capturing groups of the word to be updated as a[ ] and the first and second capturing groups of the other word as c and v.
We apply basic spoonerism and take care of long vowels with:
c + v + (a[3] && v) + a[4]

To apply vowel harmony, we first coerce the regular expression e to a string by adding it to itself, which gives:
e = "/(.*?)([eiäaöoyu])(\2?)(.*)//(.*?)([eiäaöoyu])(\2?)(.*)/"
     ^^^^^^^^^^^^^^^^
     0123456789ABCDEF (position as hexa)

Vowels that need to be harmonized have a position greater than 9 in the resulting string. Furthermore, the expression was arranged in such a way that front vowels äöy are located at even positions, while back vowels aou are located at odd positions, next to their counterparts.
Hence the following translation formula which is applied to each character c of the output word:
(j = e.search(v), i = e.search(c)) > 9 & j > 9 ? e[i & ~1 | j & 1] : c

Python 3, 235 231 225 221 217 215 bytes
import re
S=F,B='äöy','aou'
def f(a,b,C=1):
 e,r,Q,W=re.findall(fr' ?(.*?([ei{B+F}]))(\2)?(\w*)'*2,a+' '+b)[0][2:6]
 for c in zip(*S*(W in B)+(B,F)*(W in F)):r=r.replace(*c)
 return[Q+W*len(e)+r]+(C and f(b,a,[]))

Try it online!

Saved

-2 bytes, thanks to Lynn
-4 bytes, thanks to Zacharý

Save two bytes with: fr' ?(.*?([ei{B+F}]))(\2)?(\w*)'

Even better: you can change the second line to S='äöy','aou', then on the fifth line: (F,B) => S and (B,F) => S[::-1] (This is incompatible with the suggestion @Lynn gave)

Also, you can change the fourth line to e,r,Q,W=re.findall(r' ?(.*?([eiaouäöy]))(\2)?(\w*)'*2,a+' '+b)[0][2:5] for a few more bytes saved.

What I meant to say: 2nd line to S=F,B='aöy','aou', and then on the 4th line change (F,B) to S.

S=F,B=... should save a few bytes if you replace (F,B) with S

@Zacharý I see, thanks :)

Pyth, 84 bytes
.b++hY*W@N2JhtY2XW}JeA@DJc2"aouäöy"eNGH_Bmth:d:"^([^A*)([A)(\\2)*(.+)"\A"aeiouyäö]"4

Try it online. Test suite.
Proving that it's not that hard in golf languages. A stack-based language might do even better.
Pyth uses ISO-8859-1 by default, so äö are one byte each.
Explanation

Q, containing the input pair of words, is appended implicitly.
m: map each word d in the input to:

:"^([^A*)([A)(\\2)*(.+)"\A"aeiouyäö]": replace A with aeiouyäö] in the string to get the regex ^([^aeiouyäö]*)([aeiouyäö])(\2)*(.+).
:d: find all matches and return their capturing groups.
h: take the first (and only) match.
t: drop the first group containing the entire match.

_B: pair with reverse to get [[first, second], [second, first]].
.b: map each pair of words N, Y in that to:

hY: take the beginning consonants of the second word.
@N2: take the long first vowel of the first word, or None.
htY: take the first vowel of the second word.
J: save that in J.
*W…2: if there was a long vowel, duplicate the second word's vowel.
+: append that to the consonants.
c2"aouäöy": split aouäöy in two to get ["aou", "äöy"].
@DJ: sort the pair by intersection with the first vowel of the second word. This gets the half with the second word's first vowel in the end of the pair.
A: save the pair to G, H.
e: take the second half.
}J: see if the first vowel of the second word is in the second half.
XW…eNGH: if it was, map G to H in the suffix of the first word, otherwise keep the suffix as-is.
+: append the suffix.


text:
Draw a distribution diagram!
Challenge
You are given three integers as input - min_value, max_value, sample_size, that you can pass to your answer as either array or several parameters.
Your task is to output a diagram in any convenient format, that shows the frequency of numbers in the (min_value, max_value) range showing up when a random number in the (min_value, max_value) range is picked sample_size times. The random number sequence should be generated within your answer.
With large ranges and sample sizes, you're free to change the steps your diagram uses, as long as the representation remains accurate.
Example
With [1, 5, 10] as input:
o o o x o
x o x x x
x x x x x
1 2 3 4 5

With [1, 100, 15] as input (in steps of 10, so 00 shows 1-9, 10 shows 10-19, etc.):
xx oo oo xx oo xx oo oo oo oo
xx oo oo xx oo xx xx oo oo oo
xx xx oo xx xx xx xx xx xx oo
00 10 20 30 40 50 60 70 80 90

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

I guess we aren't allowed to output tables with a larger height than necessary? For your [1,5,10] example, can the height be 10? So column 4 would look like this (vertically top-to-bottom instead of horizontally left-to-right): oooooooxxx4.

You could do that, as long as it generates a readable output - I don't see why have that restriction.

Must we always show any zeros in the distribution picked? For example if we use input [1,5,10] and happen to pick ten fours is an output showing ten fours acceptable or should we also show we have picked zero threes etc? ("the frequency of numbers in the min_value-max_value range" seems to imply we must show zeros)

The zeros must be present.

What's to stop me from selecting a bin of width b-a? That's quite a convenient format...

@Giuseppe Correct me if I got you wrong, but you mean that, for example, for a 10 to 100 range, your diagram would start with 10 instead of 0? If so, yeah, that's valid.

Giuseppe means that for a range a...b, the diagram has a single bin that covers the entire range, resulting in a single bar with height equal to the number of samples.

Are we allowed to draw the histogram horizontally? Also, do the values have to be chosen uniformly in the range, or is any distribution where all outcomes are possible valid?

@Mnemonic about the distribution: The consensus is that it doesn't have to be uniform unless OP has specified it.

@Mnemonic horizontal drawing is allowed, and the distribution does not have to be uniform.

@Stewie yes, that's exactly what I meant.

Does the input have to be an array, or can it be separate numbers?

@LuisMendo It can be separate numbers, too. I'll add that to the challenge text.

Jelly, 13 bytes
Ṫɓr/;"xẊĠ>ʋ¥G

Uses a very convenient format:

Prints the values on the left axis
Uses 0 as the distribution pixels (like the xs) and 1 as the background pixels (like the os)
Uses as many horizontal spaces between "pixels" as there are characters in the maximum length number in the range (e.g. -23 is length 3, while 23 is length 2).

Try it online!
Note: If the input did not have to be an array it would be 11 bytes taking two arguments, [from, to] and sampleSize with just r/;"xẊĠ>ʋ¥G.

I think this may be taking the convenient formatting allowance just a little too far for 4 bytes:
Ṗ;1K
This is using the idea (which should be addressed) put forward by Giuseppe in the comments with a single bin identified with from and to separated by a space, another space representing the axis and and a single 1 representing the height of 100%.
...or even just Ṗ1 for 2 bytes!

Octave, 34 32 bytes
@(a,b,n)hist(--a+randi(b-a,n,1))

Doesn't work on TIO, but works on Octave-online.net.
It creates a histogram (bar chart) looking like this:

I'd say that counts as "Any convenient format".
If non-zero bins must be shown, then this can be solved in 38 bytes:
@(a,b,n)hist(--a+randi(b-a,n,1),a+1:b)

I asked for clarification about zero height bins - this fails to show them if they are strictly less than or strictly greater than all non-zero ones (f(1,5,1) would show the behaviour for example).

I feel obliged to point out that that is most certainly not a histogram, rather it is a bar chart (which aren't the same thing, at all).

@cairdcoinheringaahing skimming through those wiki pages I don't see what this wouldn't be a histogram. Care to explain why you think it's a bar chart instead?

@Imus a histogram is a special kind of bar chart. I reckon the point that caird coinheringaahing wants to make is that it only qualifies as a histogram if the bins are large enough to allow estimating the actual distribution of the random variable (which in this case is actually completely flat). For a sample size of only 10 it's not really possible to create a proper histogram.

R, 36 bytes
function(a,b,n)stem(sample(a:b,n,T))

Try it online!
Sigh. A stemplot.
The bane of existence for second year university students taking Introduction to Statistics for [This Specific Area of Study] from some professor who doesn't know what they're talking about but still think stemplots are a good idea because it's still in the 14th edition of the textbook they've been using since the 4th edition was published in 1983.

Charcoal, 25 bytes
≔…·θηθ≔Ｅζ‽θηＥθ№ηι↖←Ｅ⮌θ⮌Ｉι

Try it online! Explanation:
≔…·θηθ

Create an inclusive range of the distribution.
≔Ｅζ‽θη

Sample the range the desired number of times.
Ｅθ№ηι

Count and print the number of each of the range in the sample.
↖←Ｅ⮌θ⮌Ｉι

Print the labels.

Python 2, 115 bytes
from random import*
a,b,n=input()
r=range(a,b+1)
s=sample(r*n,n)
for v in r:print'%%0%dd'%len(`b`)%v,s.count(v)*'x'

Try it online!

Python 2, 164 bytes
column-based output.
from random import*
a,b,n=input()
r=range(a,b+1)
s=sample(r*n,n)
d=len(`b`)
while n:n-=1;print' '.join(d*'ox'[s.count(v)>n]for v in r)
for v in r:print'%%0%dd'%d%v,

Try it online!

Java 11, 184 168 bytes
(m,M,s)->{int a[]=new int[M],q=M;for(;s>0;q=M)if((q*=Math.random())>m-2){a[q]++;s--;}for(;m<=M;)System.out.printf("%0"+(M+"").length()+"d%s%n",m,"*".repeat(a[m++-1]));}

Try it online. (NOTE: String.repeat(int) is emulated as repeat(String,int) for the same byte-count, because Java 11 isn't on TIO yet.)
Explanation:
(m,M,s)->{                         // Method with three integer parameters & no return-type
                                   // (`m` = min_value; `M` = max_value; `s` = sample_size)
  int a[]=new int[M],              //  Integer-array, filled with `M` amount of 0s
      q=M;                         //  Temp integer for the random value, set to `M`
  for(;s>0;                        //  Loop as long as `s` isn't 0 yet:
      q=M)                         //    Reset `q` back to `M` after every iteration
    if((q*=Math.random())          //   Pick a random integer in the range [0, `M`)
       >m-2){                      //   If this random integer is larger than `m-2`:
      a[q]++;                      //    Increase the value at that this random index by 1
      s--;}                        //    And decrease `s` by 1
  for(;m<=M;)                      //  Loop in the range [`m`, `M`]
    System.out.printf(             //   Print with trailing new-line
      "%0"+(M+"").length()+"d%s%n",//   and leading zeros if necessary:
      m,                           //    The number
      "*".repeat(a[m++-1]));}      //    appended with "*" repeated the amount of times
                                   //    specified in the random array at index `m-1`

R, 52 bytes
function(a,b,n)table(cut(sample(a:b,n,T),a:(b+1)-1))

Try it online!
Returns a table of frequencies with names equal to the half-open intervals selected by cut, so (0,1], (1,2], (2,3], and so forth. Makes no effort to select more reasonable binning.

Wouldn't function(a,b,n)hist(sample(a:b,n,T)) satisfy the requirements of the question?

@ngm I guess...I wanted to do a text output since the challenge seemed to intimate that, but you are more than welcome to post it yourself

Ruby, 135 bytes, 117 bytes
d=->(m,n,s){p=(m..n);t=(1..s).map{rand(p)};p.map{|h|g=t.count(h);"#{h}-#{'x'*g}#{'o'*(t.map{|e|t.count(e)}.max-g)}"}}

Ungolfed:
d =-> (m,n,s) {
  p = (m..n)
  t = (1..s).map{rand(p)}
  p.map{ |h|
    g = t.count(h)
    "#{ h }-#{ 'x' * g }#{ 'o' * (t.map{|e| t.count(e) }.max - g) }"
  }
}

puts d.call(1,5,10)

Try it online! - in case anyone else wanted to test it as I did!

L.

Perl 5, 85 bytes
/ \d+/;$d[$`+rand$&-$`+1]++for 1..$';say$"x(length($&)-length),$_,"-"x$d[$_]for$`..$&

Try it online!
Produces similar output to @Neil's Charcoal answer.

JavaScript, 239
I'm sorry about this, but the variables were just named willy-nilly. Anyway, the question said any convenient format, so this function returns a sideways graph
f=>{x=Math;z=Array;q=_=>x.floor(x.random()*(f[1]-f[0]))+f[0];r=z(f[1]-f[0]).fill(0);z(f[2]).fill``.forEach(_=>r[q()-1]++);u=`${f[1]}`.length;return r.map((e,i)=>`${`${i}`.padEnd(u)}${" x".repeat(e)}`.padEnd(x.max(...r)*2+u," o")).join`\n`}

Japt -R, 14 bytes
Takes input in the order max, min, size. Outputs the chart horizontally.
õV
öW
Ë+QpVè¥D

Try it

Explanation
             :Implicit input of integers U=max_value, V=min_value & W=sample_size
õV           :Range [U,V]
\n           :Reassign to U
öW           :Get an array of W random elements from U
\n           :Reassign to V
Ë            :Map each integer D in U
 +           :  Append
  Q          :  Quotation mark
   p         :  Repeat
    Vè       :   Count the elements in V
      ¥D     :    That equal D
             :Implicitly join with newlines and output.

Pyth, 19 bytes
JmOK}FPQeQVK,N*/JNd

Try it here
Explanation
JmOK}FPQeQVK,N*/JNd
   K}FPQ             Get the inclusive range between the first two inputs as K.
JmO     eQ           Get <last input> random elements as J.
          VK         For each value in the range...
            ,N       ... output a list of the value...
              */JNd  ... and spaces equal to the count in J.


text:
Bot: Outsnake the game!
So, I wrote a simple Javascript game (as yet unnamed) and naturally I wanted to write an API so I could write a bot to play it for me, and naturally I wanted to let the PPCG community have a go for themselves.
It's a 'snake' game with the simple goal of collecting as many blue squares as possible while avoiding red squares or the edge of the board. It was initially controlled with a mouse.

Find the API edition of the game here: https://ajfaraday.github.io/game_name_here/api.html
Gameplay:

Type the code for your bot in the field under 'Your function': This will repeat automatically when you tell it to run.

Only in Javascript, sorry.
See restrictions, below.

You can try it step-wise by clicking 'step'.
I suggest you 'Run (fast)' once you have a workable function.
Click 'Reset' to try a fresh game.
Every 10 points will increase the points per blue square by 1.
Every 10 points will increase the red squares spawned by 1.
You can lose lives by:

Gobbling up a red square (Be aware that, while you lose a life, it also breaks down the wall. Sacrificing lives to break through walls is a legitimate tactic).
Attempting to leave the game board.
Running down the 'Timeout' clock of 20 seconds between blue squares.

You will not lose a life by 'stepping on your tail' in this version.
Every 100 points will earn an additional life.
Be aware that all coordinates are x, y starting in the top left corner. 0 indexed.

Restrictions:

There is no security in this code. Please do not hack the game!

Only use standard JS and the API methods described.
PLEASE! Don't change API.coord
You may not interact directly with Sketch, Cell or other entities defined within the game.

The competition

Please give your entry title a short name for your snake.
Include your JS code and any explanation you'd like to include.
The OP will copy/paste the code into the game, and run it 5 times (using 'Run (fast)').
The highest score achieved in those attempts is your score.
The OP will add your score to the answer, and to a leader board in the question.
You may submit more than one function.

Leader Board
+--------------------------+---------------------------------+----------+
| Username                 | Snake Name                      | Score    |
+--------------------------+---------------------------------+----------+
| orlp                     | Simple A*                       | 595      |
+--------------------------+---------------------------------+----------+

Rendering Issue
This rendering issue has now been fixed and deployed.

Please be aware that if you call more than one of the direction methods during your function, the snake will visit all of the squares and collect points or lose lives accordingly. However, due to a rendering issue, it will only display the ending position of your snake.

Be aware that the snake can not travel diagonally between walls without losing a life.

Responsible disclosure: This is written in pure Javascript, it contains no logging, analytics or other data gathering processes. It's hosted on github pages, typically a trusted home of code.
If you want to confirm this, or would prefer to develop your answer on a locally hosted instance, the code is available here:
https://github.com/ajfaraday/game_name_here

This is my first attempt at a competitive non-golf challenge, so I'm open to suggestions about how I could make it more suitable for this kind of situation.
Happy snaking!

"Running down the 'Timeout' clock of 20 seconds between blue squares." How fast is the snake going, so how many cells can be traveled in those 20 secs from blue to blue? (And I assume the run-fast button, also increases this countdown speed?)

@KevinCruijssen The fast run will call your method every 100 ms. 20 seconds is easily enough time to get from corner to corner. You can also call more than one direction method in your function to go faster (causing the rendering issue mentioned). The time-out is really an objective method of detecting when your snake has become stuck. If it's looping, or sat in one place for 20 seconds per life, it's safe to say that snake is not going to get the blue square.

@JoKing Good point, well made. I've finished it off.

I don't think this is [tag:king-of-the-hill] because as far as I can tell the submissions don't interact with each other.

@PeterTaylor Perhaps I've misunderstood the meaning of the tag, how would this kind of challenge be described?

[tag:code-challenge], maybe also [tag:puzzle-solver] although I think that's a stretch for this question.

Can I move multiple squares at a time like let[[x,y],[X,Y]]=[API.coord,API.goal];while(x<X)++x,API.right();while(x>X)--x,API.left();while(y<Y)++y,API.down();while(y>Y)--y,API.up()? (note that it doesn't perform well because it doesn't avoid red squares)

@user202729 Yes, you can, but it's not as good as it sounds. a: The snake visits all the intervening squares, so it will lose lives for walls it passes through. b: The rendering issue will kick in, and you won't be able to see the path of your snake (until I fix that issue). So go ahead, but be aware of the costs.

Can red blocks be placed under blue ones? I just faced an issue where a red block and a blue block were placed in the same coordinates

@LuisfelipeDejesusMunoz That's an issue with the app, on the board itself the blue goal wins out and that space is not also a red wall. It appears the API still adds it to the list of walls, tho. I'll fix it soon.

Was this sandboxed? If not, it should have been

@LuisfelipeDejesusMunoz I've fixed and deployed that issue, thank you for the feedback!

Another thing I notice is that sometimes blue dots doesn't appear. Check this out

@LuisfelipeDejesusMunoz Is it fixed in that position? Could you check if API.goal and API.coord are the same?

@AJFaraday sure, next time it happens I check. It just has happened 2 times

@LuisfelipeDejesusMunoz Thank you! You could also log issues with the github repo: https://github.com/ajfaraday/game_name_here

Do you know the leaderboard snippet? It helps automatize the process of making a leaderboard.

@user202729 interesting, I'll have a proper look at some point, it looks like it might need a bit of time to get used to it.

@user202729 You might want to check my earlier comment on that issue, travel time really isn't an issue (10 function calls a second means you have 200 steps time to get around), so multiple calls really doesn't create an advantage (it looks cool, tho). The timeout is basically a way to answer the question "has it had enough time to try and find a route?" more objective. It'll only really kick in when the snake is stuck, or looping, with or without multiple calls.

Some rendering bugs: (1) this should remove "wall" class.

Note: Have you considered the case where a blue/red square spawn on the square the snake is on?

@user202729 Thanks for the feedback! Could you please log the second one as an issue on the github repo? (It’ll take a bit more time than I can give it today, particularly with the two methods of input.)

Simple A* - Official score: 595
This solution uses simple A* pathfinding, with no long-term strategy - it always finds the optimal route towards just the next blue square.
var h = function(p, q) {
    // Manhattan distance.
    return Math.abs(p[0] - q[0]) + Math.abs(p[1] - q[1]);
};

var s = JSON.stringify;
var p = JSON.parse;
var walls = API.walls.map(s);
var start = API.coord;
var goal = API.goal;

var is_closed = {};
is_closed[s(start)] = 0;
var open = [s(start)];

var came_from = {};
var gs = {};
gs[s(start)] = 0;
var fs = {};
fs[s(start)] = h(start, goal);

var cur;
while (open.length) {
    var best;
    var bestf = Infinity;
    for (var i = 0; i < open.length; ++i) {
        if (fs[open[i]] < bestf) {
            bestf = fs[open[i]];
            best = i;
        }
    }

    cur = p(open.splice(best, 1)[0]);
    is_closed[s(cur)] = 1;

    if (s(cur) == s(goal)) break;

    for (var d of [[0, 1], [0, -1], [1, 0], [-1, 0]]) {
        var next = [cur[0] + d[0], cur[1] + d[1]];
        if (next[0] < 0 || next[0] >= API.width ||
            next[1] < 0 || next[1] >= API.height) {
            continue;
        }

        if (is_closed[s(next)]) continue;
        if (open.indexOf(s(next)) == -1) open.push(s(next));
        var is_wall = walls.indexOf(s(next)) > -1;
        var g = gs[s(cur)] + 1 + 10000 * is_wall;
        if (gs[s(next)] != undefined && g > gs[s(next)]) continue;

        came_from[s(next)] = cur;
        gs[s(next)] = g;
        fs[s(next)] = g + h(next, goal);
    }
}

var path = [cur];
while (came_from[s(cur)] != undefined) {
    cur = came_from[s(cur)];
    path.push(cur);
}

var c = path[path.length - 1];
var n = path[path.length - 2];
if (n[0] < c[0]) {
    API.left();
} else if (n[0] > c[0]) {
    API.right();
} else if (n[1] < c[1]) {
    API.up();
} else {
    API.down();
}

I love this! Particularly how it factors the number of red blocks into the decision making.

This will be pretty hard to beat since almost every pathfinding algorithm is created from this one. Nice solution +1

So this will always find the path that need to break least red squares?

@user202729 Yes it does, but only considering the current objective - not thinking ahead at all.

This will probably raise some runtime error when the blue square is at the position of the snake.

@user202729 If the blue square is at the position of the snake, we eat the blue square and it spawns somewhere else.

I don't think so. (implementation bug? I didn't test it but I believe there is a bug)

@user202729 It's not currently aware of the location of the current square. It should be easily fixable, tho.


text:
Consecutive 1-Bits are Incremented
Given a pattern (string or array format) of Bits :
[0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,1]
The tasks is to replace any number of consecutive 1-Bits with an ascending number sequence starting at 1.
Input

Pattern (can be received as an string or array) Example:

String: 1001011010110101001
Array: [1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1]

Output

Ascending number sequence (can be returned as an string or array) Example:

String: 1 0 0 1 0 1 2 0 1 0 1 2 0 1 0 1 0 0 1
Array: [1, 0, 0, 1, 0, 1, 2, 0, 1, 0, 1, 2, 0, 1, 0, 1, 0, 0, 1]

Rules

(only apply for strings) Input wont contain spaces between 1 and 0
Assume Input length > 0
(only apply for strings) Output is separated by space (use any other separator if you need as long as is not a number or a letter from the alphabet)

Example:
Given [0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,1]
Output [0,1,2,3,0,1,2,0,0,0,1,2,3,4,5,6]

--------------------------------------------------------------------------

Given 0110101111101011011111101011111111
Output 0 1 2 0 1 0 1 2 3 4 5 0 1 0 1 2 0 1 2 3 4 5 6 0 1 0 1 2 3 4 5 6 7 8

---------------------------------------------------------------------------

Given 11111111111101
Output 1 2 3 4 5 6 7 8 9 10 11 12 0 1

Winning criteria: Codegolf

05AB1E, 4 bytes
γ€ƶ˜

Try it online!
or as a Test Suit
Explanation
γ      # split input into groups of consecutive equal elements
 €ƶ    # multiply each number in each sublist by its 1-based index in the sublist
   ˜   # flatten

Oof, better than mine. I would've never thought of this.

I'm not 100% familiar with codegolf byte-counting rules (and googling only found this post which didn't come to a conclusion).  While your answer is 4 characters shouldn't it at least be 8 bytes (e.g., utf-16-be without BOM 03 B3 20 AC 01 B6 02 DC) or 9 bytes (utf-8: CE B3 E2 82 AC C6 B6 CB 9C) or 10 bytes (e.g., UTF-16 including the 2 byte BOM) in any non-toy encoding?  (Yes, one could construct a toy 8-bit encoding similar to iso-8859 encodings with these 4 symbols represented as 1-byte, but that seems like cheating.)

@drjimbob Yes, good question. The code can actually be converted to a binary file using the 05AB1E code page. For example, γ€ƶ˜ would be represented as 04 80 8F 98. The code page primarily exists to make writing code easier. To run this 4-byte file, you would need to run the interpreter with the --osabie flag.

Haskell, 15 bytes
scanl1$(*).succ

Try it online!
Explanation/Ungolfed
scanl1 iterates from left over a list using a function which takes the last result and the current element generating a new list with the results, leaving empty lists and singletons "unmodified".
(*).succ is the equivalent of \x y-> (x+1)*y
Using that function together with scanl1 only works because the increasing sequences (1,2,3,..) start with 1 and either have no preceding element (in which case it's the first element in the list which won't be "modified") or they have a leading 0.

Husk, 5 4 3 bytes
ṁ∫g

Try it online!
Explanation
ṁ∫g  -- full function, example input: [1,1,1,0,1]
  g  -- group: [[1,1],[0],[1]]
ṁ    -- map the following and concatenate result (example with [1,1,1])
 ∫   -- | cumulative sum: [1,2,3]
     -- : [1,2,3,0,1]

Edit history
-1 byte by using scanl1 over zipWith
-1 byte by porting Dennis's solution

Python 2, 36 bytes
c=0
for i in input():c=c*i+i;print c

Try it online!

APL (Dyalog Unicode), 5 bytes
⊥⍨¨,\

Try it online!
How it works
⊥⍨¨,\
   ,\  ⍝ Convert to lists of first n elements
⊥⍨¨    ⍝ Map "Count trailing ones" to each list

Nice usage of  the ⊥⍨ trick.

JavaScript (ES6), 22 bytes
Takes input as an array.
a=>a.map(s=n=>s=n*-~s)

Try it online!
The shorter a=>a.map(n=>a=n*-~a) (20 bytes) would unfortunately fail on [1] because of coercion of singleton arrays to the integer they're holding.

J, 4 bytes
#.~\

A port of Bubbler's APL solution
Try it online!
J, 8 bytes
i.&0@|.\

How?
It's simply the distance to the preceding 0
       \  for each prefix
     |.   reverse it
    @     and
i.&0      find the index of the first 0

Try it online!

Python 2, 39 38 bytes
-1 byte thanks to Erik the Outgolfer

i=1
for x in input():i*=x;print i;i+=1

Try it online!

I don't think you need the ,.

@EriktheOutgolfer it looks prettier this way c:

Sorry, but sometimes, in life, you have to make sacrifices.

RIP , you're not in the code anymore, but you will be forever in my heart

Jelly, 4 bytes
‘×¥\

Try it online!
‘×¥\
   \   Accumulate the input with:
  ¥   The dyad
‘      Increment the left element
 ×    Multiply by the second element (1 or 0)
       The result always begins with the first element unchanged

R, 46 31 bytes
function(a)sequence(rle(a)$l)*a

Try it online!
sequence, which "mainly exists in reverence to the very early history of R", is quite handy here.
function(a)                       # function, taking a vector as argument
                    rle(a)$l      # take the lengths of the run-length encoding
           sequence(        )     # and generate the list [1:x for x in lengths]
                             *a   # multiply by a to maintain 0s, and return

Jelly, 4 bytes
ŒgÄF

Try it online!
How it works
ŒgÄF  Main link. Argument: A (bit array)

Œg    Group adjacent, identical bits.
  Ä   Accumulate; take the cumulative sum of each chunk.
   F  Flatten.

With the group runs quick Erik had suggested this would be three bytes! (If I understood what it would do correctly)

@dylnan The problem is that it's hard to decide on a behavior for such a quick. :( That's why the quick is still in hiatus.

There could be multiple quicks for the main possible implementations

K (oK), 11 8 bytes
Solution:
{y*1+x}\

Try it online!
Explanation:
Iterate over the list. Increment accumulator, multiply by current item (which resets accumulator if item is 0):
{y*1+x}\ / the solution
{     }\ / iterate (\) over lambda function
     x   / accumulator
   1+    / add 1
 y*      / multiply by current item

RAD, 8 bytes
(⊢×1+⊣)⍂

Try it online!
How?

(⊢×1+⊣), if the right argument is 0, return 0, otherwise increment the left argument
⍂, LTR Scan ((A f B) f C instead of A f (B f C)) , apply this across the array

TIS, 68 + 33 = 101 bytes
Code (68 bytes):
@0
MOV UP ACC
SUB 47
MOV ACC ANY
@1
ADD 1
JRO UP
SUB ACC
MOV ACC ANY

Layout (33 bytes):
2 1 CC I0 ASCII - O0 NUMERIC - 32

Try it online!
Explanation:
|    Input 0    |    Input is given in ASCII (`0` is 48, `1` is 49)
+--------+------+
| Node 0 |      |    This node prepares the input data
+--------+      |
| MOV UP ACC    |    Read in a character
| SUB 47        |    Subtract 47 to map [48, 49] to [1, 2]
| MOV ACC ANY   |    Send the 1 or 2 to the next node
|               |    Implicitly wrap back to top of node
+--------+------+
| Node 1 |      |    This node does the incrementing/printing
+--------+      |
| ADD 1         |    Increment counter (starts at zero)
| JRO UP        |    Get value from above, and jump forward that many lines  (skip next line or not)
| SUB ACC       |    Reset counter to zero (if input was zero)
| MOV ACC ANY   |    Send the counter value downward to be printed
|               |    Implicitly wrap back to top of node
+---------------+
|   Output 0    |    Output is space-delimited numeric values

C (gcc), 45 44 38 bytes
f(a,i)int*a;{while(--i)*++a*=-~a[-1];}

Try it online!
Save one byte thanks to Toby Speight!
Save 6 bytes by using *= and a smarter while condition.

You can save 1 byte: *(a-1) → a[-1]

Welcome to PPCG! :)

Perl 6, 29 24 18 bytes
-6 bytes thanks to Sean!
*.map:{($+=1)*=$_}

Try it online!
The inner function could by ($+=1)*=*, but then the anonymous variable would persist across function calls. We get by this by wrapping it in an explicit code block.
Explanation:
*.map:               # Map the array to
      {($+=1)    }   # The anonymous variable incremented
             *=$_    # Multiplied by the element

I got the same basic approach down to 16 bytes: *.map(($+=1)*=*).  This solution has the proviso that the state variable $ persists across calls to the function, so if the final element passed to one call and the first element passed to the next call are both nonzero, then the counting will start with the wrong number.

@Sean, Yeah I remember struggling with that when I originally answered. Fortunately I've learned a way around that since then

You can knock one more byte off: *.map:{...}.

Jelly, 5 bytes
ṛȧ+ɗ\

Try it online!

Haskell, 19 bytes
scanl1$((*)=<<).(+)

Try it online!
Explanation:
The code is equivalent to scanl1(\b a->(b+a)*a), where b is the current bit and a is the accumulator. scanl1 takes a list, instantiates the first list element as accumulator, and folds over the list and collects the intermediate values in a new list.
Edit: BMO beat me by a few seconds and 4 bytes.

Japt, 7 6 5 bytes
åÏ*°X

Try it

Explanation
åÏ        :Cumulatively reduce
   °X     :  Increment the current total (initially 0)
  *       :  Multiply by the current element

Java 8, 55 48 bytes
a->{int p=0,i=0;for(int v:a)a[i++]=v<1?p=0:++p;}

Modifies the input-array instead of returning a new one to save bytes.
-7 bytes thanks to @TimSeguine.
Try it online.
Explanation:
a->{             // Method with integer-array parameter and no return-type
  int p=0,       //  Previous integer, starting at 0
      i=0;       //  Index-integer, starting at 0
  for(int v:a)   //  Loop over the values of the input-array:
    a[i++]=v<1?  //   If the current value is 0:
          p=0    //    Reset the previous integer to 0
         :       //   Else:
          ++p;}  //    Increase `p` by 1 first with `++p`
                 //    and set the current item to this new value of `p`

You can shave it down to 48: a->{int p=0,i=0;for(int b:a)a[i++]=b<1?p=0:++p;}

@TimSeguine Thanks! Now that I see it I can't believe I hadn't thought about it myself.

I was able to get rid of p, but it is the same size :( a->{int i=0;for(int v:a)a[i]+=v*i++<1?0:a[i-2];}

Gaia, 5 bytes
ẋ+⊣¦_

Try it online!
Explanation
ẋ+⊣¦_     Full program
ẋ         Split into chunks of equal adjacent values.
   ¦_     And for each chunk, flattening the result afterwards...
 +⊣       Reduce it cumulatively on + (addition); aka cumulative sums

Ugh, I thought SE code fonts were monospace....

They are monospace... There is a space missing on the first line.

Look at the edit. It is still misaligned.

You must be looking from a mobile device or something - It looks fine to me

@micsthepick I'm not...

Wolfram Language (Mathematica), 16 bytes
FoldList[+###2&]

Try it online!

PowerShell, 48 40 25 bytes
Thanks Mazzy for -8Thanks AdmBorkBork for -15
$args[0]|%{($i=$_*=++$i)}

Try it online!
Takes input as an array numbers. Uses the self-assigning, multiply trick other answers are using and updates everything with a very gross assignment. It then wraps this whole thing in parens to push it to output.

Given: 'Output ... can be returned as an string or array' ) I think param($p)$a=@();$p|%{$a+=$i=$_*=++$i};$a is enough. 40 bytes

25 bytes by using $args[0] and getting rid of $a -- Try it online!

Shakespeare, 365 bytes
I.Ajax,.Ford,.Act I:.Scene I:.[enter Ajax and Ford]Ajax:Open mind!Scene V:.Ford:Am I nicer than the sum of a big red old cute hard cat a big red old cute joy?Ford:If so,you is the sum of thyself a son!Ford:If not,you is zero!Ford:Open heart!Ajax:you is a big red old cute hard cat.Ajax:Speak mind!Ajax:Open mind!Ford:Am I nicer than zero?Ajax:If so, let us Scene V.

try it here
less golfed version
I.Ajax,.Ford,.
Act I:.
Scene I:.
[enter Ajax and Ford]
Ajax:Open mind!
Scene V:.
Ford:Am I nicer than the sum of a big red old cute hard cat a big red old cute joy?     <- smallest way to 48 (ascii "0") I could think of
Ford:If so,you is the sum of thyself a son!
Ford:If not,you is zero!
Ford:Open heart!
Ajax:you is a big red old cute hard cat.    <- get value of 32 or space
Ajax:Speak mind!                            <- then output it
Ajax:Open mind!
Ford:Am I nicer than zero?
Ajax:If so, let us Scene V.                 <- loop through inputs

280 bytes. Check out the SPL tips page for golfing tips.

C++, 47 bytes
[](int*a,int*b){for(int c=0;a!=b;)c=*a++*=1+c;}

A lambda that modifies an array in place, given start and end pointers.

Try it online! (requires Javascript)

Generic version at 55 bytes (this works for any container with elements of arithmetic type):
[](auto a,auto b){for(auto c=*a-*a;a!=b;)c=*a++*=1+c;};

Brachylog, 12 10 bytes
ḅ{a₀ᵇ+ᵐ}ᵐc

Try it online!
(-2 bytes thanks to @Fatalize.)
ḅ             % split input into "blocks" of equal value
 {     }ᵐ     % map this predicate on each such block:
  a₀ᵇ            % Find all prefixes (initial subsequences) of the block
                 %  Returns them in increasing order of length
     +ᵐ          % Sum the values in each subsequence
                 % This results in each block being replaced by its cumulative sum values
         c    % concatenate the results back into a single array

~c{≤₁a₀ᵇ+ᵐ}ᵐc is temptingly just out of reach at 13 bytes, but I haven't been able to find a shorter way of doing cumulative sum than the 5 byte a₀ᵇ+ᵐ.

ḅ{+ℕ₁⟦₁|}ᵐc is 1 byte shorter

ḅ{a₀ᵇ+ᵐ}ᵐc is 2 bytes shorter and should work, right?

@Fatalize Yep. I was an idiot, I even mentioned the cumulative sum idea for the alternate solution, but didn't apply it to this one. Thanks!

Pyth, 6 bytes
m=Z*hZ

Try it here!
How it works

m=Z*hZ – Full program. Q = the evaluated input.
m      – For each integer d in Q.
 =Z    – Assign the variable Z (preinitialised to 0) to...
   *hZ – (Z + 1) * d; (d is implicit at the end).

Wanted to get an answer in using regular expressions.  There is probably an easier solution which I leave as an exercise for the reader.
PowerShell Core, 86 bytes
Filter F{($_-split"(0)(\B|\b)"|?{$_-ne''}|%{$_-replace'(1+)',(1..$_.Length)})-join' '}

Try it online!

C (gcc), 57 52 51 bytes
f(a,l,c,i)int*a;{for(c=i=0;i<l;)a[i++]=c=a[i]*-~c;}

Port of Arnauld's JavaScript answer, modifies the array in-place. Try it online here.

Wouldn't it be more accurate to say this is K&R C?

Possibly, but that would be true of a lot of answers. I'm no expert, but it's entirely possible it's not even valid K&R C. The thing is, we don't really care about the language standards on this site. If gcc allows you to mix K&R C with more modern stuff, then it's valid C for the purposes of golfing because gcc will compile it. See also: https://codegolf.stackexchange.com/questions/2203/tips-for-golfing-in-c

I didn't realize until searching just now that C11 still supports the old identifier list function syntax, so nevermind. But your point holds regardless.

Suggest f(a,l,c)int*a;{for(c=0;l--;)c=*a++*=c+1;}

QBasic, 60 bytes
INPUT s$
FOR i=1TO LEN(s$)
b=MID$(s$,i)>="1
v=-b*v-b
?v
NEXT

Takes the input as a string; gives the output as numbers separated by newlines.
Explanation
We read the string s$ and loop i from 1 up to its length.
MID$(s$,i) gets the substring from character i (1-indexed) to the end of the string. If this starts with a 1, it will be lexicographically >= the string "1"; if it starts with a 0, it will not be. So b gets 0 if the character at index i is 0, or -1 if the character is 1.
Next, we update the current value v. If we just read a 0, we want v to become 0; otherwise, we want to increment v by one. In other words, v = (-b) * (v+1); simplifying the math gives the shorter expression seen in the code. Finally, we print v and loop.

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

Try it online!
Explanation:
([]){  For each element in the input
    {}
    <>(())<>  Push a one to the other stack
    { If the element is one,
       {}<>({}({}))(<>)  Add the one to a copy of the previous number in the series
    }{}  Pop the element
([])}  End loop
{}<>   Pop extra zero
{({}[()]<>)<>}<>   And reverse the output stack, subtracting one from each element

Retina, 14 bytes
rv`0|(1)+
$#1¶

Try it online!

Java,  65 bytes
void a(int[]q){for(int i=1;i<q.length;i++)q[i]+=q[i]>0?q[i-1]:0;}

MATL, 11  10 bytes
0w"@+@*t]x

Try it online!
(-1 byte thanks to Giuseppe)
The obvious "accumulate y(x+y) over the array" approach.
16 bytes
n:G~f!-tO<YYw(X<

Try it online!
Longer, more matrix-y approach: get the overall index, broadcast-subtract the indices of all zeros, and take the difference from the index of the nearest zero.

Do you need D? I removed it and it seems to work fine without it.

I had 12 bytes porting my R answer with 4#Y'"@:v!]G*

Indeed I don't, the values will just accumulate in the stack in order. Thanks! (And your R answer's RLE approach is what I too started with, but soon got confused and lost. :)

Vyxal, 4 bytes
Ġv¦f

Try it Online!
-6 thanks to Lyxal.
Ġ    # Group consecutive identical elements
 v¦  # Take the cumulative sum of each
   f # Flatten the result

there is

Zig, 65 bytes
fn f(b:[]u8)[]u8{for(b)|_,i|{if(i>0)b[i]+=b[i-1]*b[i];}return b;}

Expanded version
fn f(b:[]u8) []u8 {
    // Foreach loop where only index is used.
    for(b) |_,i| {
        // First value is always going to be 0 or 1,
        if(i > 0)
            // b[1] will either be 0 or 1,
            // so this is basically an if statement
            // that we can use to reset the count.
            b[i] += b[i-1] * b[i];
    }
    return b;
 }

I would add a Try it online!, but their compiler seems to lack some crucial language features. (Language still being in development and all that)
And I am not going to attempt to make it compatible through trial and error.
But you can copy paste this into Zig playground (Confirmed to work as of writing this post)
const std = @import("std");

fn f(b:[]u8)[]u8{for(b)|_,i|{if(i>0)b[i]+=b[i-1]*b[i];}return b;}

pub fn main() anyerror!void {
    var bits = [_]u8{0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,1};
    var array = f(bits[0..]);

    try std.io.getStdOut().writer().print("{any}\n", .{array});
}

Welcome to Code Golf, and nice first answer!

Thunno, \$ 6 \log_{256}(96) \approx \$ 4.94 bytes
zy.z(S

Attempt This Online!
Explanation
zy      # Group by consecutive
  .     # Apply to each:
   z(   #  Cumulative sums
     S  # Flatten

K (ngn/k), 11 9 bytes
(*/+\|,)\

Try it online!
-2 bytes thanks to ovs

Shorter with a lambda but tacit is fun.

Isn't 1+\/ just +\ ?

That seems to hang for me.  I that turns it into converge on sum scan which is monadic.

(*/+\|,)\

Oh, sorry.  I misread what you wrote.

Jelly, 6 bytes
ŒgJ€F×

Try it online!

Retina 0.8.2, 15 bytes
.(?<=(1*))
$.1

Try it online! Link includes test cases. Alternative version, also 15 bytes:
.(?<=(1)*)
$#1

Try it online! Link includes test cases Explanation:
.

Match the 0s and 1s.
(?<=(1*))
(?<=(1)*)

Count the number of 1s from the current digit backwards. The first one counts by capturing the run of 1s as a subtring, while the second one counts the number of times the 1 was captured.
$.1
$#1

Replace the digit with the number of 1s, either via the length of the capture or by the number of captures as appropriate.

Pyth, 9 bytes
t.u*YhNQZ

Verify all the test cases
t.u*YhNQZ   Implicit: Q=eval(input())

 .u    QZ   Cumulative reduce over Q, starting value 0
     hN       Increment the current value
   *Y         Multiply by the next value
t           Remove 1st element of list, implicit print

racket, 107 bytes
(λ(i)(let c((x i)(z 0))(if(empty? x)'()(if(= (car x)1)(cons(+ 1 z)(c(cdr x)(+ 1 z)))(cons 0(c(cdr x)0))))))

Possible space save in = (.

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

Try it online!
Readable version:
(<>)<>
([])

{

    {}

    {
        {}<>(({})())<>
    }

    ([])
    {

        {}(<>)<>
    }

    {}

    ([])

}{}<>

([])

{
    {}({}<>)<>([])
}<>{}

C (gcc), 52 51 bytes
Thanks to ceilingcat for the suggestion.
c;f(char*i){for(;*i;printf("%d ",c=~c*(48-*i++)));}

Try it online!

Julia 0.6, 28 bytes
t->(x=0;[(x=(x+y)y)for y=t])

Try it online!

C++, 46 45 41 bytes
Generic lambda, any int container.
[](auto&a){int p=0;for(int&i:a)p=i*=p+i;}

Saved a byte with the *= operator, saved 4 bytes by removing unneeded braces and parenthesis.
Note: The p+i part can be replaced with p+1 or ++p, I'm not sure why I did p+i but it wouldn't save any bytes to change it.
Old:
[](auto&a){int p=0;for(int&i:a){p=i=i*(p+i);}}

Arturo, 22 bytes
$=>[0map&=>[<=&*<=1+]]

Try it
$=>[        ; a function, assign input to &
    0       ; push 0
    map&=>[ ; map over input, assign current elt to &
        1+  ; increment tos
        <=  ; dup
        &*  ; multiply by current elt
        <=  ; dup
    ]       ; end map
]           ; end function

TI-Basic, 25 bytes
Prompt B
For(I,1,dim(⁻B
⁻B(I)(Ans+1
Disp Ans
End

Input is taken as a list. Output is as numbers separated by newlines.

Nibbles, 2.5 bytes (5 nibbles)
=\$+*

=\$+*       # full function
=\$+*$@$    # (with implicit arguments shown):
=\          # scan from left over
  $         # input
            # with function:
   +        #   add
       $    #   each element
            #   to
    *       #   product of
     $      #   each element
            #   and
      @     #   result so far

BQN, 6 bytes
(×+⊢)`

Try it at BQN online!
Explanation
Port of Dominic van Essen's Nibbles answer.
(×+⊢)`
(    )`  Left scan on this function:
  +       Add
   ⊢      each element to
 ×        the product of the element and the previous intermediate value

KamilaLisp v0.2, 14 (APL SBCS)
$(⍀.←[+ * #1])

Equivalent to $(scanl1[+ * #1]).

Thunno 2 S, 4 bytes
ġıż×

Attempt This Online!
Explanation
ġıż×  # Implicit input
ġ     # Group consecutive items
 ı    # Map over this list of lists:
  ż   #  Push [1..length] without popping
   ×  #  Multiply the two lists elementwise
      # Implicit output, summed (flattened)

Python 2, 52 46 bytes
f=lambda x,y=1:x and[y*x[0]]+f(x[1:],y*x[0]+1)

Saved 6 bytes thanks to Jo King and Rod!

Perl 5 -p, 22 20 bytes
-2 bytes thanks to @DomHastings
s/./$i=$&*++$i.$"/ge

Try it online!
Method:
Replace each character with itself multiplied by the incremented value of $i, then store that value back in $i.  Thus, $i starts at 0 (undef) and gets reset to 0 every time the character in the bit string is a 0.
Finally, append a space to the result of the above step to make the output format correct.

Nice again! You can save 2 bytes by dropping the ( ) as the trailing space is just ignored!

@Abigail In some languages, that may be the case, but in Perl, ++ has a higher precedence than either = or * and will always execute first.

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

Golfed Try it online!
a=>{for(int i=1;i<a.Length;i++)if(a[i-1]>0&a[i]>0)a[i]=a[i-1]+1;return a;};

Ungolfed
a => {
    for( int i = 1; i < a.Length; i++ )
        if( a[ i - 1 ] > 0 & a[ i ] > 0 )
            a[ i ] = a[ i - 1 ] + 1;

    return a;
};

Full code
using System;

namespace Namespace {
    class Program {
        static void Main( String[] args ) {
            Func<Int32[], Int32[]> f = a => {
                for( int i = 1; i < a.Length; i++ )
                    if( a[ i - 1 ] > 0 & a[ i ] > 0 )
                        a[ i ] = a[ i - 1 ] + 1;

                return a;
            };

            List<Int32[]>
                testCases = new List<Int32[]>() {
                    new Int32[] { 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 },
                    new Int32[] { 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
                    new Int32[] { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 },
                };

            foreach( Int32[] testCase in testCases ) {
                Console.WriteLine( $"{{ {String.Join(", ", testCase)} }}\n{f( testCase )}" );
            }

            Console.ReadLine();
        }
    }
}

Releases

v1.0 - 75 bytes - Initial solution.

Notes

None

Since you are already modifying the input, you can change the Func into an Action and drop the return a;. Also, with Java/C# lambdas you don't have to include trailing semi-colon after the function. Your current code becomes: a=>{for(int i=1;i<a.Length;i++)if(a[i-1]>0&a[i]>0)a[i]=a[i-1]+1;} (65 bytes), but you could golf it further (by creating a port of my Java answer) to: a=>{for(int p=0,i=0;i<a.Length;)a[i]=a[i++]<1?p=0:++p;} (55 bytes).

Dodos, 152 bytes
	_ b _ F >
b
	dab
t
	dot
(
	t b
	t
X
	X dip
<
	b X (
/
	<
	< b
0
	t 0 b
>

	0
.
	dip <
	< b
	t b
x
	x .
H
	b b x >
	b
G
	t H /
	b b
F
	<
	F G
_
	_ b
	<

Try it online!

Python 2.7, 217 Bytes
def f(d):
    c = 0
    r = []
    for e in d:
        if e == 1:
            r.append(1 + c)
            c += 1
        else:
            c = 0
            r.append(0)
    return r

I'm new so.

Welcome to the site. You can save bytes here by removing whitespace around operators, and using ; instead of newlines for indentation. You can also save bytes by using += instead of append.  Lastly instead of appending 1+c and then incrementing c you can increment c first and then append it. Here's a link with all those edits made.  Anyway hope you have fun here!

Kotlin, 73 bytes
var i=0
readLine()?.forEach{(it-48).toInt().let{c->i=i*c+c;print("$i ")}}

Try it online!

Lua, 63 54 bytes
function f(j)for i=2,#j do j[i]=j[i]*(j[i-1]+1)end end
Written by Jo King.
Try it online!

Explanation
function f(j) -- declares the function 'f' that will receive a variable 'j' (we know it's a table)
  for i=2,#j do -- from 2 to the number of elements in j
    j[i]=j[i]*(j[i-1]+1) -- change the current element of j to itself
              (j[i-1]+1) -- multiplied by the one before it plus one
  end
end

Original (invalid) in expanded form:
for i=2,#input do -- a loop that goes from 2 to the number of elements in the input table
  if input[i] == 0 then -- if the element at 'i' is 0
    input[i] = 0 -- then keep it as 0
  else
    input[i] = input[i-1]+1 -- change it to the element that comes before + 1
  end
end

Feel free to ask or suggest anything!

The input can't be a pre-declared variable, otherwise this is an incomplete snippet. Your submission can be either a full program taking input from STDIN or equivalent, or a function.

Here's a 54 byte function that modifies its argument in-place. For more standards, you can check out the Standard I/O methods for submissions

@JoKing oh thank you for the correction, now I think I got how it works. But what do I do? Remove the post or edit it with your code?

You can use my code, sure

C++ (gcc), 37 bytes
[](auto&a){for(int&i:a)i*=*(&i-1)+1;}

Try it online!

A lambda function which works with any int container supporting range-based for loops.

Z80Golf, 12 bytes
00000000: cd03 8030 0176 b928 0180 47d5            ...0.v.(..G.

Try it online! or Run test cases.
I/O format is byte values.
Disassembly
start:
  call $8003    ; cd 03 80 ; a = getchar()
  jr nc, skip   ; 30 01    ; if not EOF, skip
  halt          ; 76       ; terminate program
skip:
  cp c          ; b9       ; compare a and 0
  jr z, skip2   ; 28 01    ; if a == 0, skip
  add b         ; 80       ; a += b
skip2:
  ld b, a       ; 47       ; b = a
  push de       ; d5       ; call putchar with return address 0

The final push de pushes the address 0 to the stack, so when putchar returns, PC goes back to the start of the program.

C# (.NET Core), 74 70 bytes
a=>{int i=0;var s="";foreach(var c in a)s+=(i=c/49*-~i)+" ";return s;}

Try it online!
-4 bytes: changed format of foreach loop (thanks to recursive)
Ungolfed:
a => {
    int i = 0;              // initialize i to 0
    var s = "";             // initialize s
    foreach(var c in a)     // for each character in a
        s +=                    // append to s:
            ( i =                   // i, where i is:
                c / 49                  // ascii representation of c divided by 49 (identifies 0 or 1)
                    * -~i )             // multiplied by the negative bitwise complement of i (essentially, one more than current i)
            + " ";                      // a space
    return s;               // output s to console
}

Found 4 bytes to shave. https://tio.run/##NU1BCsIwELz3FUtOibXagheJKYjgSS968BzSVBdqCtm0IKV@vaZIB4aZWZYZQ5lpvZ06QveE@4eCfUswjSaCIwwJBR3QwLlz5kDBx6f1X0qo1aRVOaALgCqXvfZAijFZxz5tXnw@GEAHWlCqOCqz3e1X2RdFyoBJb0PnHZAcJ7nM9C1WcNXouBgSADi1jtrGbh4eg@U1X/LN6uqCznIhhEzGccqLoojM89lE/AA

Clojure, 62 bytes
#(map-indexed(fn[i n](*(+(.indexOf(reverse(take i %))0)1)n))%)

Use as follows:
(println #(...) [0 1 1 1 0 1])

where #(...) is the answer (anonymous function).

Forth (gforth), 48 bytes
: f 0 tuck do 1+ over i + c@ '0 - * dup . loop ;

Try it online!
Code Explanation
: f                \ start a new word definition
  0 tuck           \ set up a loop and also stick a 0 on the stack to use as a counter
  do               \ loop from 0 to string-length - 1
    1+             \ add 1 to counter
    over i +       \ get the address of the next character
    c@             \ get the ascii value for that character
    '0 -           \ subtract ascii 0 (48) from the value
    *              \ multiply counter by the result (change counter to 0 if char is '0')
    dup .          \ print the current sequence
  loop             \ end the loop
;                  \ end word definition

Google Sheets, 37 bytes
=SCAN(,array,LAMBDA(a,c,--IF(c,a+1)))

Nekomata, 4 bytes
ĉᵐ∫j

Attempt This Online!
A port of @Dennis's Jelly answer.
ĉᵐ∫j
ĉ       Split into runs of equal elements
 ᵐ      Map over each run:
  ∫         Cumsum
   j    Join

PHP, 41 bytes
while(~$c=$argv[++$i])echo$k=++$k*$c," ";

takes input from command line arguments; prints string.
Run with -r.

Scheme, 91 61 bytes
(lambda(l)(define x 0)(map(lambda(n)(set! x(* n(+ 1 x)))x)l))

Try it online!

Uiua, 6 bytes
\(×+1)

Try it!
\(×+1)
\(   )  # scan by
   +1   # increment
  ×     # multiply


text:
Hardcoding the Cops and Robbers (Cops)
This is a cops-and-robbers challenge. The robbers' thread is here.
An interesting question to think about is the following:

If I have a sequence of numbers how many of them do I have to provide before it is clear what sequence I am talking about?

For example if I want to talk about the positive integers in order starting from \$1\$, I could say \$1,2,3, \dots\$, but is that really enough?
I have one way of answering this question, and being a code-golfer it involves code-golf.  You have provided enough terms of a sequence if the shortest code that produces those terms produces all the terms of the sequence.  If we think about this in terms of code-golf, this would mean you have provided enough test cases such that the shortest code that passes the test-cases does the desired task.
Challenge
This challenge is a cops-and-robbers challenge.  In which cops will be presenting test-cases and robbers will have to find a shorter way to spoof the test-cases other than the intended sequence. Cops will present the following things:

A piece of code that takes a non-negative integer as input and produces an integer as output.    This code will define your sequence. Your code does not need to support 0 as an input, opting to instead take 1 as the smallest input.  It should be clear if this is the case in your answer.
Any relevant platform or language requirements that might affect the output, for example the size of longint.
A number \$n\$, along with the first \$n\$ terms of the sequence as calculated by the code.  These will act as "test-cases".

You are encouraged to explain what your sequence does and link OEIS if it exists, however it is your code that defines the sequence not the description.
Robbers will be finding a program in the same language that is shorter than the one presented and passes all the test cases (produces the same output for the first \$n\$ inputs as the cop's code). The robber's code must also differ in output from the cop's program for some number larger than \$n\$.
Cops must be able to crack their own answers before submitting them.
After one week a cop may reveal their crack and mark their answer as Safe.  Answers marked as such can no longer be cracked.
Scoring
Cops answers will be scored by the number of bytes with fewer bytes being better. Cracked answers score an infinite score.

It's clear there are ways to un-mathematically crack a problem, like just printing all the test cases, but that issue is conditional on the cops' provided cases. Should there be a rule about that? Is there a restriction against computability of the sequences or anything from Ramsey Theory? (i.e. do you need to be able to crack on your machine?)

@theReallyumdub the question stipulates you must be able to crack your own submission.

@CatWizard Thanks, I went ahead and that's already on an obvious meta post, it impedes some of these guys apparently. So it isn't in the spirit of the tag to make a crack take over an hour to compute or something

http://spikedmath.com/062.html

Is there a "although theorically your solution must work for all numbers in practice it only need to work for ..." condition?

@user202729 No there is not.  You're sequence is defined simply by how your code works so if it diverges from whatever sequence you might intend to model because of the innacurracy of floating point numbers than that is that.  The sequence is what your code outputs.

Can the code use unary for I/O, or does it have to be decimal?

@DLosc I'm just going to defer to the standard methods of IO.  I believe that unary is allowed in some cases.

cQuents, 4 bytes (Cracked)
"::$

Try it online!
Here are eight (n=8) cases:
1 1
2 12
3 123
4 1234
5 12345
6 123456
7 1234567
8 12345678

Code explanation:
"      Stringify sequence (join on "", remove it and see what happens)
 ::    Given input n, output all items in the sequence up to and including n
   $   Each item in the sequence equals the index

So the sequence is 1,2,3,4,5 ..., it is joined on "" so it becomes 12345 ..., and :: means that it prints up to the input.

Cracked.

Python 3, 66 57 bytes (Cracked)
cracked by xnor
also cracked by Cat Wizard before an edit
def f(n):x=n/10-2;return int(x*60-x**3*10+x**5/2-x**7/84)

Try it online!
Hello! Here is a sequence to crack for \$n=40\$.
It gives these first 40 elements with 0-indexing, it's not an OEIS sequence
[-54, -56, -58, -59, -59, -59, -59, -57, -55, -53, -50, -46, -43, -38, -33, -28, -23, -17, -11, -5, 0, 5, 11, 17, 23, 28, 33, 38, 43, 46, 50, 53, 55, 57, 59, 59, 59, 59, 58, 56]

I forgot to remove the whitespace, I'm not an expert golfer yet :p Do you mind if I edit to fix that ?

Sure go ahead.  I'll remove my crack.

Cracked

Python 2, 44 bytes (cracked)
f=lambda n,i=1,p=1:n and-~f(n-p%i,i+1,p*i*i)

Try it online!
The prime numbers. What sequence could be purer? Or more overdone? Your goal is to produce the first 50 primes for n=1 to n=50.
The code is a Wilson's Theorem generator copied exactly from this tip.
The different values for the alternative sequence are not due to machine limitations like overflows and precision. No 3rd party libraries.

Cracked by Arnauld, @PoonLevi, and Mr. Xcoder.

Pretty sure you did not mean to get cracked by this; maybe specify "Python (with no 3rd party libraries)" or "Python (with no imports)" or something?

@JonathanAllan Thanks, I edited that there's no 3rd party libraries.

I haven't been able to crack this yet (my best attempt at the moment is 47 bytes or so), but I think there's something interesting to note about those particular primes. For each $p_i$, with $i\in[1, 50]\cap \mathbb{N}$, this holds: $2^{p_i}\equiv 2 (\text{mod } p_i)$. At the same time, this isn't true for any number which is not prime (in the range noted above), but it does so for higher values. I'm leaving this idea here so that others may try their hand at a crack using the mentioned technique, and perhaps obtain a better score :)

@Mr.Xcoder Here is my best attempt based on your proposed method. It successfully diverges at N=69, returning 341 (the first Fermat pseudoprime to base 2, or first Poulet number) but it also fails for N=1. I doubt I can fix it on my own, so I thought I'd better share what I have. (My best fix is 46 bytes...)

@Arnauld I found a 44-byte solution using this method. I can't seem to go any further. Maybe someone else will be able to figure this out.

@PoonLevi Nicely done! By rearranging it some more, here is a 43-byte crack.

Now, since it was a team work, I'm not sure how the crack should be posted.

I went ahead and posted this crack.

Wolfram Language (Mathematica), 39 34 bytes (Safe)
Check[{1,9,7}[[#]],18+Boole[#>9]]&

Try it online!
Looks simple, solution should be hard.
1-indexed and \$n = 99\$. This sequence is not available on the OEIS.
{1, 9, 7, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19}

This above list is equal to:
Join[{1, 9, 7}, Table[18, 6], Table[19, 90]]

Here's a template for checking your solution: Try it online!
Intended Crack

 The catch here is that the output increases by 1 when the number of digit increases by 1, with the exception for the first three terms; the intended solution has something to do with string conversion.

 Hence, reading the documentation on Converting between Expressions & String, one could find the function SpokenString.

 The solution is simply the length of the spoken-string version of the expression x^n for various inputs: StringLength@SpokenString[x^#]&

Haskell, 29 bytes (Cracked: 1,2)
a n=n*ceiling(realToFrac n/2)

Try it online!
This is A093005: \$ a(n)=n\lceil \frac{n}{2} \rceil\$.
Test cases for \$0 \leq n \leq 20 \$, that is map a [0..20]:
[0,1,2,6,8,15,18,28,32,45,50,66,72,91,98,120,128,153,162,190,200]

Intended solution (20 bytes)
b n=sum$n<$show(3^n)

Try it online! Differs at \$ n=23 \$, with \$ a(23) = 276 \$ and \$ b(23) = 253\$.
This function is equivalent to \$b(n) = n\ len(3^n) = n \lceil log_{10}(1+3^n)\rceil\$. Thanks to the ceiling, both functions overlap for integer arguments in the range from \$0\$ to \$22\$:
source

cracked

@Laikoni, if the intended crack is shorter, then someone else could potentially claim the robber from BMO.

@fəˈnɛtɪk Thanks, I was not aware of this rule.

@BMO re-cracked

Given that @ØrjanJohansen was able to beat 20 bytes and I failed to find the other solution, you could reveal it now (I'm really interested) :)

@BMO There you go :)

APL (Dyalog Unicode), 17 15 bytes, safe
⌈∊∘1 5+.633*5-⊢

Try it online!
The first 13 terms (1-based) are:
2 1 1 1 2 2 3 4 7 10 16 25 39

Hint: The intended solution uses one of the least used built-in functions.

The intended code is the following:
APL (Dyalog Unicode), 10 bytes
⌊(2*⍳)⌹⌽∘⍳

Try it online!

cracked

@ngn Updated the cop submission :)

JavaScript (ES6), 12 bytes (Cracked)
This one is rather easy.
n=>n*(8*n+1)

Try it online!
This is A139275:
$$a(n) = n(8n+1)$$
Your code must support \$0\le n<9\$:
$$0, 9, 34, 75, 132, 205, 294, 399, 520$$
And as per the challenge rules, it must diverge beyond.

n=>8*n*n+n differs for n=94906273, is this a valid crack?

@ngn It looks valid to me according to the challenge rules, but maybe you should ask the OP whether loss of precision does count as a valid divergence? The intended crack differs for n=9, though.

@CatWizard ^

I'd say it is a valid crack.

cracked (| instead of +)

Jelly, 6 bytes, Safe!
<4+ạ2ȯ

This defines a zero-indexed sequence where:
$$  a(n) =
\begin{cases}
1  & n<3 \\
2 & n=3 \\
n-2 & n>3
\end{cases}$$
As such the first sixteen values \$a(0)\cdots a(15)\$ are 1,1,1,2,2,3,4,5,6,7,8,9,10,11,12,13
Try it online! (here is a single value version)
This is not currently in the OEIS (although A34138 will work as a crack if short enough)
Intended Crack

 The sequence above agrees with the count of decimal digits of the first \$16\$ terms of A062569, the sum of the divisors of the factorial of \$n\$ (also zero-indexed).
 The \$17^{\text{th}}\$ term of A062569, however, is \$107004539285280\$ which has \$15\$ digits, not \$14=a(16)\$.

 The required code is five bytes in Jelly, !ÆsDL.

><>, 276 bytes (Cracked)
1$1-:?!v$:      1[0$          >:?!va2[$:{:@%:{$-{,]v
       >$n; v              <  ^   >~{]02.1+1+ffr+1r<
 :}[r]{  [01>:{*@@+$a*l2=?!^~]+ff+9+1g"3"=?v"3"ff+9+1pf0.
 :}[l01-$>    $:0(?v$@$:@@:@)?v@@1-$}v     >"2"ff+9+1p00.
>.       ^-1l v!?} <  .4a}$@@$<   .4a<
^26{]r0[}:{]~{<

Try it online! Call this one with -v n to get the n-th element (1-indexed)
1$1-:?!;$::n84*o1[0$          >:?!va2[$:{:@%:{$-{,]v
            v              <  ^   >~{]02.1+1+ffr+1r<
 :}[r]{  [01>:{*@@+$a*l2=?!^~]+ff+9+1g"3"=?v"3"ff+9+1pf0.
 :}[l01-$>    $:0(?v$@$:@@:@)?v@@1-$}v     >"2"ff+9+1p00.
>.       ^-1l v!?} <  .4a}$@@$<   .4a<
^26{]r0[}:{]~{<

Try it online! Call with -v n to get a list of n-1 elements starting at 1
Online Fish Interpreter
A long and complex one, this is OEIS A004000.

Let a(n) = k, form m by Reversing the digits of k, Add m to k Then
  Sort the digits of the sum into increasing order to get a(n+1).
Example: 668 -> 668 + 866 = 1534 -> 1345.

Because the code in ><> is quite long, the challenge is to crack it for \$n = 34\$.
These 34 elements make a total of 290 bytes, just a bit too much to hardcode the result ;)
Here are the 34 first elements 1-indexed
1 2 4 8 16 77 145 668 1345 6677 13444 55778 133345 666677 1333444 5567777 12333445 66666677 133333444 556667777 1233334444 5566667777 12333334444 55666667777 123333334444 556666667777 1233333334444 5566666667777 12333333334444 55666666667777 123333333334444 556666666667777 1233333333334444 5566666666667777

How does one run the program to yield a single output for a given n (as required by the question)?

As there are not really "functions" in fish, I added a version you can call to get the n-th (which is essentially the same, because it has to compute the n-1 previous elements)

More importantly, do you have a crack that fits the same input indexing which yields the single output?

I think so, I can do a function that does the same sequence for $1<=n<=34$ but is different for $n>34$ while being ~30 bytes shorter

Cracked

Malbolge, 10 bytes
ub&;$9]J6

Note that the code ends with an 0x14 (device control 4) byte.
Try it online!
The 0-indexed sequence to crack is [9, 19, 29].

JavaScript, 26 bytes (Cracked)

let f=x=>x>1?f(x-1)*f(x-2)+1:1

for (x of [0,1,2,3,4,5,6,7]) {
  console.log(x + ' -> ' + f(x))
}

OEIS A007660
Output is the first 6 elements with 0 indexing (1,1,2,3,7,22)
(somewhat shifted from what OEIS has it listed as)
Just creating a simple to solve answer to kick things off
Try it online!

Cracked.

Your example snippet's output starts at 1, not at 0?

@PaŭloEbermann Fixed that

JavaScript, 16 bytes (Cracked)

g=
x=>Math.exp(x)|0

tmp=[0,1,2,3,4]
console.log(tmp.map(g).join(','))

First 5 elements of OEIS149 (\$\lfloor e^n\rfloor\$)
Required inputs to match are 0,1,2,3,4.
Try it online!

Cracked

Husk, 5 bytes (cracked by Jonathan Allan)
This one is A000030 shifted by \$16\$:
←d+16

Try it online!
The sequence is 0-indexed, output for \$ 0 \leq n < 23 \$:
$$ 1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3 $$
Explanation
←d+16  -- example input:  23
  +16  -- add 16:         39
 d     -- digits:         [3,9]
←      -- extract first:  3

Solution

 LdΣ

cracked

JavaScript, 25 bytes (Cracked 21 bytes)

f=
x=>[7,11,12,13,13][x]||14

for(i=0;i<15;i++)
  console.log(i+"->"+f(i))

Sequence of 7,11,12,13,13 followed by infinite 14s.
Intended solution 22 bytes:

 x=Math.atan(x+1)*10|0

Try it online!

Cracked

JavaScript, 22 bytes (Cracked)

f=
x=>(3-(5/63)**.5)**x|1

for(y=0;y<16;y++)
  console.log(y +"->"+f(y))

This is 0 indexed and accuracy is required up to an input of 15. It can not be found on OEIS
My solution 20 bytes

x=>163**(32*x/163)|1

Try it online!

Cracked.

><>, 42 bytes, cracked
i3%0v
642 .
840
789
159
a 1
v<<
n
l
?
\/
;

Try it online!
Sequence to crack (0-indexed): 101786, 5844, 19902 (not on OEIS).
Intended solution, for reference.

Cracked

Usually the robbers should be hard coding the output

@JoKing Your crack doesn't seem to produce any values different from mine (or maybe I haven't tested it thoroughly enough to find which values differ), but that's probably easily rectifiable. While there doesn't seem to be anything in the rules forbidding hardcoding, I agree that it may not fit the spirit of the challenge -- in any case you've demonstrated that hardcoding (for a cop) comes with its own risks.

I've updated my answer to produce a different value for 4

Pascal (FPC), 86 bytes (cracked)
var n:word;begin read(n);write(n div 2+n div 4+n div 8+n div 16+n div 32+n div 64)end.

Try it online!
The sequence must be equal up to \$n=120\$. The sequence from input 0 to input 120 is
0   0   1   1   3   3   4   4   7   7   8   8  10  10  11  11  15  15  16  16  18  18  19  19  22  22  23  23  25  25  26  26  31  31  32  32  34  34  35  35  38  38  39  39  41  41  42  42  46  46  47  47  49  49  50  50  53  53  54  54  56  56  57  57  63  63  64  64  66  66  67  67  70  70  71  71  73  73  74  74  78  78  79  79  81  81  82  82  85  85  86  86  88  88  89  89  94  94  95  95  97  97  98  98 101 101 102 102 104 104 105 105 109 109 110 110 112 112 113 113 116

My original solution was

var n,i,s:word;begin read(n);i:=2;repeat s:=s+n div i;i:=i*2until i>n;write(s)end.

but r_64 made it even better!

cracked

Perl 6, 53 bytes
{(1,2,2,{$!=++$;prepend(@,2-$!%2 xx$_).pop}...*)[$_]}

Try it online!
Anonymous code-block that returns the 0-indexed Kolakoski sequence (OEIS A000002). Solutions are required to match the first 130 elements, so that for some n > 129 it differs from the Kolakoski sequence.