text:
Is this a consecutive-prime/constant-exponent number?
A while ago, I had a look at the prime factorization of 27000:

27000 = 23 × 33 × 53

There are two special things about that:

consecutive-prime: The primes are consecutive: 2 is the 1st prime, 3 is the 2nd prime, 5 is the 3rd prime.
constant-exponent: The exponent is the same for every prime (always 3)

Mathematically expressed:

An integer x is a consecutive-prime/constant-exponent number if there exist strictly positive integers n, k, m such that x = pnm × pn+1m × ... × pn+km, where pj is the j-th prime

Your task is to test if a positive integer fulfills these conditions.
Input:
A positive integer > 1, in any reasonable form.
Output:
One of two values, at least one of which has to be constant, indicating whether the input is a consecutive-prime/constant-exponent number.
Edge cases:

primes are truthy, as the factorization for prime p is p1
other numbers that can be written as pm where p is a prime are also truthy.

Rules:

Standard loopholes apply.
No worries about integer overflow, but numbers up to 255 must work.
Shortest code in bytes wins.

Test cases:
Truthy:
2
3
4
5
6
7
8
9
11
13
15
27000
456533

Falsy:
10
12
14
72
10000000

Here is a python script generating some test cases.
The fact that I accepted an answer does not mean that the challenge is over; the winner can still change!

You could probably come at this the other way by generating a list of all such numbers and checking if the input is in the list

@EngineerToast There are infinitely many truthy numbers though.

@AlexisOlson Sure, but a finite that can be handled as integers by many languages.

Your mathematical expression has Pj doesn't relate to the x = Pn^m part. I'm assuming you meant Pn is the n-th prime

@Veskah n has a specific value (index of the first prime dividing x), so saying Pn is the n-th prime is awkward if you also want to imply that Pn+1 is the n+1-th prime.

One of two values, at least one of which has to be constant Is it necessary that the values are truthy and falsy according to the input, or can they be any constant value and any other values?

@Luis any constant value and any other values

05AB1E, 4 bytes
Ó0ÛË

Try it online!
Explanation
Ó     # get a list of prime exponents
 0Û   # remove leading zeroes
   Ë  # all remaining elements are equal

ÎÓKË is all I can think of other than this, nice one... I was thinking ß but it does the opposite of what I thought.

Regex (ECMAScript), 276 205 201 193 189 177 174 bytes
Comparing the multiplicities (exponents) of different prime factors is an interesting problem for solving with ECMAScript regex – the lack of backreferences that persist through iterations of a loop makes it a challenge to count anything. Even if counting the numerical trait in question is possible, often a more indirect approach makes for better golf.
As with my other ECMA regex posts, I'll give a spoiler warning: I highly recommend learning how to solve unary mathematical problems in ECMAScript regex. It's been a fascinating journey for me, and I don't want to spoil it for anybody who might potentially want to try it themselves, especially those with an interest in number theory. See this earlier post for a list of consecutively spoiler-tagged recommended problems to solve one by one.
So do not read any further if you don't want some advanced unary regex magic spoiled for you. If you do want to take a shot at figuring out this magic yourself, I highly recommend starting by solving some problems in ECMAScript regex as outlined in that post linked above.
The main payload from a regex I previously developed turned out to be very applicable to this challenge. That is the regex that finds the prime(s) of highest multiplicity. My first solution for that was very long, and I later golfed it way down in stages, first rewriting it to use molecular lookahead, and then porting it back to plain ECMAScript using an advanced technique to work around the lack of molecular lookahead, and subsequently golfing it down to be much smaller than the original plain ECMAScript solution.
The part from that regex that applies to this problem is the first step, which finds Q, the smallest factor of N that shares all of its prime factors. Once we have this number, all we have to do to show that N is a "constant-exponent number" is divide N by Q until we can't any longer; if the result is 1, all primes are of equal multiplicity.
After submitting an answer using my previously developed algorithm for finding Q, I realized that it could be calculated in an entirely different way: Find the largest square-free factor of N (using the same algorithm as my Carmichael number regex). As it turns out, this poses no difficulty at all in terms of stepping around the lack of molecular lookahead and variable-length lookbehind (no need to pull in the advanced technique previously used), and is 64 bytes shorter! [Note, at the time, molecular lookahead still offered a slight benefit, but thanks to later golfs, it no longer does at all.] Additionally it eliminates the complexity of treating square-free N and prime N as different special cases, dropping another 7 bytes from this solution.
(There still remain other problems that require the advanced technique formerly used here to golf down the calculation of Q, but currently none of them are represented by my PPCG posts.)
I put the multiplicity test before the consecutive-primes test because the latter is much slower; putting tests that can fail more quickly first makes the regex faster for uniformly distributed input. It's also better golf to put it first, because it uses more backreferences (which would cost more if they were double-digit). [The multiplicity test is now split in two for golf, with the consecutive-primes test sandwiched inside.]
I was able to drop 4 bytes from this regex (193 → 189) using a trick found by Grimmy that can futher shorten the form of division in which the assertion that \$dividend-quotient\$ is divisible by \$divisor-1\$ can be skipped. (Skipping this assertion was already saving 4 bytes, so now it's saving 8 bytes.) This algorithm (in both its 4 byte longer form and the currently used one) is guaranteed to match the correct quotient when at least one of these constraints is met (along with satisfying the assertion that \$dividend\$ is divisible by \$divisor\$):

\$divisor^2+2(divisor)+1 < 4(dividend)\$
\$quotient=1\$  or equivalently  \$divisor=dividend\$
\$divisor\$ is a prime power

One of the cases in which this must be true is when \$dividend\$ is semi-prime and neither of the two other conditions are met. It also must be true if \$dividend\$ is a prime power.

We're actually not guaranteed in this context that any of those constraints will be met. Most notably, we're not even asserting that \$quotient\$ (which will become the next \$dividend\$) is still divisible by \$divisor\$ after each iteration of the loop. But an additional fact comes to the rescue: if the division algorithm matches an incorrect quotient (which it doesn't always do even when none of the above constraints are met), the incorrect answer is guaranteed to be less than \$divisor\$ but greater than \$1\$.
So if this happens when repeatedly dividing N by Q, the loop will terminate, and the final result will not be 1, thus guaranteeing no false positives. If N is actually a constant-exponent number, the correct quotient will always be greater than or equal to Q, so this doesn't cause any false negatives either.
Further golfs:

-3 bytes by dividing by N just like any other largest square-free factor, instead of treating N being square-free as a special case (inspired by H.PWiz but goes farther then what he did, saving 1 extra byte – he made it so the regex attempted to divide by 0 in the case that Q=N, and then asserted that the end result of the repeated division was Q rather than 1)
-6 bytes by changing (?=A)(?!B) to (?!B)A (some of this is from multiple uses of backrefs changing from double to single digit, with less of the opposite occurring) – thanks to H.PWiz
-2 bytes by capturing the smallest prime as \$\ge 2\$ instead of augmenting the non-composite test to be a full prime test – thanks to H.PWiz
-2 bytes by removing an extraneous pair of parentheses – thanks to H.PWiz
-2 bytes by changing an outermost (|(x+)\2*(?=\2$)) to (|x*)\1*(?=\1\b), similarly to what I did in the alternate answer here; one of these bytes is from a backref changing from double to single digit

And the regex:
^(?=(|x*)\1*(?=\1\b)(((?=(xx+?)\4*$)(?=(x+)(\5+$))\6(?!\4*$))*x$))(?!(((xx+)(?=\9+$)(x+))(?!\8+$)(x+))\7*(?=\7$)(?!(\11\10?)?(xx+)\13+$))((?=((x*)(?=\2\16*$)x)(\15*$))\17)*x$
Try it online!
^                           # tail = N = input number

# Assert that all of N's prime factors are of equal multiplicity. There are two stages
# to this, which we will call Step 1 and Step 2. For golf reasons, a negative assertion
# is inserted between them.

# Step 1: Find Q, the largest square-free factor of N (which will also be the smallest
# factor of N that has all the same prime factors as N).
(?=
    (|x*)\1*(?=\1\b)        # cycle tail through all of the divisors of N, including N,
                            # from largest to smallest;
                            # \1 = the divisor, or zero if the divisor is N itself
    # Assert that tail is square-free (its prime factors all have single multiplicity)
    (                       # \2 = tail = the divisor
        (
            (?=(xx+?)\4*$)  # \4 = smallest prime factor of tail
            (?=(x+)(\5+$))  # \5 = tail / \4 (implicitly); \6 = tool to make tail = \5
            \6              # tail = \5
            (?!\4*$)        # Assert that tail is no longer divisible by \4, i.e. that
                            # that prime factor was of exactly single multiplicity.
        )*x$
    )
)

# Assert that there exists no trio of prime numbers such that N is divisible by the
# smallest and largest prime but not the middle prime.
(?!
    (                       # \7 = a factor of N
        (                   # \8 = a non-factor of N between \7 and \9
            (xx+)(?=\9+$)   # \9 = a factor of N smaller than \7 and greater than 1
            (x+)            # \10 = tool (with \11) to make tail = \9
        )
        (?!\8+$)
        (x+)                # \11 = tool to make tail = \8
    )
    \7*(?=\7$)              # tail = \7

    # Assert that \7, \8, and \9 are all prime
    (?!
        (\11\10?)?          # tail = either \7, \8, or \9
        (xx+)\13+$          # Assert tail is not composite; no need to test against
                            # 0 and 1, because we captured \9 > 1
    )
)

# Step 2: Require that the result of repeatedly dividing N by \2 is 1.
(
    # In this division calculation \15 = N / \2, we can skip the test for N-\15 being
    # divisible by \2-1. (Actually doing that test would make the regex 8 bytes larger.)
    # The quotient matched by this abbreviated algorithm is guaranteed to be correct if
    # the real quotient is 1 or is not less than the divisor, or if the divisor is a
    # prime power. Our input here is not guaranteed to satisfy any of those constraints.
    # But if none of those constraints are met, and the quotient matched by the algorithm
    # is incorrect, the incorrect quotient is guaranteed to be less than the divisor and
    # greater than 1. And once that happens, this loop will terminate, as the current
    # value will no longer be divisible by our divisor \2.
    (?=
        (                   # \15 = tail / \2
            (x*)            # \16 = \15-1
            (?=\2\16*$)
            x
        )
        (\15*$)             # \17 = tool to make tail = \15
    )
    \17                     # tail = \15
)*
x$                          # Require that the end result is 1

Regex (ECMAScript+(?*), 195 187 183 bytes
Obsoleted by no longer treating N being square-free as a special case (i.e. is now identical to the above).
Regex (ECMAScript 2018), 198 195 194 186 182 bytes
Obsoleted by no longer treating N being square-free as a special case and changing (?=A)(?!B) to (?!B)A (i.e. is now identical to the above).

You can replace .*$\2 with \2^

Although, I believe this is valid: ^(?=(|(x+)\2*(?=\2$))(((?=(xx+?)\5*$)(?=(x+)(\6+$))\7(?!\5*$))*x$))(?!(((xx+)(?=\10+$)(x+))(?!\9+$)(x+))\8*(?=\8$)(?!(\12\11?)?(xx+)\14+$))((?=((x*)(?=\2\17+$)x)(\16*$))\19)*\3$

Doesn't seem close to optimal though

@H.PWiz thanks! Note, the \19 at the end is supposed to be a \18.

Jelly, 13 6 5 bytes
ÆEt0E

Try it online!
Still outgolfed... (thanks Erik for -1 byte)

Explanation
ÆE     # get a list of prime exponents (noooo long builtin name)
  t0   # remove zeroes on both sides (leading or trailing)
    E  # all remaining elements are equal

œl -> t. There's no reason for trailing zeroes to be present in ÆE's output.

This doesn't quite work but will maybe lead to a 4 byte solution.

@dylnan That fails for 2250.

@Dennis Thanks, I had realized it wouldn't work but I am hoping it will inspire a four byte solution

JavaScript (ES6), 87 bytes
Returns 0 for truthy or a non-zero integer for falsy.
f=(n,k=2,j,i)=>n%k?j*(P=d=>k%--d?P(d):d==!i)(k)|j-i|(n>1&&f(n,k+1,j||i)):f(n/k,k,j,-~i)

Try it online!
Commented
f = (                     // f() = recursive function taking:
  n,                      //   n = input
  k = 2,                  //   k = current factor
  j,                      //   j = reference exponent, initially undefined
  i                       //   i = current exponent, undefined each time we start testing
) =>                      //       the next factor
  n % k ?                 // if k is not a divisor of n:
    j * (                 //   ignore the primality of k if j is still undefined
      P = d =>            //     P() = function testing if k is prime:
        k % --d ?         //       decrement d; if d is not a divisor of k:
          P(d)            //         do a recursive call until it is
        :                 //       else:
          d == !i         //         unless i is already defined: d must not be equal to 1
                          //         (if it is: k is the next prime but does not divide n)
    )(k) |                //   initial call to P() with d = k
    j - i | (             //   if both i and j are defined, they must be equal
      n > 1 &&            //   if n is not yet equal to 1,
      f(n, k + 1, j || i) //   go on with k + 1; if j is undefined, set it to i
    )                     //   (otherwise, stop recursion and return what we have)
  :                       // else:
    f(n / k, k, j, -~i)   //   increment the current exponent and go on with n / k

This was broken by the change of j||i to i. It now yields lots of false positives.

@Deadcode I can't check or correct this for the moment,  so I've just rollbacked for now.

CJam, 30 29 bytes
{mFz~)-!\__W=,\0=>\-:mp1#W=&}

Try it online!
My first answer after a nearly 2(!)-year break, so it can probably be golfed more. This is a block that takes input as an integer (can also be mapped over for arrays of integers).
Explanation
{        e# Begin block
 mF      e# Factor input, giving an array of primes and their powers
 z~      e# Transpose and dump, giving an array of primes and an array of powers
 )-      e# Check that the powers are the same: subtract each power from the last element
 !       e# Negate to make sure they're all 0
 \__W=,  e# Get the range from 0 to the largest prime minus one
 \0=>    e# Slice that array so it only includes everything larger than the smallest prime
 \-      e# Remove the original primes from the range array
 :mp     e# Check each element for primality. If the input's primes are consecutive,
         e# this will contain no primes
 1#W=    e# Make sure a "1" is not found
 &       e# If the powers are the same AND primes are consecutive, return 1. Otherwise, 0.
}

Stax, 5 6 bytes
╣♥qJ╬c

Run and debug it
Unpacked, ungolfed, and commented, it looks like this.
|n    get the exponents of the prime factorization
0:D   trim leading zeroes
:u    array has exactly a single distinct element

Edit: This doesn't work on 512.  I'll give it some thought and hopefully a fix later.  It works now.

Husk, 11 bytes
Λ§*≈¤≈oṗ←gp

Try it online!
Outputs 0 if not a consecutive-prime/constant-exponent number.

MATL, 12 11 10 bytes
YFtgYsg)Zs

Try it at MATL Online!
Thanks to Luis Mendo for the remove-leading-zeroes part.  He also pointed out that swapping truth values is allowed, so this returns 0 for numbers that satisfy the challenge requirements and any positive value otherwise.
Grosso Modo, this generates the exponents of the sequential prime factorization, removes leading zeroes and calculates the standard deviation.

I think 0iYFhdz works for 7 bytes: prepend a 0 to the exponents of the sequential factorization, consecutive differences, number of non-zeros. The result is 1 iff input satisfies the requirement

@LuisMendo Sorry for the delayed response, but you can post that as a separate answer. It is most definitely very different.

OK, I posted it as an answer

Stax, 9 bytes
1 is truthy, 0 is falsy
αAG<└\{┬⌠

Run and debug it
Explanation
|nX0-u%x:^=      # Full Program, unpacked, implicit input
|n               # Exponents of sequential primes in factorization. (eg. 20 -> [2 0 1])
  X              # Save to X register
   0-            # Remove all '0' from array
     u%          # Get unique numbers and get length of array
       x         # Copy back the array saved to X
        :^       # Is it ascending
         =       # Are the two comparisons equal? implicit output

Can probably be golfed more, but it covers the cases I was missing in the last solution.

Java 10, 223 191 178 176 168 bytes
n->{var s=new java.util.HashSet();for(int f=1,i=1,x,j;n>1;){for(x=++i,j=2;j<x;)x=x%j++<1?1:x;if(x>1){for(j=0;n%i<1&&n>(f=0);n/=i)j++;if(f<1)s.add(j);}}return s.size();}

Returns 1 as truthy, and >=2 as falsey.
Try it online.
Explanation:
n->{                   // Method with integer parameter and boolean return-type
  var s=new java.util.HashSet();
                       //  Set to keep track of the prime exponents
  for(int f=1,         //  Prime-flag, starting at 1
          i=1,x,j;     //  Index and temp integers
          n>1;){       //  Loop as long as `n` is still larger than 1
    for(x=++i,         //   Set `x` to `i`, after we've increased `i` by 1 first with `++i`
        j=2;           //   Set `j` to 2 (first prime)
        j<x;)          //   Inner loop as long as `j` is still smaller than `x`
      x=x%j++<1?       //    If `x` is divisible by `j`:
         1             //     Set `x` to 1
        :              //    Else:
         x;            //     Leave `x` unchanged
    if(x>1){           //    If `x` is larger than 1 (if `i` is a prime):
      for(j=0;         //     Use `j` as counter, and set it to 0
          n%i<1        //     If `n` is divisible by `i`:
                       //      And loop as long as `n` is still divisible by `i`,
          &&n>         //      and `n` is larger than 0
              (f=0);   //      (and set `f` to 0 at the same time)
          n/=i)        //       Divide `n` by `i`
        j++;           //       And increase `j` by 1
      if(f<1)          //     If the flag `f` is now/still 0:
        s.add(j);}}    //      Add counter `j` to the Set
  return s.size();}    //  Return the amount of items in the Set
                       //  (1 being true, >=2 being false)

Some example inputs:
n=15:

Flag remains 1 for the first prime 2 (because 15 is not divisible by 2).
Flag goes from 1 to 0 as soon as we're at the prime 3. Since 15 is divisible by 3, n becomes 5 (15/31), and the Set becomes [] → [1].
Then we check the next prime 5. Since 5 is divisible by 5, n becomes 1 (5/51), and the Set remains the same ([1] → [1]).
Now n=1, so we stop the outer loop. The Set ([1]) only contains one item, the 1 from both adjacent primes 3 and 5, so we return true.

n=14:

Flag goes from 1 to 0 for the first prime 2 (because 14 is divisible by 2). n becomes 7 (14/21), and the Set becomes [] → [1].
Then we check the next prime 3. Since 7 is not divisible by 3, n remains the same, and the Set becomes [1] → [1,0].
Then we check the next prime 5. Since 7 is also not divisible by 5, n remains the same, and the Set remains the same as well ([1,0] → [1,0]).
Then we check the next prime 7. Since 7 is divisible by 7, n becomes 1 (7/71), and the Set remains the same ([1,0] → [1,0]).
Now n=1, so we stop the outer loop. The Set ([1,0]) contains two items, the 1 from the non-adjacent primes 2 and 7, and the 0 from the primes 3 and 5, so we return false.

n=72:

Flag goes from 1 to 0 for the first prime 2, because 72 is divisible by 2 (multiple times). So n becomes 9 (72/23), and the Set becomes [] → [3].
Then we check the next prime 3. Since 9 is divisible by 3 (multiple times), n becomes 1 (9/32), and the Set becomes [3] → [3,2].
Now n=1, so we stop the outer loop. The Set ([3,2]) contains two items, the 3 from prime 2, and the 2 from prime 3, so we return false.

You can remove <2 and return an int (specify that you return 1 for truthy).

@wastl Ah, missed the rule about only one of the two values being consistent. In that case 1 is truthy and 2 or higher is falsey. Thanks.

Thanks to whoever gave me the bounty, but why?

I had started a "Reward existing answer" bounty to bring more attention to my ECMAScript answer, which I still believe deserves more than it's gotten (I'd consider the bounty to have failed). When the week was over, I had to choose an answer other than my own to award the bounty to, or leave it to default to the highest-voted. I did not think any deserved it, but your answer had the best explanation, and that's why I awarded it to you; good explanations are way too rare on PPCG. As for my answer, I figure I have to give it a better writeup, which I plan on when I have time.

@Deadcode Ah, so that's why. I thought maybe someone started the bounty, but they accidentally let it expire and it came to me instead. Still a bit confused why my answer then and not the highest voted one. I must say I'm impressed by all your Regex answers. I've seen some of them, and every time I'm amazed. Especially when I come back later to the same answer and you golfed it even loads more. :D I just noticed I hadn't seen nor upvoted the one for this challenge, so I just did. You know, I will add a bounty to this answer of yours. :)

Wow, thank you so much, Kevin! :D

MATL, 7 bytes
0iYFhdz

The result is 1 iff input satisfies the requirement.
Try it online! Or verify all test cases
Explanation
0    % Push 0
i    % Push input number
YF   % Exponents of consecutive prime factors
h    % Concatenate horizontally
d    % Consecutive differences
z    % Number of nonzeros. Implicitly display

Octave, 67 bytes
@(x)~any(diff(find(h=histc(factor(x),primes(x))))-1)&h(h>0)==max(h)

Try it online!
I believe this is the only solution that uses a histogram.
Explanation:
This makes a histogram, where the variable to be counted are the factors of the input, and placed in the bins primes(x), which is all primes less than the input. We then find the location of the prime factors, takes the difference between each of the indices and subtract one. If there are any elements that aren't zero (i.e. the difference of the indices of prime numbers is not 1), then this will result in a falsy value, otherwise it will return a truthy value.
We then chech that all non-zero elements in the histogram are equal to the maximum element. If there are values that aren't equal then this will result in a falsy value, otherwise it will return a truthy value.
If both those blocks are truthy then our input is a consecutive prime constant exponent number!

J, 16 bytes
Big thanks to FrownyFrog for -8 bytes!
(=&#+/\=@#])_&q:

Try it online!
My old solution:
J, 24 bytes
[:(1=[:#@~.{.@I.}.])_&q:

Try it online!
Explanation:
_&q: prime exponents
{.@I.}.] removes the leading zeros by finding the first non-zero element:
     }.   drop
       ]  from the list of exponents
{.@       as much items as the first of the
   I.     indices of non-zero elements

1=[:#@~.  tests if all remaining numbers are equal:
  [:#@~.  finds the length of the list after removing the duplicates
1=        is it 1?

APL (Dyalog Extended), 28 bytes
{f p←`↓⍭⍵⋄(1=≢∪p)∧∨/f⍷⍸1⍭⍳⍵}

Try it online!
How:
{f p←`↓⍭⍵⋄(1=≢∪p)∧∨/f⍷⍸1⍭⍳⍵} ⍝ Monadic function, takes an argument ⍵
       ⍭⍵                     ⍝ Prime factors and exponents of ⍵
     `↓                        ⍝ split the resulting matrix in 2 vectors
 f p←                          ⍝ assign the factors to f and the powers to p
         ⋄                     ⍝ then
                          ⍳⍵   ⍝ range [1..⍵]
                        1⍭     ⍝ primality check for each element in the vector
                       ⍸        ⍝ where; returns the indices of truthy values
                     f⍷         ⍝ find the factors; returns a boolean vector
                   ∨/           ⍝ logical OR reduction
                  ∧             ⍝ logical AND
           (   ∪p)              ⍝ unique members of the powers
              ≢                 ⍝ tally; returns the number of elements in the vector
            1=                  ⍝ check if there's only one element

J, 14 bytes
1#.2~:/\0,_&q:

1 in the output indicates consecutive constant exponent.
Try it online!
        0,_&q:   zero followed by the prime exponents of input
   2~:/\         for every two consecutive values, 1 if they are different
1#.              convert from base-1, just add them up

Clean, 127 bytes
import StdEnv
@n=[]== $n
?n#j= $n
= @n||j==filter@[hd j..last j]&&any(\p=(prod j)^p==n)[1..n]
$n=[i\\i<-[2..n-1]|n/i*i==n&& @i]

Try it online!
Defines the function ? :: Int -> Bool using $ :: Int -> [Int] to factorize and @ :: Int -> Bool to check primality.

Wolfram Language (Mathematica), 65 bytes
Differences[{PrimePi@#,#2}&@@@FactorInteger@#]~MatchQ~{{1,0}...}&

Try it online!

Pari/GP, 63 bytes
n->#Set(vector(#(a=factor(n)~),i,[primepi(a[1,i])-i,a[2,i]]))<2

Try it online!

APL(NARS) 41 chars, 82 bytes
{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}

{π⍵}  is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime (note that in this case its argument is not a scalar but one array of integers). test:
  h←{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
  (2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30
  h¨27000 456533 72 10000000
1 1 0 0


text:
Generalized Cantor set segment lengths
Problem
Let's define a generalized Cantor set by iteratively deleting some rational length segments from the middle of all intervals that haven't yet been deleted, starting from a single continuous interval.
Given the relative lengths of segments to delete or not, and the number of iterations to do, the problem is to write a program or function that outputs the relative lengths of the segments that have or have not been deleted after n iterations.

Example: Iteratively delete the 4th and 6th eighth
Input:
n – number of iterations, indexed starting from 0 or 1
l – list of segment lengths as positive integers with gcd(l)=1 and odd length, representing the relative lengths of the parts that either stay as they are or get deleted, starting from a segment that doesn't get deleted. Since the list length is odd, the first and last segments never get deleted.
For example for the regular Cantor set this would be [1,1,1] for one third that stays, one third that gets deleted and again one third that doesn't.
Output:
Integer list o, gcd(o)=1, of relative segment lengths in the nth iteration when the segments that weren't deleted in the previous iteration are replaced by a scaled down copy of the list l. The first iteration is just [1]. You can use any unambiguous output method, even unary.
Examples
n=0, l=[3,1,1,1,2] →                 [1]
n=1, l=[3,1,1,1,2] →     [3,    1,    1,    1,    2]
n=2, l=[3,1,1,1,2] → [9,3,3,3,6,8,3,1,1,1,2,8,6,2,2,2,4]

n=3, l=[5,2,3]     → [125,50,75,100,75,30,45,200,75,30,45,60,45,18,27]
n=3, l=[1,1,1]     → [1,1,1,3,1,1,1,9,1,1,1,3,1,1,1]

You can assume the input is valid. This is code-golf, so the shortest program measured in bytes wins.

Would it be acceptable to input and output the indices of non-deleted segments instead of the lengths?  For instance, [0, 1, 2, 4, 6, 7] instead of [3, 1, 1, 1, 2]?

@Mnemonic it's not too far from unary, so I'd say it's fine.

Could you add one (or multiple) test case(s) for even-sized input-lists?

@KevinCruijssen the input lists are guaranteed to be odd-sized

Jelly,  15 13  12 bytes
-2 thanks to Dennis (using a Link rather than a chain allows right to be used implicitly by ¡; No need to wrap the 1 in a list due to the fact that Jelly prints lists of one item the same as the item)
-1 thanks to Erik the Outgolfer (use Ɗ to save the newline from using Ç)
1×€³§JḤ$¦ẎƊ¡

A full program printing a list in Jelly format (so [1] is printed as 1)
Try it online!
How?
1×€³§JḤ$¦ẎƊ¡ - Main link: segmentLengths; iterations
1            - literal 1 (start with a single segment of length 1)
           ¡ - repeat...
             - ...times: implicitly use chain's right argument, iterations
          Ɗ  - ...do: last 3 links as a monad (with 1 then the previous output):
   ³         - (1) program's 3rd argument = segmentLengths
 ×€          -  1  multiply €ach (e.g. [1,2,3] ×€ [1,2,1] = [[1,4,3],[2,4,2],[3,6,3]])
        ¦    -  2  sparse application...
       $     - (2) ...to: indices: last two links as a monad:
     J       - (2)          range of length = [1,2,3,...,numberOfLists]
      Ḥ      - (2)          double            [2,4,6,...] (note: out-of bounds are ignored by ¦)
    §        - (2) ...of: sum each (i.e. total the now split empty spaces)
         Ẏ   -  3  tighten (e.g. [[1,2,3],4,[5,6,7]] -> [1,2,3,4,5,6,7])
             - implicit print

Python 2, 120 107 104 103 100 99 89 bytes
f=lambda n,l:n and[x*y for i,x in enumerate(l)for y in[f(n-1,l),[sum(l)**~-n]][i%2]]or[1]

Try it online!

Saved

-10 bytes, thanks to Neil

89 bytes

Haskell, 76 58 bytes
l%0=[1]
l%n=do(x,m)<-l%(n-1)`zip`cycle[l,[sum l]];map(*x)m

Try it online!
The function (%) takes the list of line lengths l as first argument and the number of iterations n as second input.
Thanks to Angs and Ørjan Johansen for -18 bytes!

You should be able to save at least 7 bytes by switching to a recursion on n and dropping # altogether

Independently of @Angs 's suggestion, the original % can be shortened to l%a=do(x,m)<-zip a$a>>[l,[sum l]];(*x)<$>m .

R, 94 bytes
f=function(n,a)"if"(n,unlist(Map(function(g,i)g(i),c(c,sum),split(m<-a%o%f(n-1,a),row(m)))),1)

Try it online!

JavaScript (Firefox 42-57), 80 bytes
f=(n,l,i=0)=>n--?[for(x of l)for(y of(i^=1)?f(n,l):[eval(l.join`+`)**n])x*y]:[1]

Needs those specific versions because it uses both array comprehensions and exponentiation.

JavaScript (Node.js), 71 bytes
l=>f=(n,c=1,e)=>n--?''+l.map(_=>(e=!e)?f(n,c*_):eval(l.join`+`)**n*c):c

Try it online!

Java 10, 261 bytes
L->n->{if(n<1){L.clear();L.add(1);}else if(n>1){var C=new java.util.ArrayList<Integer>(L);for(int l=C.size(),i,x,t,s;n-->1;)for(i=x=0;i<L.size();){t=L.remove(i);if(i%2<1)for(;i%-~l<l;)L.add(i,C.get((i++-x)%l)*t);else{x++;s=0;for(int c:C)s+=c;L.add(i++,t*s);}}}}

Modifies the input-List instead of returning a new one to save bytes.
Try it online.
L->n->{                       // Method with List and integer parameters and no return-type
  if(n<1){                    //  If `n` is 0:
    L.clear();                //   Remove everything from the List
    L.add(1);}                //   And only add a single 1
                              //  Else-if `n` is 1: Leave the List as is
  else if(n>1){               //  Else-if `n` is 2 or larger:
    var C=new java.util.ArrayList<Integer>(L);
                              //   Create a copy of the input-List
    for(int l=C.size(),       //   Set `l` to the size of the input-List
        i,x,t,s;              //   Index and temp integers
        n-->1;)               //   Loop `n-1` times:
      for(i=x=0;              //    Reset `x` to 0
          i<L.size();){       //    Inner loop `i` over the input-List
        t=L.remove(i);        //     Remove the current item, saving its value in `t`
        if(i%2<1)             //     If the current iteration is even:
          for(;i%-~l<l;)      //      Loop over the copy-List
            L.add(i,C.get((i++-x)%l)*t);
                              //       And add the values multiplied by `t`
                              //       at index `i` to the List `L`
        else{                 //     Else (the current iteration is odd):
          x++;                //      Increase `x` by 1
          s=0;for(int c:C)s+=c;
                              //      Calculate the sum of the copy-List
          L.add(i++,t*s);}}}} //      Add this sum multiplied by `t`
                              //      at index `i` to the List `L`

Jelly, 13 bytes
Ø1××S¥ƭ€³Ẏ$¡Ṗ

Try it online!
Full program. Outputs 1 instead of [1]. Annoyingly, ḋ doesn't work like ×S¥ in this context, and ƭ doesn't work well with nilads. >_<

APL (Dyalog Classic), 20 bytes
{(∊⊢×⍵(+/⍵)⍴⍨≢)⍣⍺,1}

Try it online!

K (ngn/k), 27 bytes
{x{,/y*(#y)#x}[(y;+/y)]/,1}

Try it online!
{ } is a function with arguments x and y
(y;+/y) a pair of y and its sum
{ }[(y;+/y)] projection (aka currying or partial application) of a dyadic function with one argument. x will be (y;+/y) and y will be the argument when applied.
,1 singleton list containing 1
x{ }[ ]/ apply the projection x times
(#y)#x reshape to the length of the current result, i.e. alternate between the outer y and its sum
y* multiply each element of the above with the corresponding element of the current result
,/ concatenate

Ruby, 73 bytes
->a,l{r=[1];a.times{s=p;r=r.flat_map{|x|(s=!s)?l.map{|y|x*y}:x*l.sum}};r}

Try it online!

Pyth, 20 bytes
us.e?%k2*bsQ*LbQGE]1

Input is segment array l, then iterations n. Try it online here, or verify all the test cases at once here.
us.e?%k2*bsQ*LbQGE]1   Implicit, Q=1st arg (segment array), E=2nd arg (iterations)
u                E     Execute E times, with current value G...
                  ]1   ... and initial value [1]:
  .e            G        Map G, with element b and index k:
        *bsQ               Multiply b and the sum of Q {A}
            *LbQ           Multiply each value of Q by b {B}
    ?%k2                   If k is odd, yield {A}, otherwise yield {B}
 s                       Flatten the resulting nested array

source: Stack Exchange

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

sort: votes


text:
Determining Yes or No?
After inputting a string [length 1-20], only containing the chars y for yes and n for no,
your program should output the result (y or n). Example input: yynynynny would output y.
The result is determined by combining the y's and n's in the following way:

yes and no equals no
yes and yes equals yes
no and no equals yes

If the string contains more than 2 characters (likely...), the calculation would look the same. Examples:

yes and yes and no equals no (because the no merges with the first yes to no. then there are no and yes left and the same thing happens again)
no and no and no equals no (the first two no's merge to yes, then there are yes and no left, which emerge to no)

Example input with output:

yynynynynyyn = n

Tip: have in mind that the order of the chars your program works off doesn't care. (for example you can read the input from back, or from behind, mix the letters, sort it, whatever. What counts is the correct ouptput) have fun!
Winning criteria:
this is code-golf, so shortest code in byte wins.

Congratulations on the first challenge with clear specification! (although it's unfortunate that some community members don't like "too trivial" challenges....)

Very similar.

The boolean relationship defined is XNOR, sometimes called EQV in older BASICs. It is the inverse of XOR, and can be achieved as NOT(XOR...) if using boolean values directly; the additional complexity in this challenge is strictly from the requirement to deal with strings of 'yn' in both input and output.

Can we output an alternative pair? Say 1 for y, and 0 for n.

Can we take input as a list of characters ie ["y", "n", "n"]

Can we take input as an alternative pair? Say 1 for y, and 0 for n.

@Adám Then this would be an exact duplicate of the linked challenge, I guess not :P

@Mr.Xcoder No, XNOR vs XOR. But why the unnecessary complication of I/O formats here, when the much related challenge doesn't need it?

XNOR is just NOT XOR so this would be too closely related to be kept open.

@Mr.Xcoder It's only a duplicate if it's "1 for n, 0 for y"...

@Mr.Xcoder If the only thing keeping this question from being a duplicate is different characters for input format, how is it not already a dupe?

Why not close the old one as a dupe of the new one? The old one was poorly received, and I think this one is more interesting

@ConorO'Brien What's wrong with doing this? HNQ questions rarely "have the correct votes".

@ConorO'Brien Some discussion in chat.

The output format makes this more interesting than the problem it's marked a duplicate of. That one is just sum of elements, reduce modulo 2. Many of those answers would not be optimal here.

Your first example doesn't make sense to me. How does the no merge with the first yes? Isn't evaluation left-to-right? Do you mean the two yeses merge, then the resulting yes merges with the no to make no?

Could we have a few more examples?

Why close this as a duplicate of a heavily downvoted challenge? I voted to leave this open in the review queue.

@davidconrad you're right, but as I said, the order doesn't matter

Since the duplicate of this challenge was heavily downvoted, I don't think it's very helpful to close this as a duplicate. If anything, the older challenge should be a duplicate of this one since it's policy to leave the better challenge open I've reopened this challenge

Can we output truthy or falsy values?

Charcoal, 6 bytes
§yn№Ｓn

Try it online! Link is to verbose version of code. Explanation:
    Ｓ   Input string
   № n  Count number of `n`s
§yn     Circularly index into string `yn`
        Implicitly print appropriate character

Explain how it works,  please?

@Malandy Link is to verbose version of code.

@Adám Actually I usually add one, however I had just dashed this off in a work break and forgotten to edit one in.

Octave, 29 27 bytes
Thanks to @RickHithcock for pointing out a mistake, now corrected. Also, 2 bytes off thanks to @StewieGriffin!
@(s)'yn'(mod(sum(s+1),2)+1)

Try it online!
Explanation
The ASCII code point of 'y' is odd, and that of 'n' is even. The code

adds 1 to each char in the input string to make 'y' even and 'n' odd;
computes the sum;
reduces the result to 1 if even, 2 if odd;
indexes (1-based) into the string 'yn'.

I'm probably missing something obvious, but this seems to function the same way in a few limited test cases for -4 bytes. It's probably wildly wrong because I don't know Octave!

@DomHastings Fails for yynynynny given in the OP, should return y, but returns n

JavaScript (ES6), 28 bytes
Takes input as a string.
s=>'ny'[s.split`n`.length&1]

Try it online!

JavaScript (ES6), 30 bytes
Takes input as an array of characters.
y=>'yn'[n=1,~~eval(y.join`^`)]

Try it online!

31: s=>'yn'[s.match(/n/g).length&1] :P

@ASCII-only This would fail on strings that do not contain at least one n.

Oh, it would. Oops >_>

Haskell,  33 28 bytes
f a=cycle"yn"!!sum[1|'n'<-a]

Indexes the count of n's into the infinite list "ynynynyn…".
Previous approach (33 bytes) was folding pairs of different elements to n, otherwise y:
f=foldl1(\a b->last$'y':['n'|a/=b])

Try it online!

Your previous approach can be done in 30 bytes. Try it online!

Jelly, 7 bytes
ċ”nị⁾ny

Try it online!
ċount number of ”n, ịndex into the string ⁾ny. (with modulo 2)

ċḢịɗ⁾ny

Try it online!
{ċount number of, take the Ḣead, then ịndex into} string ⁾ny.

OCSị⁾ny

Try it online!
Similar to the Octave answer above. Calculate Ord value, take the Complement (for each ord value x calculate 1-x), Sum, then ịndex into string ⁾ny.

It was my bogus solution confusing me!

APL (Dyalog Unicode), 15 bytes
'ny'[1+=/'y'=⍞]

Try it online!
Note: TIO defaults to ⎕IO = 1. If run with ⎕IO←0,
APL (Dyalog Unicode), 13 bytes
'ny'[=/'y'=⍞]

Try it online!
This is the XNOR function (sometimes called EQV, especially in old BASICs.
Decomposition/Analysis:
             ⍞  - Accept string input
         'y'=   - Compare it to the letter `y`. This "converts" the input
                  string into a vector of 1s and 0s where the 1s correspond
                  to 'y' and the 0s to 'n'.
       =/       - XNOR/EQV/equality reduction - converts the vector into a
                  single boolean value by evaluating e.g., 1 xnor 0 xnor 0
                  xnor 1 ...
     1+         - adds one for subscripting in ⎕IO = 1 environment. In
                  ⎕IO = 0, should be omitted (save 2 bytes)
    [         ] - subscript indicator - the expression, which should be
                  either a 1 or 2 (0 or 1 in `⎕IO = 0`), is now going to be
                  interpreted as a subscript of...
'ny'            - The string of possible results - a 0/1 is 'n', a 1/2 is 'y'

While XOR ignores 0s and flips on 1s, XNOR ignores 1s and flips on 0s, “initially” being at 1 instead of 0 like XOR.

@FrownyFrog - I suppose you could look at it that way... or you could look at it as being a check to see if both of its input values are the same.

Python 2, 29 bytes
lambda s:'yn'[s.count('n')%2]

Try it online!

Pyth, 9 bytes
@"yn"l@\n

Try it here
Explanation
@"yn"l@\n
     l@\nQ   Get the length of the intersection of the (implicit) input and "n".
@"yn"        Modular index into "yn".

Japt, 8 bytes
"yn"gUèn

Try it online!
Explanation:
"yn"gUèn
"yn"       String literal - "yn"
    g      Return the char at index:
      è      Number of matches where:
       n       "n" is found in
     U         Input

Japt uses index-wrapping, so if Uèn returns 2, it will return y when getting the char from "yn".

Identical to what I had.

dc, 39
?dsiZdsl[[]r1-d0<m]dsmxklixzll-2%B*C1+P

Input string is read from STDIN and should be in the form [yynynynynyyn].
dc is not known for its string handling, but we have just enough here to get this to work.  The approach here is to count the ns, and output y if even or n if odd.  This is done by executing the input string as a macro.  dc will output 'y' (0171) unimplemented errors for all the ys and attempt to pop strings and print them for all the ns.  So first we make sure we have plenty (total input string length) of empty strings [] on the stack to pop.  Then we execute the input string and see how many [] are left on the stack.  The original string length is subtracted from this to give the (-ve) total number of ns.  The rest is arithmetic to do mod 2 and have the output come out right as ASCII y or n.
?dsi                                    # Read input string, duplicate, store in register i
    Zdsl                                # Get input length, duplicate, store in register l
        [         ]                     # define macro to:
         []                             #   push empty string
           r                            #   swap empty string and remaining length
            1-                          #   subtract 1 from length
              d0                        #   duplicate and compare with 0
                <m                      #   if >0 recursively call this macro again
                   dsmx                 # duplicate macro, store in register m and execute
                       k                # discard left-over 0
                        lix             # load input string and execute as macro
                           z            # get stack length
                            ll-         # load string length and subract
                               2%       # mod 2 (result is -ve because difference is -ve)
                                 B*     # multiply by 11 ('y' - 'n')
                                   C1+  # add 121 ('y')
                                      P # print result as ASCII char

Try it online!

Perl 6, 21 bytes
{<y n>[.comb('n')%2]}

Try it
Expanded:
{  # bare block lambda with implicit parameter $_

  # index into the list ('y', 'n')
  <y n>[

    .comb('n') # get every instance of 'n' (implicit method call on $_)
    % 2        # turn it into a count and get the modulus

  ]
}

J, 10 9 bytes
{&'ny'@=/

Try it online!

Very clever usage of reduction!

Really nice solution(s)!

Would you please provide a decomposition of the/both solutions (as I did with my APL solution)? (Incidentally, you should really post the APL solution as a separate solution from the J solution, even if the algorithm is the same.)

{&'ny'@=/ saves a byte.

@algorithmshark ohhh thanks!

Java 8, 35 bytes
A decider for a regular language! I can do that.
s->s.matches("y*(ny*ny*)*")?'y':'n'

Try It Online

Jelly,  8  7 bytes
O‘Sị⁾ny

Try it online!

Ẉ can be used instead of L€.

R, 46 44 bytes
"if"(sum(1+utf8ToInt(scan(,"")))%%2,"n","y")

Try it online!
Down 2 bytes thanks to Giuseppe and ngm. Port of the Octave answer by Luis Mendo.

It's easiest to get inspired by the Octave answer; while Octave has the advantage that strings are converted to their code points more easily, I think you can port the approach there for a couple bytes down.

sum(utf8ToInt(scan(,""))%%2)%%2 saves one byte.

@ngm @Giuseppe sadly n is even so have to add+1 first..

Japt, 9 bytes
Oliver beat me to the shortest solution so here are a couple that are just a byte longer.
B*aUèÍu¹d

Try it
#ndB*UèÍv

Try it

Explanations
              :Implicit input of string U
B             :11
 *            :Mutiplied by
  a           :  The absolute difference of 11 and
   UèÍ        :    The count of "n" in U
      u       :    Mod 2
       ¹d     :Get the character at that codepoint

              :Implicit input of string U
#n            :110
   B*         :Add 11 multiplied by
        v     :  The parity of
     UèÍ      :    The count of "n" in U
  d           :Get the character at that codepoint

Perl 5, 19 18 bytes
s/y|ny*n//g;s;^$;y

Try it online!
Similar to the Retina solution.

///, 24 bytes
/ny/n//nn/y//yy/y//yn/n/<input>

Try it online!
I believe this is the shortest possible /// program, as making a one character substitution either is useless (if you insert something in its place) or prevents it from being an output (if you insert nothing). However, since the program must deal with the two character cases, this should be minimal.
First removes all ys right of an n. Then replaces double ns with ys, taking advantage of LTR substitution. At this stage there are many ys followed by at most one n; we deduplicate the ys and if there is an n use it to mop the last y up.

MATL, 8 bytes
Qs'ny'w)

Try it online!
Saved 2 bytes thanks to Luis Mendo! I previously used the explicit modulus command to get the index into the range 1,2.
Explanation
This uses the fact that MATL have modular indexing, which means that the 1st, 3rd, 5th ... element of the string ny are the same (n). So are the 2nd, 4th, 6th ... element of the string (y).
Q          % Grab input implicitly, and increment each ASCII-value by 1
           % This makes 'n' odd, and 'y' even
 s         % Take the sum of all elements
  'ny'     % Push the string `ny`
      w    % Swap the stack to facilitate the indexing
       )   % Take the n'th element of 'yn' and output it.

'yn'3) gives y...? Now that's clever design Luis =) Thanks for the tips! :)

It was Dennis' suggestion :-)

Python 2, 26 bytes
lambda s:'yn'[int(s,35)%2]

Try it online!

Retina, 11 bytes
y

nn

^$
y

Try it online!

CJam, 20 11 bytes
q~'ne="yn"=

Try it online!

05AB1E, 8 bytes
'n¢„ynsè

Try it online!

Java (OpenJDK 8), 143 bytes
a->{char[] u=a.toCharArray();if(u.length==1)return u[0];else{char b=(u[0]==u[1])?'y':'n',i=2;for(;i<u.length;b=(b==u[i++])?'y':'n');return b;}}

Try it online!
And if we take the input as a list:
Java (OpenJDK 8), 118 bytes
u->{if(u.length==1)return u[0];else{char b=(u[0]==u[1])?'y':'n',i=2;for(;i<u.length;b=(b==u[i++])?'y':'n');return b;}}

Try it online!
Explanation:
(input as string)
char[] u=a.toCharArray();  //turn string into char array
if(u.length==1){
    return u[0];      //if single letter, return it
}else{
    char b=(u[0]==u[1])?'y':'n';     //first two XNOR
    for(char i=2;i<u.length;b=(b==u[i++])?'y':'n');   //XNOR each remaining character
return b;    //return final result
}

You don't need the parenthesis at your ternary-ifs (-4 bytes), you can remove the space at char[]u (-1 byte); and if(u.length==1) can be if(u.length<2) (-1 byte). There is probably more to golf, but I don't really have the time right now. :)

F#, 54 50 bytes
-4 bytes thanks to Laikoni.
let c=Seq.reduce(fun a x->if a=x then 'y'else 'n')

Try it online!
Seq.reduce applies a function with an accumulator (a)  to each element (x) in the string. For the first call, a is the first element in the string and x is the second element.

It looks like the space after 'y' can be removed.

i can also be removed by Eta-conversion: let c=Seq.reduce(fun a x->if a=x then 'y'else 'n'). And as our general rules allow anonymous functions, you can drop the let c= part as well.

I like the Eta-conversion! But can you link to that rule about anonymous functions please? It seems a little strange not to have the function definition in the submitted code, even for anonymous functions.

The meta consensus is here: https://codegolf.meta.stackexchange.com/a/1503/56433

Ruby, 24 bytes
->s{"yn"[s.count(?n)%2]}

Try it online!
A lambda taking a string and returning a string.

Chip -z, 24 bytes
B}Zvv~vedSD~t
 `'bc af*g

Try it online!
Explanation
This prints 'h', which is 'n' & 'y':
        d
       f*g

This converts the 'h' to either an 'n' or a 'y', according to whether the top-left wire is powered:
   vv~ve
   bc a

This is the xor counter, it powers the part described above as necessary:
B}Z
 `'

Finally, this causes the program to only print the last output and terminate when the input is exhausted (the -z flag adds a null terminator for this purpose):
         SD~t

Try replacing the S with a space to see the running result (the first 'y' is extraneous, the second char matches the first input, and the third is the result of the first nontrivial calculation).

Cubix, 24 20 bytes
Been a while since I played with Cubix, so ...
i;iwW-?;o@..!'yv.n'|

Try it online!
Fairly naive implementation that steps through the string and compares the character against current result.
Interactive Demo
This unwraps onto the cube as follows
    i ;
    i w
W - ? ; o @ . .
! ' y v . n ' |
    . .
    . .

W shift ip left
i get the initial character
i? get character and test for EOI (-1), also start of the loop

if EOI ;o@ remove TOS, output TOS as character and exit.

else -W! subtract, shift ip left, test for truthy

if truthy 'n push character n to TOS
if falsey |!'y reflect, test and push character y to TOS

v'.;w redirect around the cube pushing and  removing a . character and shifting right back into the loop

Scala, 50 Bytes
def?(b:String)=b.reduce((r,l)=>if(r==l)'y'else'n')

C (gcc), 52 50 bytes
Thanks to @Neil for the suggestions.
I borrowed the solution of counting ns, but instead of keeping a count, I just flip between the initial state and its inverse on an n.
i;f(char*a){for(i=*a;*++a;i^=*a&1?0:23);return i;}

Try it online!

*a&1?0:23 saves a byte and return i saves another.

Suggest i;f(char*a){for(i=*a;*++a;i^=*a&1?:23);a=i;}

Befunge-98, 13 bytes
~k!aj@,+n'*b!

Try it online!
Basically inverts a 0 for every n in the input, and once more for good measure, then outputs y for 1 and n for 0
~     Get inputted character
 k!   Invert the current value 110 (n) or 121 (y) + 1 times
   aj Jump past the rest of the code
~     Get input again. If no more input, reverse direction
            ! Invert the value once again
       +n'*b  Convert 0/1 to n/y
     @,       Output letter

JavaScript, 3937 Bytes
s=>[...s].reduce((x,y)=>x==y?'y':'n')

Simple reduce function after splitting the input string.

Welcome to PPCG! Your code assumes the input is in the variable s, which is not a valid input method here. You may instead make your answer a lambda function taking the input as an argument by prepending s=> to your answer for 42 bytes.

golfing suggestion: replace s.split('') with [...s] for 37 bytes: s=>[...s].reduce((x,y)=>x==y?'y':'n')

Clean, 26 23 bytes
foldr1\a b|a==b='y'='n'

Try it online!

You can save 3 bytes using lambda guards: foldr1\a b|a==b='y'='n'. (By the way, unfortunately usually imports are part of the bytecode.)

Kotlin, 32 Bytes
"yn"[s.filter{it=='n'}.length%2]

Try it online!

PHP, 77 70 Bytes
Try it online
Code, recursive function
function f($p){echo($p[1])?f(strtr($p,[yy=>y,yn=>n,ny=>n,nn=>y])):$p;}

Explanation
Why use strtr with a replace array like [yy=>y,yn=>n,ny=>n,nn=>y], as the string the function takes can be shown like (example with test case "yynynynynyyn")
  (y and y) and (n and y) and (n and y) and (n and y) and (n and y) and (y and n)

What does the function do?
  function f($p){
      echo($p[1])
           //The function will replace yy yn ny nn while strlen>1
           ?f(strtr($p,[yy=>y,yn=>n,ny=>n,nn=>y]))
           //Length greater than one, apply strtr
           :$p;
           //ok, just one letter left, "echo" it
     }

With a loop, 83 Bytes
Try it online
Simulates "run as pipe"
Code
<?php $p=$argv; while(strlen($p)>1){$p=strtr($p,[yy=>y,yn=>n,ny=>n,nn=>y]);}echo$p;

Explanation
It does the exact same thing as the recursive function
$p=$argv; //Accepting value from the script variable
while(strlen($p)>1){ //the loop ends when string length is one
   $p=strtr($p,[yy=>y,yn=>n,ny=>n,nn=>y]); //replace
}
echo$p; //echo the result.

JavaScript, 44 bytes
(prompt()+"n").match(/n/gi).length%2?"y":"n"

Try it out on developer console.

Husk, 8 bytes
!"ny"#'n

Try it online!

Stax, 9 7 bytes
Å8Dq↨W<

Run and debug it

If I'm understanding right, you can use modular indexing to get to 7.

@recursive what is modular indexing?

When you use @ to get an element from an array, it "wraps around".  So you can use @ to get an element from a 2-length array, and even indices return the first element, and odd ones return the last.  Basically |e (which determines parity of a number) is unnecessary.

Mathematica, 59 bytes
Not the shortest but anyway
f[s_]:=Times@@StringCases[s,a={"y"->1,"n"->-1}]/.Reverse/@a

Call if s is your string of y and n (included between ".."), call f[s].
All it does is to replace y by 1 and n by -1, then multiply them and replace the numbers back to strings.

GolfScript, 14 bytes
'n'/,2%'ny'1/=

Try it online!

PowerShell Core, 48 43 bytes
"$args"|% t*y|%{$z=$z-xor$_-eq'n'};'yn'[$z]

Try it online!
Not the best method. Split into char array, use -xor, invert it implicitly at the end with the array lookup to get back a char.

Save 5 bytes by using "yn" instead of ('y','n').

Also, you need to compare against 'n' and not 'y' - you don't see this in your demo because there are equal numbers of each letter.

@Neil wow I can't believe I didn't use 'yn', I'm crazy rusty. I originally was comparing with 'n' and now I can't remember why I changed it. Thanks!

Go, 91 bytes
package main;import ."strings";type s=string;func f(S s)(s){return s("yn"[Count(S,"n")%2])}

105 bytes if ;func main(){} is added; unsure of Gode Golf golang norms.

Clojure, 40 bytes
(if(even?(count(filter #(= %\n)s)))\y\n)

Try it online!

C (GCC) 42 bytes
g(char*a){return*a?"yn"[(g(a+1)^*a)&1]:1;}

Try in online!
Solution is simply based on XNOR operation.

JavaScript (ES6), 71 bytes
f=a=>(a.split("").map(b=>(b=="y")?1:-1).reduce((b,c)=>b*c)==1)?"y":"n";

Prolog (SWI), 56 bytes
[H,H]-121.
[_,_]-110.
[A]-A.
[A,B|T]-S:-[A,B]-C,[C|T]-S.

Try it online!

Common Lisp, 52 bytes
(lambda(s)(reduce(lambda(a b)(if(eq a b)#\y #\n))s))

Try it online!

05AB1E, 7 bytes
'n¢„ynè

Try it online!
'n¢„ynè  # full program
      è  # character in...
         # (implicit) commutative indèx...
   „yn   # literal...
      è  # at 0-based index...
         # (implicit) commutative, modular indèx...
  ¢      # number of...
'n       # literal...
  ¢      # s in...
         # implicit input
         # implicit output

Thunno 2, 8 bytes
'nc`ynsi

Try it online!
Same as all the other answers
'nc`ynsi  # Implicit input
'nc       # Count of "n"s
      si  # modularly indexed
   `yn    # into the string "yn"
          # Implicit output

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


text:
Rolling Quine Dice
Create a program that outputs itself.
However, if the source code is repeated n times (meaning to concatenate a copy of the source code to the end n-1 times), then there should be 1/n probability outputting the original source code, a 1/n probability of outputting the source code repeated twice, a 1/n probability of outputting the source code repeated three times, ..., and a 1/n probability of outputting the source code n times.
For example, if your program is foobar, then it should always output exactly foobar.
However, if you run foobarfoobarfoobarfoobar, then there should be a ¼ chance each of outputting foobar, foobarfoobar, foobarfoobarfoobar and foobarfoobarfoobarfoobar.

The distribution of each possible output should be equal
In addition to standard I/O methods applying and standard loopholes forbidden, standard quine rules apply (can't access its own source, etc.)
This is code golf so shortest answer in bytes wins

Is pseudorandom good enough?

@wastl Yep, that's alright

Your definition is slightly off. If you repeat it 1 time (i.e. foobarfoobar) then it'd only print foobar

@Veskah foobarfoobar is foobar repeated two times, not once.

@Nit You start with the source. If you use it again, you have only repeated it once but have two instances.

@Veskah I'd say this is just not how the phrase works, but "by concatenating a copy of the source code to the end n times" seems to imply what you say. However, then the probabilities don't add up to 1.

Yeah, I'll clear up the ambiguity. I would agree for repeating 3 times would be foobarfoobarfoobar but that would be inconsistent

Perl 5, 82 80 bytes
$s=q($s=q(%s);printf"$s\n+1#",$s for 0..rand);printf"$s\n+1#",$s for 0..rand
+1#

Try it online! or Test suite

Jelly, 24 22 bytes
“Ṿ;ẋŻɼLX¤¤µ”Ṿ;ẋŻɼLX¤¤µ

Try it online!
Try it x4!
“Ṿ;ẋŻɼLX¤¤µ”Ṿ;ẋŻɼLX¤¤µ
“Ṿ;ẋŻɼLX¤¤µ”              String literal: Ṿ;ẋŻɼLX¤¤µ
            Ṿ             Uneval. Return “Ṿ;ẋŻɼLX¤¤µ” (with quotes)
             ;            Append the initial string. Yields the source code.
                ɼ         Apply the preceding link to the register and store the
                          result in the register.
               Ż          Prepend 0.
                          Each time Żɼ is used when the source code is repeated
                          the register's length increases by one.
                          We can't use ‘ because it closes string literals.
                 L        Length. Returns the number of times the source code has
                          been repeated up till now.
                  X       Random element. If ɼ results in n, X returns a random
                          integer between 1 and n.
                   ¤      Combines ŻɼLX as a nilad.
              ẋ           Repeat the source code a random number of times between
                          1 and n.
                    ¤     Close everything from the initial string literal as a
                          nilad.
                     µ    Start a new monadic chain. The register gets updated
                          once for time the code is repeated but only the final
                          repetition will result in output.

05AB1E, 32 bytes
"34çìDJ¼32ôн¾L×Ω"34çìDJ¼32ôн¾L×Ω

Try it online!
Explanation
"34çìDJ¼32ôн¾L×Ω"                   # push this string
                 34ç                # push a "-character
                    ì               # prepend it to the string
                     DJ             # duplicate and join the copy to the string
                       ¼            # increment the counter
                        32ô         # split the string into pieces of size 32
                           н        # take the first one
                            ¾L×     # repeat it for each in [1 ... counter]
                               Ω    # pick one at random

Could you add an explanation when you have a chance?

@Shaggy: Thanks for reminding me :)

Gol><>, 21 bytes
:QoaonC|P\Sx*F2ssS"
0

Try it online!
Explanation:
:Q     |     If the top of stack is 0, skip to next |
             Top of stack is implicitly 0
        P    Increment top of stack
         \   Redirect pointer down]
0:QoaonC|P\Sx*F2ssS"  Increment for each copy of the source code
0:QoaonC|P\Sx*F2ssS"

         \   Redirect back to the right
          Sx*  Multiply the number of copies of the source code by a random number between 0 and 1
             F      Repeat that many times
              2ss   Push a double quote
                 S" Print the source code minus the quote, newline and 0
 :Q       If top of stack is not 0
   oaonC  Print the quote, a newline and a 0 to complete the source code and continue the loop
        \Sx*   Error on the * for some reason

Alice, 35 bytes
"d3a*h-&;adddd12h&}Uh*t&w.odt,k@
 !

Try it online!
Explanation
"

Like in many quines in 2D languages, this starts with a " that wraps around to itself and pushes the entire first line except the " itself.
d3a*h-&;

Adding one or more additional copies of the source code will place some implicit spaces at the end of the string literal.  To make this actually a quine, we truncate the stack at 31 characters.
addd

Push a newline, then the stack height three times.  The values pushed as the stack height are 32 (the space in the second line), 33 (the ! in the second line), and 34 (the initial ").
d

Push the stack height again, this time as the length of the original source code (35).
1

Initialize a counter at 1.  This will count the number of times the source code is repeated.
2h&}

Turn right three times in place (i.e., turn left).  Each additional repetition of the source code will contribute an h in the same column as this }, thus incrementing the counter.  When the IP returns to the }, turn right again to continue in the same direction.
Uh

Take a uniform random number from 0 to n-1, then add 1 to get the number of times to output the original source.
*t&w

Multiply by the previously pushed stack height (code length), then repeat the following that many times by pushing a return address that many times minus one.
.o

Output the top of the stack without destroying it.
dt,

Move the bottom stack entry to the top.
k@

Repeat, then terminate after the loop is finished.

JavaScript (Node.js), 62 bytes
(f=a=>b=>b?f(a+.5):`(f=${f})(1)`.repeat(1+Math.random()*a))(1)

Try it online!

Either I'm very unlucky, or this can't print more than two copies of the original source code.

@Nitrodon Thanks, fixed

Charcoal, 58 bytes
≔´θ´⎚´×´⊕´‽´Ｌ´⊞´Ｏ´υ´ω´⁺´⪫´⁺´´´≔´θ´´´´´θθ⎚×⊕‽Ｌ⊞Ｏυω⁺⪫⁺´≔θ´´θ

Try it online! No verbose version because the deverbosifier currently chokes on "´". Mostly based on the Charcoal quine from Golf you a quine for great good!. Explanation:
≔´θ´⎚´×´⊕´‽´Ｌ´⊞´Ｏ´υ´ω´⁺´⪫´⁺´´´≔´θ´´´´´θθ

Assign the literal string θ⎚×⊕‽Ｌ⊞Ｏυω⁺⪫⁺´≔θ´´θ to θ.
⎚

Clear any previous output, so that only the last output takes effect.
×⊕‽Ｌ⊞Ｏυω

Push the empty string to the predefined array. This makes the array length equal to the number of repetitions processed so far, so take its length, take a random number the implicit exclusive range, add 1, and repeat the following string that many times.
⁺⪫⁺´≔θ´´θ

Prepend the literal string ≔ to θ, then insert literal ´s between each character, then suffix another copy of θ.

Python 3.8 (pre-release), 118 116 bytes
for i in(1,c:=0):
 exec(s:="from random import*;c+=i or print('for i in(1,c:=0):\\n exec(s:=%r)#'%s*randint(1,c))")#

Try it online!


text:
Sum of replicated matrices
Given a list of numbers \$[a_1, a_2, ... a_n]\$, compute the sum of all the matrices \$A_i\$ where \$A_i\$ is defined as follows (\$m\$ is the maximum of all \$a_i\$):
$$
\begin{array}{c|cc}
       & 1 & 2 & \cdots & i-1 &  i  & i+1 & \cdots &  n  \\
\hline
1      & 0 & 0 & \cdots &  0  & a_i & a_i & \cdots & a_i \\
2      & 0 & 0 & \cdots &  0  & a_i & a_i & \cdots & a_i \\
\vdots &   & \vdots & & \vdots & & \vdots & & \vdots \\
a_i    & 0 & 0 & \cdots &  0  & a_i & a_i & \cdots & a_i \\
a_{i+1}& 0 & 0 & \cdots &  0  &  0  &  0  & \cdots &  0  \\
\vdots &   & \vdots & & \vdots & & \vdots & & \vdots \\
m      & 0 & 0 & \cdots &  0  &  0  &  0  & \cdots &  0  \\
\end{array}
$$
Example
Given the input [2,1,3,1] we construct the following matrix:
$$
\left[\begin{matrix}
2 & 2 & 2 & 2 \\
2 & 2 & 2 & 2 \\
0 & 0 & 0 & 0 \\
\end{matrix}\right]
+
\left[\begin{matrix}
0 & 1 & 1 & 1 \\
0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 \\
\end{matrix}\right]
+
\left[\begin{matrix}
0 & 0 & 3 & 3 \\
0 & 0 & 3 & 3 \\
0 & 0 & 3 & 3 \\
\end{matrix}\right]
+
\left[\begin{matrix}
0 & 0 & 0 & 1 \\
0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 \\
\end{matrix}\right]
=
\left[\begin{matrix}
2 & 3 & 6 & 7 \\
2 & 2 & 5 & 5 \\
0 & 0 & 3 & 3 \\
\end{matrix}\right]
$$
Rules and I/O

you may assume the input is non-empty
you may assume all the inputs are non-negative (0≤)
the input can be a \$1×n\$ (or \$n×1\$) matrix, list, array etc.
similarly the output can be a matrix, list of lists, array etc.
you can take and return inputs via any default I/O format
your submission may be a full program or function

Test cases
[0] -> [] or [[]]
[1] -> [[1]]
[3] -> [[3],[3],[3]]
[2,2] -> [[2,4],[2,4]]
[3,0,0] -> [[3,3,3],[3,3,3],[3,3,3]]
[1,2,3,4,5] -> [[1,3,6,10,15],[0,2,5,9,14],[0,0,3,7,12],[0,0,0,4,9],[0,0,0,0,5]]
[10,1,0,3,7,8] -> [[10,11,11,14,21,29],[10,10,10,13,20,28],[10,10,10,13,20,28],[10,10,10,10,17,25],[10,10,10,10,17,25],[10,10,10,10,17,25],[10,10,10,10,17,25],[10,10,10,10,10,18],[10,10,10,10,10,10],[10,10,10,10,10,10]]

I'm guessing there's a font difference or something.  I see you rolled back my edit.  This is how it currently looks to me https://imgur.com/a06RH9r  This is Chrome on Windows 10.  The vertical ellipses are not rendered in monospace for some reason, and don't align with the columns.  That's why I changed it.  But I guess it must look different in different environments.

Definitely a font issue. Both revisions are misaligned on my screen.

May we return the result transposed?

we need mathjax!

@Adám: I'm gonna say no to that, however feel free to include a solution in your post that does so.

Jelly, 10 5 bytes
ẋ"z0Ä

Try it online!
How it works
ẋ"z0Ä  Main link. Argument: A (array)

       e.g. [2, 1, 3, 1]

ẋ"     Repeat each n in A n times.

       e.g. [[2, 2   ]
             [1      ]
             [3, 3, 3]
             [1      ]]

  z0   Zipfill 0; read the result by columns, filling missing elements with 0's.

        e.g. [[2, 1, 3, 1]
              [2, 0, 3, 0]
              [0, 0, 3, 0]]

    Ä  Take the cumulative sum of each row vector.

       e.g. [[2, 3, 6, 7]
             [2, 2, 5, 5]
             [0, 0, 3, 3]]

R, 80 bytes
n=sum((a=scan())|1);for(i in 1:n)F=F+`[<-`(matrix(0,max(a),n),0:a[i],i:n,a[i]);F

Try it online!
Takes input from stdin; prints a 0x1 matrix for input 0, which prints out like
	[,1]

For those wondering, F is a built-in global variable whose initial value is FALSE. Here it's coerced to 0 and used as the initial value of the cumulative sum. This answer demonstrates the reason not to use F and T except in code specifically designed never to be actually used!

Haskell, 70 66 51 bytes
g x=[scanl1(+)[sum[n|n>=r]|n<-x]|r<-[1..maximum x]]

Try it online!

As a puzzle, there is a 54 byte version ;)

@BMO How about 51 bytes instead?

Very nice! Mine was this :)

APL (Dyalog Unicode), 8 bytesSBCS
Full program. Prompts stdin for list, prints matrix to stdout.
Uses Dennis's method.
+\⍉↑⍴⍨¨⎕

Try it online!
⎕ stdin
⍴⍨¨ reshape-selfie of each
↑ mix list of lists into matrix, filling with 0s
⍉ transpose
+\ cumulative row-wise sum
The ⍉ doesn't make any computational difference, so it could potentially be left out and \ changed to ⍀ to sum column-wise instead of row-wise.

JavaScript (ES6), 88 79 bytes
Returns [] for [0].
f=(a,y,b=a.map((_,x)=>a.map(c=>y>=c|x--<0?0:s+=c,s=0)|s))=>s?[b,...f(a,-~y)]:[]

Try it online!

Python 2, 85 bytes
lambda x:[[sum(n*(n>j)for n in x[:i+1])for i in range(len(x))]for j in range(max(x))]

Try it online!

Octave, 64 bytes
@(x,k=a=0*(x+(1:max(x))'))eval"for i=x;a(1:i,++k:end)+=i;end,a";

Try it online!
Explanation:
Yet again: Expressions in the argument list and eval are used in one function :)
This takes x as input, and creates two identical matrices filled with zeros, with the dimensions k=a=zeros(length(x),max(x)). This is achieved by adding the horizontal vector x with a vertical vector with 1:max(x), implicitly expanding the dimensions to a 2D-array, then multiplying this with zero. ~(x+...) doesn't work unfortunately, since that forces a to be a logical array throughout the rest of the function.
for i=x is a loop that for each iteration makes i=x(1), then i=x(2) and so on. a(1:i,k++:end) is the part of the matrix that should be updated for each iteration. 1:i is a vector saying which rows should be updated. If i=0, then this will be an empty vector, thus nothing will be updated, otherwise it's 1, 2 .... ++k:end increments the k matrix by one, and creates a range from the first value of this matrix (1,2,3...) and up to the last column of the a matrix. +=i adds the current value to a. end,a ends the loop and outputs a.

Wolfram Language (Mathematica), 42 bytes
Thread@Accumulate@PadRight[#~Table~#&/@#]&

Try it online!

Java 10, 142 135 134 bytes
a->{int l=a.length,i=0,j,s,m=0;for(int q:a)m=q>m?q:m;int[][]r=new int[m][l];for(;i<m;i++)for(j=s=0;j<l;j++)r[i][j]=s+=i<a[j]?a[j]:0;return r;}

-7 bytes thanks to @ceilingcat.
Try it online.
a->{              // Method with integer-array parameter and integer-matrix return-type
  int l=a.length, //  Length of the input-array
      i,j,        //  Index integers
      s,          //  Sum integer
  m=0;for(int q:a)m=q>m?q:m;
                  //  Determine the maximum of the input-array
  var r=new int[m][l];
                  //  Result-matrix of size `m` by `l`
  for(;m-->0;)    //  Loop `i` over the rows
    for(j=s=0;    //   Reset the sum to 0
        j<l;j++)  //   Inner loop `j` over the columns
      r[m][j]=s+= //    Add the following to the sum `s`, add set it as current cell:
        m<a[j]?   //     If the row-index is smaller than the `j`'th value in the input:
         a[j]     //      Add the current item to the sum
        :         //     Else:
         0;       //      Leave the sum the same by adding 0
  return r;}      //  Return the result-matrix

GolfScript, 39 bytes
{.$):M;;{[.](*[0]M*+M<}%zip{{\.@+}*]}%}

Try it online!
Uses Dennis's algorithm.

Ruby, 50 bytes
->a{(1..a.max).map{|n|w=0;a.map{|r|w+=(r<n)?0:r}}}

Try it online!

Pari/GP, 60 bytes
a->matrix(vecmax(a),#a,i,j,vecsum([a[k]|k<-[1..j],a[k]>=i]))

Try it online!

Japt, 10 bytes
ÔËÆD
z ®å+

Try it (includes all test cases)

Husk, 7 bytes
m∫T0m´R

Try it online!
Dennis' method.

k, 24 Bytes
{+\'+(x#'x),'(x-|/x)#'0}

Dennis algorithm
Sample
  {+\'+(x#'x),'(x-|/x)#'0}2 1 3 1
(2 3 6 7;2 2 5 5;0 0 3 3)

numeric arrays in k are represented as a sequence of values without separators, so 2 1 3 1 is the same as [2,1,3,1] in other languages.
k Use the syntax (..;..;..) to represent an heterogeneous or multi-level list, so (2 3 6 7;2 2 5 5;0 0 3 3) is the same as [[2,3,6,7],[2,2,5,5],[0,0,3,3]] in other languages
Explanation

{..x..} defines an anobymous function with implicit arg x
+\array is the cummulative sum of the elems of the array
f'matrix applies f to each row ('=each) of the matrix preserving matrix shape, so +\'matrix calculates cummulative sum of the elems of each row of the matrix
n#x signifies take n copies of x value. if n and x are
both arryas of the same length, n#'x applies # to each pair, so
2 1 3 1#'2 1 3 1 is the same as (2#2; 1#1; 3#3; 1#1) and
evaluates to (2 2;,1;3 3 3;,1). NOTE one-item list is represented as ,item
a,b joins (catenates) arrays a and b. a,'b applies , to each corresponding items of a and b: if both are matrices of the same shape, catenates each corresponding pair of rows
|/array applies binary operator | (max) over the elements of the array (reduce), so |/2 1 3 1 is equivalent to 2|1|3|1 and reduces to 3
(x-|/x) substract to each element of x the maximum of the array, so 2 1 3 1 - |/2 1 3 1 is the same as 2 1 3 1 - 3 and evaluate to -1 -2 0 -2
array#'0 is "take n copies of 0" for each value n in array. It really uses "abs(n) take 0", so we don't worry about sign. -1 -2 0 -2#'0 evaluates to (,0;0 0;();0 0). NOTE.- () is the empty array

k applies unary operators and binary operators right to left, and parenthesis indicate precedence. NOTE.- k uses one-letter symbols, with two meanings (unary op or binary op) depending of context (example + as binary op is sum, but as unary op is flip (transpose).

#' is a binary op modified by ' adverb. Its arguments are (x-|/x) and 0.

Evaluates x-|/x first. | it's a binary op (max), but adverb / convert it to unary (max over x), and evaluates to 3. The resulting x-3 is a binary op (minus), with args xand 3, and evals to -1 -2 0 -2
-1 -2 0 -2#'0 evals to (,0;0 0;();0 0)

The actual expr is +\'+(x#'x),'(,0;0 0;();0 0). , is a binary op (join) modified by ' adverb (each): we need to evaluate the left arg (x#'x)

x#'x is 2 1 3 1#'2 1 3 1, and applies binay op # (take) to each pair. The result is (2 2;,1;3 3 3;,1)
(2 2;,1;3 3 3;,1),'(,0;0 0;();0 0) applies binary op , modified by (') each, and join each pair of corresponding values. The result is (2 2 0;1 0 0;3 3 3;1 0 0)

+ is a monad operator that transpose (flip) the matrix, so the result is (2 1 3 1;2 0 3 0;0 0 3 0)
+\'matrix calculates cummulative sums of each row of the matrix, so eval to `(2 3 6 7;2 2 5 5;0 0 3 3)