text:
Counting painted sides of cubic shapes
Sandbox
Many of us have seen math problems where a shape made of unit cubes is dipped in paint, and the answer is the number of painted sides. We'll generalize that problem in this challenge.
Input
A 3-dimensional matrix of 0s and 1s.
Output
A non-negative integer
Challenge
Given a n by m by k matrix of 0s and 1s, we can view the matrix as a 3D shape by considering a n by m by k rectangular prism broken up into n * m * k unit cubes, and the unit cubes  corresponding to the 0 values in the matrix are removed.
For example, the matrix [[[1,0],[0,0]],[[1,1],[0,1]]] represents the shape

Given such a shape, the code-golf challenge is to output the number of painted sides on the shape if the whole shape is dunked in paint.
Test Cases
[[[1,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,0,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]]] -> 54

[[[1,0],[0,0]],[[1,1],[0,1]]] -> 18

[[[1]],[[0]],[[1]]] -> 12

[[[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,0,0,0,0,1],[1,0,0,0,0,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,0,0,0,0,1],[1,0,0,0,0,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,0,1,1,0,1],[1,0,1,1,0,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,0,1,1,0,1],[1,0,0,1,0,1],[1,1,1,1,1,1]],[[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1]]] -> 168

[[[0,0,0],[0,1,0],[0,0,0]],[[0,1,0],[1,0,1],[0,1,0]],[[0,0,0],[0,1,0],[0,0,0]]] -> 30

[[[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1]],[[1,1,1,1,1],[1,0,0,0,1],[1,0,0,0,1],[1,0,0,0,1],[1,1,1,1,1]],[[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]],[[1,1,1,1,1],[1,0,0,0,1],[1,0,0,0,1],[1,0,0,0,1],[1,1,1,1,1]],[[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1]]] -> 150

[[[1,1,0,1,1],[1,1,0,1,1],[1,1,0,1,1]],[[1,1,0,1,1],[1,1,0,1,1],[1,1,0,1,1]],[[1,1,0,1,1],[1,1,0,1,1],[1,1,0,1,1]],[[1,1,0,1,1],[1,1,0,1,1],[1,1,0,1,1]]] -> 104

[[[0,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,0,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]]] -> 54

Can we take the input as n, m, k and a 1D list of zeros and ones representing the “unrolled” 3D values?

@LuisMendo yes you can. The input is flexible.

APL (Dyalog Unicode), 55 48 bytes
≢⍸↑2≠/¨⊢∘g\3⍴⊂2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←⍉⍤2⍉∘⌽)⍣6~⎕

Try it online!
-7 bytes thanks to @ngn.
Improvements:

2 3 1⍉ → ⍉⍤2⍉: Replace "cycle the axes once" with "swap 1st and 3rd axes, then 2nd and 3rd"
{⍵(g⍵)(g g⍵)} → ⊢∘g\3⍴⊂: A scan that ignores the left arg and applies g to the right arg, so it works like this:

3⍴⊂x gives (x x x)
⊢∘g\3⍴⊂x gives (x)(x ⊢∘g x)(x ⊢∘g x ⊢∘g x)
which is the same as (x)(g x)(g g x) because:
  x ⊢∘g x
→ x ⊢ g x
→ x ⊢ (g x)
→ g x

APL (Dyalog Unicode), 55 bytes
{≢⍸↑2≠/¨⍵(g⍵)(g g⍵)}2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←2 3 1⍉⌽)⍣6~⎕

Try it online!
A full program that takes a 3D array. Uses the flood fill already used here. Another key idea is g←2 3 1⍉⌽, which effectively cycles through all six sides when applied with ⍣6 (repeat six times).
How it works
{≢⍸↑2≠/¨⍵(g⍵)(g g⍵)}2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←2 3 1⍉⌽)⍣6~⎕

~⎕                ⍝ Logical negation of the input
(1,g←2 3 1⍉⌽)⍣6   ⍝ Pad with a layer of ones on all six sides
2(g⊣(⌈∧⊢)/,)⍣6⍣≡  ⍝ Flood fill from the outside, changing 1s to 2s:
2(        ,)      ⍝   Prepend 2 on the last axis
   ⊣(⌈∧⊢)/        ⍝   Pairwise lcm(max(x,y),y) over the last axis
                  ⍝   Effectively, propagate 2 to an adjacent 1 on the right
  g               ⍝   Cycle the orientation once
            ⍣6⍣≡  ⍝   Repeat 6 times until the flood fill is complete
2=                ⍝ Map 2s to 1s, and anything else to 0s
{⍵(g⍵)(g g⍵)}     ⍝ Construct 3 arrays so that each axis becomes the last axis
2≠/¨              ⍝ Extract faces (where 0 and 1 are adjacent) for each array
≢⍸↑               ⍝ Count ones in all arrays

2 3 1⍉⌽ -> ⍉⍤2⍉∘⌽

⍵(g⍵)(g g⍵) -> ⊢∘g\3⍴⊂⍵ and remove the { }

@ngn Wow, the second is really cool.

Wolfram Language (Mathematica), 103 102 bytes
Count[x=ImageData@FillingTransform@Image3D@#~ArrayPad~1;x~Differences~#&/@{1,{0,1},{0,0,1}},1.|-1.,4]&

Try it online!
To use FillingTransform (replace all the inner 0 with 1), I have to convert the data to Image3D and convert it back. The rest is just to count the number of nonzero consecutive differences etc.

If you don't mind, could you add the other test cases to your TIO link? I'm trying to manually test them but it's taking a while.

59 bytes by using MORE built-ins: Try it online!

@mypronounismonicareinstate Nice! / 49

Python 2, 493 bytes
A=lambda*z:0<sum(abs(a-b)for a,b in zip(*z))<2
R=lambda c:reduce(lambda a,b:a|b,c)
def C(c,d,h,w):
 a=[[{(i/w/h,i/w%h,i%w)}for i in range(d*h*w)if c[i]-v]for v in[1,0]]
 for r in a:
	i=0
	for j in range(len(r)**2):i=j/len(r);c=[[f for f in r[i:]if any(A(j,k)for k in f for j in r[i])^j]for j in[0,1]];r[i:]=(c[0]and[R(c[0])])+c[1]
 a[0]=[s for s in a[0]if all(0<e[i]<[d,h,w][i]-1for i in[0,1,2]for e in s)]
 p,q=[sum(6-sum(A(x,y)for x in r)for y in r)for r in[k and R(k)for k in a]]
 print q-p

Try it online!
Takes input as a flattened array along with depth, height, and width.
How?

Find 6-connected components of 0s and of 1s
Remove the components of 0s which contain a 0 on the outer edge
Take 6 times the number of 1s minus the number of 1s that border each other to get the number of 1s that are exposed to any 0. This includes 0s on the inside (internal 0s / air pockets), so:
Subtract (6 times the number of internal 0s minus the number of internal 0s that border each other) to get the number of internal 0s that are exposed to any 1. This subtracts all of the faces on the inside.
Done!

# Are the arguments adjacent via 6-connectivity?
A=lambda *z:0<sum(abs(a-b)for a,b in zip(*z))<2

R=lambda c:reduce(lambda a,b:a|b,c)

def C(c,d,h,w):
    a=[
        [
            {(i/w/h,i/w%h,i%w)}
            for i in range(d*h*w)
            if c[i]-v
        ]
        for v in[1,0]

    ]
    # a[0]: set of coordinates of all 0s
    # a[1]: set of coordinates of all 1s
    # Find connected components:
    for r in a:
        i=0
        for j in range(len(r)**2):
            # for each index i
            i=j/len(r);
            # do len(r) passes:
            # c[0]: all components with index > i+1 that are adjacent to component i
            # c[1]: all components with index > i+1 that are not adjacent to component i
            c=[
                [f for f in r[i:]if any(A(j,k)for k in f for j in r[i])^j]
                for j in[0,1]
            ];
            # Replace components i and higher with:
            r[i:]=(
                # If c[0] is nonempty, then the union of c[0]
                c[0]and[R(c[0])]
            )+c[1] # append c[1]
    # a[0]: set of connected components of 0s
    # a[1]: set of connected components of 1s
    # Remove all of a[0] that border the outside:
    a[0]=[
        # Filter for:
        s for s in a[0]if
        all(
            # The coordinates along each axis are between 1 and that axis's length minus 2, inclusive
            0<e[i]<[d,h,w][i]-1
            for i in[0,1,2]
            # For all points
            for e in s
        )
    ]
    # a[0] now: set of connected components of 0s that do not border the outside
    p,q=[
        sum(
            6- # cube contributes 6 sides
            sum(A(x,y)for x in r) # minus the number of adjacent cells
            for y in r # for each cube
        )
        for r in # for each connected component
        [k and R(k)for k in a]
    ]
    print q-p

Python 3 with NumPy, 177 161 bytes
-16 bytes thanks to @fireflame241 !
f=lambda l:g(pad(pad(l,1)-2,1)+2,1,1,1)
def g(l,*i):l[i]+=2;return l[i]%2if l[i]-2else sum(g(l,*(t*d+i))for d in eye(3,3,0,int)for t in[1,-1])
from numpy import*

Try it online!
Big idea:
DFS over all outer empty cells. Every time an outer empty cell touches a cube, adds 1 to the counter.
Explanation:

0 denotes air (empty cell), odd positive numbers denote walls, and even positive numbers denotes paint.
First, pad everything with a layer of 0 (air), so all outer air cells are connected: pad(l,1)
Then, pad everything with a layer of 2 (paint), which acts as a barrier to prevent out of bound search later. To do this, subtracts 2 from all cells, pad everything with 0, then adds 2 back: pad(arr - 2, 1) + 2
Start DFS at l[1,1,1], which is guaranteed to be an outer air cell.
At each DFS step (function g):

If current cell is paint, stops recursion.
If current cell is wall, adds 1 to counter, and stops recursions.
If current cell is air, changes it to paint, and recurs on the 6 neighbors.

-16 bytes (footer + input removed to fit in comment) by avoiding keyword arguments: using pad defaulting to 0 and filling up positional arguments in eye.

@fireflame241 the +2 is really clever, thanks!

MATL, 37 36 35 bytes
e7BYa~6&1ZIt1)-tz6*yZybfX[hhtZPq~z-

Input is a row vector of zeros and ones, and a row vector of three integers with dimensions from inner nesting level to outer.
Try it online! Or verify all test cases.
Explanation
The code initially adds a frame of empty space around the 3D array. Any cell that is not space connected to that frame is filled. This has the effect of filling any holes in the original 3D shape.
The number of painted faces is the number of cubes in that filled shape times 6, minus the number of cubes that touch some other cube (two cubes touching means a face is not accessible to the paint; pairs are counted twice).
To detect which cubes touch, all pairwise distances between the cubes are computed, and two cubes touch if their distance is 1.
e      % Implicit inputs: vector or zeros and ones, and 3-element vector specifying
       % size along each dimension. Reshape the first according to the second. This
       % produces the 3D array
7BYa   % Pad the 3D array with a frame of zeros along the three dimensions
~      % Negate. This changes 0 to 1 and vice versa (*)
6&1ZI  % Label connected components using 6-connectivity in 3D (so no diagonals)
       % This considers the zeros in (*) as background, and nonzeros as foreground.
       % The foreground cells are labelled with a different integer according to
       % indicate the component. There will be an outer component that will include
       % the added frame and any space surrounding the shape, and potentially more
       % components if the shape has inner holes
t1)-   % Duplicate Subtract the upper-right-front entry from each entry. This
       % makes the outer connected component (originally the space surrounding the
       %  shape) equal to 0, and other components or brackground become nonzero.
       % So now the shape plus any inner holes in it are nonzero (**)
tz6*   % Duplicate. Number of nonzeros times 6. This is the maximum number of faces
       % of unit cubes that could be painted (some won't actually get pointed,
       % namely any face that touches any other face) (***)
yZy    % Duplicate from below: pushes a copy of (**). Get its size as a length-3
       %  vector
bf     % Bubble up: moves the original copy of (**) to the top. Push linear indices
       % of its nonzero entries. Linear indices run down, then accros (left to
       % right), then front to bottom
X[     % Convert linear indices to a set of three indices assuming an array of the
       % specified size. Gives three column vectors
hh     % Concatenate veftically twice. This gives a 3-column matrix where each row
       % contains the coordinates of a cube in (**)
tZP    % Duplicate. Pairwise distances between rows of the 3-column matrix and
       % those of its copy
q~     % Subtract 1, negate. This gives 1 for distances equal to 1, and 0 otherwise
z      % Number of nonzeros
-      % Subtract from (***). Implicit display

I'd be curious to understand how this works, since I don't know MATL

@DonThousand I added a general explanation, then detailed code comments. I'd be interested to know if any part is not clear

Ah I see, that makes sense.

JavaScript (ES6),  295  291 bytes
a=>a.map((s,z)=>s.map((r,y)=>r.map((v,x)=>v|!(g=(x,y,z,R=a[z]&&a[z][y])=>R&&1/R[x]?R[x]?0:R[x]++|[0,1,2,3,4,5].some(n=>(i=n&1||-1,g(n&6?x:x+i,n&2?y+i:y,n&4?z+i:z)))|--R[x]:1)(x,y,z)))).map((s,z,a)=>s.map((r,y)=>r.map((v,x)=>n+=v&&!r[x+1]+!((q=s[y+1])&&q[x])+!((q=a[z+1])&&q[y][x]))),n=0)|n*2

Try it online!
NB: This is a bit too slow to reliably complete the 6th test case on TIO.

05AB1E, 75 bytes
-.øε0δ.ø©}ε®Ù.ø}D€øDø€ø««εÁÁεN3@iD0ÚPi1V}YiγÁεN2@id}}À˜}}}ÀÀ2V}€`€ü2€`ʒË≠}g

Dang, this was hard in 05AB1E.. But it works now. 05AB1E and matrices are already a bad combination, so add an additional dimension and it's a complete disaster, haha..
Try it online or verify all test cases.
Explanation:
Step 1: Surround the entire input 3D matrix with a layers of empty cells (0s) in each dimension:
-                    # Transform all values into 0s by subtracting the values in the
                     # (implicit) input 3D-matrix by the values in the (implicit) input
 .ø                  # Surround the (implicit) input-matrix with this 2D-matrix of 0s as
                     # both leading and trailing item
   ε                 # Map each 2D matrix of the 3D matrix to:
     δ               #  For each row of the 2D matrix:
    0 .ø             #   Surround it with a leading and trailing 0
        ©            #  Store the modified 2D matrix in variable `®` (without popping)
   }ε                # After the map: map over each 2D matrix in the 3D matrix again:
     ®Ù              #  Uniquify the last 2D matrix that was stored in `®`,
                     #  so we'll have a row of 0s wrapped inside a list
       .ø            #  Surround each 2D matrix with this row of 0s
    }                # And close this map as well

(Note: the z-axis actually contains two surrounding empty cells instead of one, but this doesn't really matter for the rest of the program.)
Step 2: Get a list of all strings of cells along the x, y, and z axes respectively:
D                    # Duplicate the current 3D-matrix, which of itself already contains
                     # all strings of cells along the x-axis
 €                   # Map each 2D matrix of the 3D matrix to:
  ø                  #  Zip/transpose; swapping rows/columns
D                    # Duplicate as well, which are the strings of cells along the y-axis
 ø                   # Zip/transpose; swapping rows/columns of this 3D matrix
  €                  # Map each 2D matrix of the 3D matrix to:
   ø                 #  Zip/transpose; swapping rows/columns
                     # And we now also have the strings of cells along the z-axis
««                   # Merge all three lists together

This will result in a 3D matrix with three inner 2D matrices (one for each dimension), which are each lists of strings of cells.
Step 3: Fill all inner bubbles with 1s:
ε                    # Map each 2D matrix of the 3D matrix to:
 ÁÁ                  #  Rotate the rows of the matrix twice towards the left
   ε                 #  Map each string of cells in the current 2D matrix to:
    N3@i             #   If the 0-based index is >= 3:
        D            #    Create a copy of the string of cells
         0Ú          #    Remove all leading and trailing empty cells
           Pi  }     #    If there are now only filled cells left:
             1V      #     Set flag `Y` to 1
         Yi          #    If flag `Y` is 1:
           γ         #     Split the string of cells into groups of equal adjacent values
            Á        #     Rotate these groups once towards the left
             ε       #     Map each group to:
              N2@i } #      If the 0-based index is >= 2:
                  d  #       Fill all empty cells (1 remains 1, 0 becomes 1)
             }À      #     After the map: rotate the groups back to the right
               ˜     #     And flatten it to a single string of cells again
   }}}ÀÀ             #  After the map: rotate the rows twice back towards the right
        2V           #  Reset flag `Y` back to 2 for the next iteration
}                    # Close the map

We basically skip the first and last strings of cells, since we know those are surrounding layers of empty cells we added in step 1. In addition, we also don't want to modify the second and second to last strings of cells, since those are the outer layers of the initial input 3D matrix. We do however want to start checking from the second string of cells onward until we find a solid string of filled cells (minus the surrounding empty cells). For all strings of cells after we've encountered such a solid string of filled cells, we want to transform them into solid strings of filled cells as well (minus the surrounding empty cells) to fill the bubble.
Step 4: Now that we've filled the bubbles, we want to get a list of all pairs of cells:
€`                   # Flatten the 3D matrix containing the three list of strings of
                     # cells one level down to a single list of strings of cells
  €                  # Map each string of cells to:
   ü2                #  Create overlapping pairs of cells
     €`              # And flatten this list of list of pairs one level down as well to a
                     # list of pairs

Step 5: Filter out any pairs of two empty or two filled cells, so we only have pairs containing one of each:
ʒ                    # Filter this list of paired cells by:
 Ë≠                  #  Check that both values in the pair are NOT the same
}                    # Close the filter

Step 6: Get the amount of pairs left containing both a filled and empty cell, and output it as result:
g                    # Pop and push the length of the filtered list
                     # (after which it is output implicitly as result)

Try it online with each of these steps output separately.


text:
Tents and Trees feasibility
Sequel to Verify Tents and Trees solution.
Background
Tents and Trees (try here) is a puzzle played on a square (or rectangular) grid, where the objective is to place tents horizontally or vertically adjacent to each of the trees, so that no two tents touch each other in 8 directions (horizontally, vertically, and diagonally) and the number of tents on each row/column matches the given clues.
Example puzzle and solution
In these examples, trees are T and tents are A.
Puzzle
  2 0 2 0 2 1
2 . T . T . .
1 . . . . T .
1 T . T . . .
2 . . . . . T
1 T . . . . .
0 . . . . . .

Solution
  2 0 2 0 2 1
2 . T A T A .
1 A . . . T .
1 T . T . A .
2 A . A . . T
1 T . . . . A
0 . . . . . .

Challenge
Given a grid with some trees, determine whether it is possible to place tents next to each of the trees so that they don't touch each other in 8 directions. Ignore the number clues in this challenge.
You may take the input in any reasonable way to represent a matrix containing two distinct values to represent a tree and an empty space respectively.
You can choose to follow your language's convention of truthy/falsy, or use two distinct values for true/false respectively.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
This uses the same notation as the above example; T for trees and . for empty spaces.
Truthy
. . .
. . .
. . . (empty board)

T .

. T .
. . T

. .
T T
. .

. T .
T . T
. T .

. . .
T T .
. T T
. . .

. T . .
. . . T
T T . .
. . . .

. T . . . .
. . . . . .
. . T . . T
. T . T . .
T . T . . .
. T . . T .

Falsy
(No space to place a tent)
T

T . T

T . T
. T .

. . . .
. T T T
T . . .

. T .
T T .
. T .

T . T
. . .
. T .

T . . . .
. . T . .
. T . T .
T . T . .
. T . . .

. . . . .
. T . . .
. T T . .
. . T T .
. . . . .

Can someone explain to me why T . T is Falsy? (I.e. why TAT is not a valid answer)  Is there a rule missing from the background, such as "There must be an equal number of Tents and Trees"?

@Chronocidal "Place tents horizontally or vertically adjacent to each of the trees," but that isn't fully clear. The linked prequel states "The number of tents equals the number of trees,
The tents do not touch each other in 8 directions, and
There is at least one way to associate every tent with an adjacent tree in 4 directions, so that every tree is used exactly once."

Python 3.8 (pre-release), 253 244 bytes
from itertools import*
f=lambda b,h,w:all(set(t:=[i%w+i//w*1jfor i,e in enumerate(b)if e])&set(s:=[*map(sum,zip(t,T))])or~any(abs(a-b)<2for a,b in combinations(s,2))+all(h>a.imag>-1<a.real<w for a in s)for T in product(*[[1,1j,-1,-1j]]*sum(b)))

Try it online!
-6 bytes thanks to @user202729 (chain comparisons)
-3 bytes thanks to @ovs (1jfor; …or a+1^b → …or~a+b for "implies" boolean operator)
# Itertools for combinations and product
from itertools import*
f=lambda b,h,w: all(
    # Test if a given set of tent position deltas works:
    # Positions are complex numbers: real part increasing to the right, imaginary part increasing down
    # (De Morgan shortened, so many expressions negated)
        # No tree is on a tent:
            # t:=Tree positions (1s)
            set(t:=[i%w+i//w*1j for i,e in enumerate(b)if e])
            # s:=Tent positions as sum of tree positions and deltas
            & set(s:=[*map(sum,zip(t,T))])
        # and difference between all distinct pairs oftrees is at least 2:
            or any(abs(a-b)<2for a,b in combinations(s,2))
        # and all trees are within rectangular boundary
            # (Using Python 2's quirky complex floordiv doesn't work since those return complex nums,
            # which don't have a total order.
            # Plus Python 38 has saves so much here; using 2 would be a waste anyway)
            >= all(h > a.imag > -1 < a.real < w for a in s)
    # For each possible delta (four directions, distance 1)
    # sum(b) is the number of tents since each tent contributes 1
    for T in product(*[[1,1j,-1,-1j]]*sum(b))
)

w>a.real>-1<a.imag<h?

@user202729 Ah, yes

Two tiny improvements: The space in 1j for is unnecessary, and +1^ can be replaced with >=.

@ovs That 1j for is wholly unintuitive, but I guess it makes a bit of sense from a parsing standpoint.

One more: or a>=b can be or~a+b.

Charcoal, 82 bytes
ＷＳ⊞υι≔⟦⟦⟧⟧θＦＬυＦ⌕Ａ§υιT«≔⟦⟧ηＦθ«υＦλ«Ｊ§μ⁰§μ¹A»Ｆ⁴«ＪκιＭ✳⊗μ¿›⁼.ＫＫ№ＫＭA⊞η⁺λ⟦⟦ⅈⅉ⟧⟧»⎚»≔ηθ»ＩＬθ

Try it online! Link is to verbose version of code. Takes input as newline-terminated strings and outputs the number of solutions. Explanation:
ＷＳ⊞υι

Read in the grid.
≔⟦⟦⟧⟧θ

Start with 1 solution for 0 tents.
ＦＬυＦ⌕Ａ§υιT«

Loop over the positions of the trees.
≔⟦⟧η

No tent positions for this tree found so far.
Ｆθ«

Loop over the tent positions for the previous trees.
υ

Print the grid.
Ｆλ«Ｊ§μ⁰§μ¹A»

Print the tents for this partial solution.
Ｆ⁴«

Check the four orthogonal directions.
ＪκιＭ✳⊗μ

Move to the relevant adjacent square.
¿›⁼.ＫＫ№ＫＭA

If this square is empty and is not bordered by a tent, ...
⊞η⁺λ⟦⟦ⅈⅉ⟧⟧

... then append its position to the previous partial solution and add it to the list of new partial solution.
»⎚

Clear the canvas after testing this tree.
»≔ηθ

Save the new solutions as the current solutions.
»ＩＬθ

Print the final number of solutions.

source: Stack Exchange

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

sort: votes


text:
Solve the dress problem
Background
Peter's Father, the Teacher of a dance-club, asks Peter a question:
Given are two natural numbers (\$\mathbb{N}\$ \$x\$ and \$y\$).
\$x\$ is the number of the garment types (e.g. shorts, shirts\$\dots\$) we have
\$y\$ is number of colors (e.g. green, blue, \$\dots\$) of each garment we have.
In the dance class, every one should be in a unique dress.
Example:

But:

Now tell me:
For every given \$x\$ and \$y\$, what is the maximum number of people who an visit our class?
Can you help Peter?
Challenge
The input should be two natural numbers (\$\forall  x,y\in\mathbb{N}\$) separated by a comma,.
The input can also be your languages equivalent for a list which has two elements.
The Output should be an Integer, the maximum number of people who can visit the dance-class.
Test cases
In:1,0
Out:0

In:0,0
Out:0

In:[2,2]
Out:4

In:3,2
Out:9

Rules

This is code-golf so the shortest code wins

Or, judging from the images, there are x pieces of clothing, each can be one of y colours. This would be x^y, right?

@ovs No example 2, 3 is not 2^3 which is 8. There are 9 possiblitys: 12,21,13,31,23,32,11,22,33

@math ovs just made a typo, the answer is clearly just y^x, with 0^0=0. IMO this is a poor challenge that should have been tested in the Sandbox.

For the last test case I only get 8 possibilities: 111, 112, 121, 122, 211, 212, 221, 222.

To look at it another way, it's really just a problem of figuring out MAXINT of a certain length in a certain base.  The length is the number of garments, the base is the number of colors.

Since 0^0 is undefined, it might have been better without zero in the input. (Also the term "natural number" is ambiguous in whether it includes 0 or not. One should use "positive integer" or "non-negative integer" instead.)

While I agree with @Bubbler about 0^0 being undefined, what really doesn't make sense here to me is an input of #,0 or 0,#.  If you have 0 items, there are no colors to be had.  If you have no colors, then your items are invisible, so they might as well not exist.

@Bubbler While I agree that it might be better to not have 0 as input, I don't understand your point of 0^0 being undefined. First of all, the challenge doesn't ask you to calculate 0^0. Secondly, "no agreed upon value" in the mathematical sense is very different from being undefined in computer languages. The article you link to ends with a ranges of computer language examples where 0^0 is defined (usually as 1). And that list is far from complete.

Perl 5 -p, 20 bytes
/,/;$_=$`*$'&&$'**$`

Try it online!

@See my comment to ovs. eg.v2,3 is not 2^3.

Fixed it.  Had the variables reversed.

Shouldn't 2,3 and 3,2 yield the same result?

No.  With 2 garments and 3 colors, you get 9 options: aa,
ab,
ac,
ba,
bb,
bc,
ca,
cb,
cc.  With 3 garments and 2 colors, you get 8 options:
aaa,
aab,
aba,
abb,
baa,
bab,
bba,
bbb

Both answers don't work for 0-inputs, I'm waiting for it to be clarified.
Husk, 2 bytes
Takes input as colors, garment types
Lπ

Try it online!
Explanation
Inputs: 2, 3

 π  (x, y) 1..x 's cartesian power by y.
           [1, 2] -> [[1,1],[1,2],[2,1],[1,3],[2,2],[3,1],[2,3],[3,2],[3,3]]
L   (x) Length of x.
           -> 9
    Implicit output

05AB1E, 4 bytes
Takes input as the specified format.
и<²β

Try it online!
Explanation
Example inputs: 2, 3

и    Repeat: ["3", "3"]
 <   Decrement: [2, 2]
  ²β From base (second input): 9
```

Porting your Husk answer to 05AB1E is an alternative 4-byter by taking the input in reverse order: L²ãg. I like your current 05AB1E more, though. :)

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


text:
Which languages are optimal for problems that require "reading" input while also writing to it like a stack
When encountering a problem whose input is meant to be read sequentially, but you may also want to push back onto the input like a stack, which languages have the optimal boilerplates for doing so, and how?
For example, from Create a Boolean Calculator, we have a string like:
1AND0OR1XOR1

We want to "pop" 5 chars 1AND0, compute it to be 0, then "push" it back to form:
0OR1XOR1

Then, repeat until there's only 1 char left. In this case:
0

It's trivial to write while loops and such, but this seems common enough in codegolf problems that there must be canonical forms. I wasn't able to find a tips question specifically about this setup though, and going through each tips question by language was difficult.

I think this question is very difficult to answer without a specific language tag. The answer will vary wildly based on the length of keywords and the language paradigm. I haven't VTC yet, but I think this is probably lacking focus unless you specify a language.

Hm, I guess I was hoping to pick my golfing language for these types of questions by knowing which was best at it.

I see, then it may be reasonable if you rephrase this as "in which language is doing task X the shortest" (that way it has a precise answer). I think that would probably make it the first of its kind though, so I'd advise asking something on meta. I'm wrong often enough about what the majority wants here so I wouldn't trust just me!

Why not write a challenge that requires this trick to be used? You basically want to sequentially replace a string prefix so if you require each step in the output you should find the best way to do that among the competing languages.

@FryTheEggman Isn't that basically [tag:code-golf] in a nutshell? :)

Instead of trying to "push back onto the input like a stack", why not just read all the input into a stack, and them work on the stack normally? In your example, you would pop the top five chars and push 0, etc. Some languages have a stack paradigm, so this is easy. For non-stack oriented languages, you can simulate a stack with an array or list

@Sanchises - Haha, that's a good idea. But likely if it became a real problem, I'd have to specify it much more tightly (what operations, etc.) or it would really have to be closed.

@LuisMendo - Yup, that was my "naive" idea. But for the Boolean problem I linked for example, I realized I need to start with the tiniest boilerplate possible to have even a chance at winning, scorewise. That's why I wanted to know what languages / techniques are hyperoptimized for this task.

This is probably much better approached with recursion either by functions like Haskell, (curry although has better pattern matching for this sort of thing), or predicates like in Prolog.  While loops are pretty bad for expressing this sort of thing.

This looks totally on-topic for a tips question. Selecting a language is part of golfing, and the feature being asked for is pretty specific.

@FryAmTheEggman - I think I accidentally deleted my reply. Yep, that makes a better title, thanks!

But you don't want to read 5 characters -- you can only know you need 5 characters once you've inspected the second (and the fifth). For 1OR0, you need 4. For 1ANDNOT0, you need 8. Reading a fixed number of characters is a whole different problem then reading a number of tokens (and with the given challenge as example, it's not even a fixed number of tokens due to the existence of NOT).

@Abigail - Ah, I realized that was a bad example. An array of inputs works as well; I just didn't want answers to think only in terms of arrays.

The approach you're asking seems like reduce/left fold in general. Many languages have this, such as Python (reduce(f,seq) or functools.reduce(f,seq)), APL (f⍨/⌽seq), Jelly (f/seq), and Haskell (foldl f start seq).
As a Python example, let's assume we already have the input parsed as a list seq=[1, 'AND', 0, 'OR', 1, 'XOR', 1]. Then reduce(f,seq) is equivalent to
f(f(f(f(f(f(1, 'AND'), 0), 'OR'), 1), 'XOR'), 1)

The trouble here is that we need to take 3 arguments at a time. A way this could be done is by grouping most of the sequence into pairs seq2=[1, ['AND',0], ['OR',1], ['XOR',1]], so reduce(f,seq) would be equivalent to
f(f(f(1, ['AND',0]), ['OR',1]), ['XOR',1])

This could work well in Jelly because it has a builtin s that could help split into pairs (output looks funny strings are internally lists of chars).
However, a loop-based approach would work better in Python by assigning to a slice of an array:
seq=[1, 'AND', 0, 'OR', 1, 'XOR', 1]
while len(seq)>1:
  seq[1:3] = [f(*seq[1:3])]
print(seq[0])

This would output f(f(f(1, 'AND', 0), 'OR', 1), 'XOR', 1).
As @AdHocGarfHunter notes in the comments, recursion is a good idea too:
# (ungolfed)
def r(s):
  if len(s)>1:
    return r(f(*s[:3]) + s[3:])
  else:
    return s[0]

APL has little boilerplate for this: {1=⍴⍵:⊃⍵⋄∇(3↓⍵),f3↑⍵} (∇ is the recursion). Jelly does too, with 1 byte recursion.


text:
Are These Scores Possible?
Background
In the sport of Table Tennis (aka Ping-Pong or Whiff Whaff), two opponents play a sequence of rounds, where each round consists of players hitting a ball back and forth until one player (may or may not be the server) gains a point.
Table Tennis has some official rules that make for a good game, but we will use a different set of rules for a better challenge.
The modified rules are as follows:

The score is announced directly before each serve as a pair (current server's score, other player's score).
Person A serves for 5 points, then Person B serves for 5 points, then back to A. Hence, A serves whenever the total score A+B is 0-4 mod 10.
After each serve, either A scores a point or B scores a point. A and B both start with 0 points.
For simplicity, games never end.

Following is an example game:
(A starts serving, so the scores are read as (A,B))
0,0; A scores a point
1,0; B scores a point
1,1; A scores a point
2,1; A scores a point
3,1; A scores a point
(B is now serving, so the scores are read as (B,A))
1,4; A scores a point
1,5; B scores a point
2,5; B scores a point
3,5; B scores a point
4,5; B scores a point
(A is now serving, so the scores are read as (A,B))
5,5; B scores a point
5,6 …
(game continues)

Task
Given a pair of unique score readouts, determine if they can be announced in the same game.
Your program/function may take input as any reasonable way equivalent to an ordered pair of numbers.
The output can follow your language's convention for truthy/falsey or use any two distinct values to represent true/false.
Examples
Given (4,5), (1,4), the output should be truthy. The example game is one where this score set occurs.
Given (4,2), (3,5), the output should be falsey. They occur at point totals 6 and 8 respectively, so B is serving in both readouts, so both are reported as (B,A). It is impossible for B's score to decrease from 4 to 3 while A's score increases from 2 to 5, so this situation is impossible.
Given (3,1), (1,5), the output should be truthy. (3,1) is reported as (A,B), while (1,5) is reported as (B,A), so the game can transition from (3,1) to (1,5) if A scores 2 points.
Test Cases
Truthy:
(4,5), (1,4)
(3,1), (1,5)
(0,0), (0,1)
(0,0), (45,54)
(6,9), (11,9)

Falsey:
(12,5), (11,6)
(4,2), (3,5)
(3,3), (5,2)
(2,1), (4,1)
(17,29), (17,24)

"Hence, A serves whenever the sum of the scores of A and B in 0,1,2,3,4 mod 5." Huh?

@xnor Probably should be 0-4 (mod 10).

Oops, edited now.

Would be interesting to state that the second pair is supposed to happen after the first. I mean there is a temporary relationship with the position.

Python 2, 58 bytes
lambda a,b,A,B:(A-a)*(B-b)<(a-b)*(A-B)*((a+b)/5+(A+B)/5&1)

Try it online!
Outputs True/False reversed
59 bytes
lambda a,b,A,B:A*B+a*(b-A-B)<(b-a)*[A,B][(a+b)/5+(A+B)/5&1]

Try it online!
59 bytes
lambda a,b,A,B:A*B+b*a<[A*b+B*a,a*A+b*B][(a+b)/5+(A+B)/5&1]

Try it online!
62 bytes
a,b,A,B=input()
if(a+b)/5+(A+B)/5&1:a,b=b,a
print(A-a)*(B-b)<0

Try it online!

Perl 5 -p -Minteger, 77, 73 bytes
/ (.*) (.*) /;$_=($`-$2)*($1-$')>=(($`+$1)/5+($2+$')/5)%2*($`-$1)*($2-$')

Try it online!
2 bytes saved using xnor approach, and 2 other bytes using integer division, explanation is (renaming: $` -> a, $1 -> b, $2 -> c, $' -> d), first answer was:

(a-B)(b-A)>=0 if scores are in reversed order ((a+b)/5%2^(A+B)/5%2==1)
(a-A)(b-B)>=0 otherwise

as (a-B)(b-A)>=0 is equivalent to (a-A)(b-B)>=(a-b)(A-B)

(a-B)*(b-A)>=0
<=> ab+AB-aA-bB>=0
<=> ab+AB-aB-Ab>=aA+bB-aB-bA
<=> (a-A)(b-B)>=(a-b)(A-B)

answer can be

(a-A)(b-B)>=0 if (a+b)/5%2^(A+B)/5%2==1
(a-A)(b-B)>=(a-b)(A-B) if (a+b)/5%2^(A+B)/5%2==0

or

(a-A)(b-B)>=(a-b)(A-B)*((a+b)/5%2^(A+B)/5%2)

or with integer division

(a-A)(b-B)>=(a-b)(A-B)*((a+b)/5+(A+B)/5)%2

05AB1E, 15 14 12 bytes
εDO5÷FR]`-Pd

-2 bytes thanks to @Neil.
Try it online or verify all test cases.
Explanation:
ε        # Map both pairs in the (implicit) input to:
 D       #  Duplicate the pair
  O      #  Pop this duplicate and calculate its sum
   5÷    #  Integer-divide it by 5
     F   #  Loop that many times:
      R  #   Reverse the pair every iteration
         #   (the pair is reversed for odd sums; and remains unchanged for even sums)
]        # Close both the loop and map
         # (all pairs are now in the order [A,B])
 `       # Pop and push both pairs separated to the stack
  -      # Subtract the values of the pairs from one another at the same indices
   P     # Take the product of those two values
    d    # And check that it's non-negative / >=0 (thus no score is decreasing)
         # (after which the result is output implicitly)

Doesn't εDO5÷._}{`-Pd work?

@Neil Ah, I guess you're indeed right, since the scores subtracted from one another can never be both negative or zero. It's either none or one of the two. Thanks

... actually I meant εDO5÷._}`-Pd...

(the point being that if exactly one of the differences is negative then the score is impossible, but if two are equal or neither or both are negative then the score is possible)

(I guess ._} and FR] are interchangeable in these versions too.)

@Neil Yeah, they indeed are interchangeable. 05AB1E usually has a lot of alternatives for the same functionality. I usually only add both alternatives if (almost) the entire program is substantially different. In my previous two 14-byters this was the case with the ending part, but right now the only difference would be the reverse X times vs rotate X times, so not really worth mentioning in the answer itself (especially since it's already here in the comments). But yes, they can indeed both be used.

APL (Dyalog Extended), 15 bytes
≡⍥⍋∘⌽⍨⌊⍤+.÷∘5⌽⊢

Try it online!
≤⌿⍣2⍤∧⌊⍤+.÷∘5⌽⊢

Try it online!
It took a long time to shave one byte from 16. You can see a long history of alternative solutions in the TIO link.
Both solutions take a 2×2 matrix as single input, where each row is a score readout. The first one would also work in Dyalog APL 18.0, since it only uses 17.x features plus ⍥⍤.
How it works
≡⍥⍋∘⌽⍨⌊⍤+.÷∘5⌽⊢  ⍝ Input: 2×2 matrix
      ⌊⍤+.÷∘5    ⍝ For each row, divide each number by 5, sum, then floor
             ⌽⊢  ⍝ Rotate each row by that amount
   ∘⌽⍨           ⍝ Check for the above and its horizontal reverse...
≡⍥⍋              ⍝   Is the sorting order equal?

≤⌿⍣2⍤∧⌊⍤+.÷∘5⌽⊢  ⍝ Alternative solution
      ⌊⍤+.÷∘5⌽⊢  ⍝ Same as above up to here
    ⍤∧           ⍝ Ascending sort the rows
≤⌿⍣2             ⍝ 1st axis reduce by ≤ twice;
                 ⍝ Since the rows are sorted, first ≤⌿ gives [1 x]
                 ⍝ where x is 1 iff the 2nd column is also increasing
                 ⍝ Then the second ≤⌿ tests if x is 1

APL (Dyalog) 18.0, 19 18 17 bytes
0≤×.-⍥(⌊⍤+.÷∘5⌽⊢)

Try it online!
This makes use of the new operators over (⍥) and atop (⍤), both of which are very good for golfing. TIO is still on 17.0, so this doesn't work, but I've tested it locally for the given test cases. Takes the two inputs as the left and right parameters.

Fails at (4,4),(4,3), which should give true.

@Bubbler reverted to a previous version (which is a bit longer)

Charcoal, 30 bytes
ＵＭθＥι§ι⁺÷Σι⁵μ¬›⁰ΠＥ²⁻§§θ⁰ι§§θ¹ι

Try it online! Link is to verbose version of code. Takes a pair of pairs of integers and outputs a Charcoal boolean, i.e. - for possible, nothing for impossible. Explanation:
ＵＭθＥι§ι⁺÷Σι⁵μ

Cyclically rotate each pair by one fifth of its sum.
¬›⁰ΠＥ²⁻§§θ⁰ι§§θ¹ι

Check that the product of the differences between the pairs is not negative.

R, 65 59 57 bytes
(or 56 bytes by outputting FALSE for Truthy and TRUE for Falsey)
function(a,b)prod(a-b[(0:1+sum(a)/5-sum(b)%/%5)%%2+1])>=0

Try it online!
Edit: -6 bytes by flipping b elements using indexing, instead of using if-else
Edit 2: -2 bytes by not bothering to do integer division for both a and b, since indexing will only use the integer part anyway.
Commented version:
validscores=function(a,b){
    b=b[                    # Select elements from b
    (0:1+                   # with index of: zero or 1, plus
    sum(a)%/%5              # changes of serve until first score
    -sum(b)%/%5)            # minus changes of serve until second score
    %%2+1]                  # modulo 2, plus 1.
                            # This will flip the elements of b if there
                            # have been an odd number of changes of serve,
                            # & otherwise leave b as it was).
    prod(a-b)>=0            # a-b now gives changes in each players points:
}                           # so if the second score came after the first,
                            # both changes must be >=0, otherwise both must be <=0.
                            # So, either way, the product must be >=0

Jelly, 11 bytes
ṚS:5Ɗ¡€Ṣ>/E

A monadic Link accepting a list of the to pairs which yields a 1 if valid, or a 0 if not.
Try it online! Or see the test-suite.
How?
ṚS:5Ɗ¡€Ṣ>/E - Link: list, S            e.g. [[17,29],[17,24]]
      €     - for each (pair in S):
     ¡      -   repeat...
Ṛ           -   ...what: reverse
    Ɗ       -   ...number of times: last three links as a monad:
 S          -       sum                       46     41
   5        -       five                       5      5
  :         -       integer division           9      8  -> [[29,17],[17,24]]
       Ṣ    - sorted                                        [[17,24],[29,17]]
         /  - reduce by:
        >   -   is greater than?       ([17>?29, 24>?17])   [0,1]
          E - all equal?                                    0

Jelly, 26 23 20 bytes
Thanks to fireflame241, I was able to shave off a few bytes already.
S€%⁵:5E¬µ³U⁸¡Ðo_/ṠIỊ

Original:
S€%ȷ1<5E¬©µ³Ṛ€®¡Ðo_/ṠIA=2¬

Try it online!
Here's my Jelly solution. It's my first Jelly program, so it can definitely be improved a lot, especially at the part where I use the register. I don't quite understand how argument flow works yet.
Here's how it works:
S€%⁵:5E¬µ³U⁸¡Ðo_/ṠIỊ - Example input:                     [[4,5],[1,4]]

S€%⁵<5               - Figure out who is serving each time
S€                   - Calculates sum of each inner list: [9, 5]
  %⁵                 - Modulo 10:                         [9, 5]
    <5               - Vectorized less than 5?:           [0, 0]

      E¬µ³U⁸¡Ð       - If server is different, reverse list 1
      E              - Checks if all elements are equal:  1
       ¬             - Logical not:                       0
        µ            - Start a monadic chain
         ³           - Get first input:                   [[4,5],[1,4]]
          U          - Reverse order of inner lists
             Ðo      - At odd indices (ie. the first list)
           ⁸¡        - {left argument, ie. 0} times:      [[4,5],[1,4]]

               _/ṠIỊ - Calculate difference in score per player.
                       If one decreased and the other increased,
                       it's not a possible score
               _/    - Vectorized subtract:               [3, 1]
                 Ṡ   - Get sign:                          [1, 1]
                  I  - Difference between elements:       0
                   Ị - abs(x) <= 1:                       0
```

Good first answer! Some immediate 1-byte improvements: ⁵ also gives 10, Ṛ€ is the same as U in this application, and _/ is the same as I since both apply only to the first axis and vectorize the subtraction. Have a look at Jonathan Allan's solution to consider almost similar approach implemented with more experience. In general, registers usually mean there's a better way

Thanks for the tips! I just tried replacing the _/ with I, and it does seem to do the same thing (although the signs are flipped), but then the next I stops returning anything. Any idea why that's happening?

Oh, I returns a list, then it vectorizes the second time you use it. It's not just the negative of _/.

Javascript , 70 bytes
(a,b,c,d)=>(~~((a+b)%10/5)==~~((c+d)%10/5)?(c-a)*(d-b):(d-a)*(c-b))>=0

Input: is 4 numbers representing two pairs in order.
Output: true/false
Try it online

Java 8, 116 63 54 bytes
(a,b,A,B)->(A-a)*(B-b)<((a+b)/5+(A+B)/5)%2*(a-b)*(A-B)

Whopping -53 bytes thanks to @NahuelFouilleul as a port from his Perl answer, so make sure to upvote him!!
Additional -9 bytes by porting @xnor's first Python answer.
Takes the inputs as four loose integers.
Outputs false for truthy; and true for falsey.
Try it online.
Explanation:
(a,b,A,B)->   // Method with four integer parameters and boolean return-type
  (A-a)*(B-b) //   Get the difference between the values of the two pairs,
              //   and take the product of those two differences
  <           //  And check that this is smaller than:
   ((a+b)     //     The sum of the first pair
     /5       //     integer-divided by 5
    +         //    Plus:
     (A+B)/5) //     The sum of the second pair, integer-divided by 5 as well
   %2         //   Check if these two added together are odd (1 if odd; 0 if even)
   *(a-b)     //   Multiplied by the reduced by subtraction of the first pair
   *(A-B)     //   Multiplied by the reduced by subtraction of the second pair

63 bytes, from my perl submission

@NahuelFouilleul Thanks, nice approach. Never even used ^ as higher order precedence with booleans. I use | or & plenty, but ^ (with booleans) next to never. :)

even shorter using xnor approach

C (gcc), 58 bytes
f(a,b,A,B){a=(A-a)*(B-b)<(a-b)*(A-B)*((a+b)/5+(A+B)/5&1);}

Try it online!
Port of xnor's Python answer.
Outputs \$0\$  if they can be announced in the same game and \$1\$ otherwise.


text:
Writing erasable code
My phone number (which I will not be sharing here) has a neat property where there is a two digit number, which when iteratively removed from my phone number will eventually remove all the digits.  For example if my phone number were
abaababbab

Then by repeatedly removing ab we would eventually get nothing (I encluse the string I am removing in brackets to make it clear)
abaababb[ab]
abaab[ab]b
aba[ab]b
ab[ab]
[ab]

Now to generalize this property lets have any string.  A "minimal eraser" of that string will be the smallest substring such that if iteratively removed it will eventually make the string empty.
Some examples at the bottom.
Task and Scoring
Warning: This challenge is not code-golf.  Do not assume it is without reading the scoring
Your challenge will be to take a string as input and output a minimal eraser of that string.
Your answers will be scored by taking them as a string of bytes and calculating that string's minimal eraser.  The length in bytes of that eraser is your score, with lower being better.
Your answer must support strings containing all printable ascii plus any characters that appear in your program.
Test cases
abaababbab -> ab
baababbab -> baababbab
baababab -> baababab
echoecho -> echo
ototoo -> oto
ibiibibii -> ibi
aabaabaa -> abaa / aaba

Suggested test case: aabaabaa -> abaa or aaba.

I'm thinking of how one might score well without golfing the actual task. I'd want a language with a char that ignores the next char including another of itself, and also a no-op char. Anyone got one?  Call _ the ignore-next and n the no-op. Make an eraser string _n_a_b_c where a,b,c are minimal distinct chars needed. By inserting into itself as _n_a__?_a_b_cb_c, we can reduce to just b, and likewise any chars. This lets us make any program be erased by this string.

@xnor Well lenguage can score 1 on this challenge, if you are looking for a language. And I would think that glypho could probably score pretty low too, maybe 2 or 3.  But as for your schema I think klein should fit the bill with ! as the skip and . as the noop.

In ototoo if you start by removing the first instance, it doesn't work.  do we assume we always remove the last instance, and then repeat?  or do we have to try every possibility, and call it an "eraser" if any of them work?

@Jonah ibiibibii doesn't work if you remove only the last one.  It is an eraser if there is any way to do it.

Do I have to write a solution if I have a scheme to eval arbitrary code with fixed eraser length? ...

@user202729 Yes

The quest for a unary answer begins...

@ouflak It seems to me the be a very significant departure from that challenge.  Checking if a string is the same thing repeated is much easier than checking if it has an eraser.  Have you maybe misread this question?

Python 3, score ... 48 29  20
+1,eval(bytes([57]))

A completely different approach from the last 2 versions (and also result in manageable generated program). Check out the revision history for some (possibly) interesting ideas.

Given an arbitrary Python program:
print(1)

it can be transformed, without changing the behavior:
exec("print(1)")

eval(rb'exec("print(1)")')

eval(bytes([101, 120, 101, 99, 40, 34, 112, 114, 105, 110, 116, 40, 49, 41]))

The number list is getting long, so I'll use a shorter list for demonstration. Note that only printable ASCII characters can appear in the string representation and the first character is e, so the first number is 101 and all numbers are at least 32.
eval(bytes([101, 32, 32]))

Rewrite the first number to 57+1+1+1+...+1+1+1, the rest into 9+1+1+...+1; then add some ,9 at the end of the list. This is always possible because of the conditions mentioned before, and the program's behavior is unchanged because the byte 9 is \t, a whitespace character.
eval(bytes([57+1+1+...+1, 9+1+1+...+1+1, 9+1+1+...+1, 9, 9,..., 9]))

The number of ,9 added must satisfy that the total number of 9s is equal to the number of +1.
Then replace all the 9 with eval(bytes([57]), and prepend +1,.
+1,eval(bytes([57+1+1+...+1,eval(bytes([57])+1+1+...+1+1,eval(bytes([57])+1+1+...+1,eval(bytes([57]),eval(bytes([57]),...,eval(bytes([57])]))

Done! It's easy to see that this string has the eraser string +1,eval(bytes([57]).

It's trivial to see that there exists a Python snippet that solves the given problem.
g=lambda s, e: not s or any(
	s[i:].startswith(e) and g(s[:i]+s[i+len(e):], e)
	for i in range(len(s)-len(e)+1))
f=lambda s: min((s[i:j] for j in range(len(s)+1) for i in range(j) if g(s, s[i:j])), key=len)
print(f(input()))

Try it online!

24B: +eval('%c'*3%(32,49,32)) (will prove later)

20B: +1,eval(bytes([57])) seems to work too.

That 20B solution can be ported to JavaScript -- but String.fromCharCode is significantly longer.

+1,eval(0+Buffer([57])) seem reasonable though

JavaScript's Buffer also have the property that values are automatically taken %256, but it doesn't seem to allow shortening the solution.

Brachylog, 23 bytes, score 23
Rather boring, as it doesn't have a non-trivial eraser.
{|~c₃↺↔At.l>0∧Akc↰}ᶠlᵒh

Try it online! or verify the other test cases (split in two, so TIO doesn't time out.)
How it works
{|~c₃↺↔At.l>0∧Akc↰}ᶠlᵒh
{                 }ᶠ     Find all outputs for the implicit input, that …
 |                        either is itself or …
  ~c₃                     split into three groups in every possible way
                           [,,AAABBB],[,AA,AABB],[AAA,B,BB],[AA,AB,BB] etc. …
     ↺↔                    with the middle moved to the back [AA,BB,AB] …
       A                   assign to A
        t.                 the tail AB is the output of this predicate
          l>0              and its length is greater than 0.
             ∧Ak          Also, [AA,BB] …
                c          concatenated AABB …
                 ↰         used in a recursive call
                           has the same output as this predicate: AB.
                     lᵒh Order all possible erasers by length, take first

Javascript, 228 bytes, score 228
Naive solution I guess:
(r,d)=>{w=0;l=r.length;for(var i=0;i!=-1&&i<l;){i=r.indexOf(d,i);w=w||((i<0)?0:t(r.substr(0,i)+r.substr((i++)+d.length,l),d))}return !r?1:w}
f=a=>{n=a.length;for(p=1;p<=n;p++)for(i=0;i<=n-p;i++)if(t(a,b=a.substr(i,p)))return b}

Try it online!

Can't you replace .substr(0,i) with slice(0,i)? And remove var ?


text:
Count The Genus
Objective
Given a matrix of connected box drawing characters, count its genus, the number of plane sections it encloses.
Valid input
The box drawing characters are ─│┌┐└┘├┤┬┴┼╴╵╶╷ (U+2500 U+2502 U+250C U+2510 U+2514 U+2518 U+251C U+2524 U+252C U+2534 U+253C U+2574 U+2575 U+2576 U+2577). The matrix shall contain these characters only, along with unique "nothing" value that represents a blank.
The input may also be a string with box drawing characters, whitespaces, and line feeds. You cannot mix different types of whitespaces, or different types of line feeds. Trailing whitespaces and line feeds are permitted.
Rule
Invalid input falls in don't care situation. In particular, you don't need to handle any input having multiple connected components, e.g.
# this
┌─┐┌─┐
└─┘└─┘
# or this
┌───┐
│┌─┐│
│└─┘│
└───┘

Examples
For font issues, every example is presented using normal spaces (U+0020) once and ideographic spaces (U+3000) once.
Genus 0
# Using U+0020 space
┤ ╷
└─┘

┌┼┐
 ─┴

# Using U+3000 space
┤　╷
└─┘

┌┼┐
　─┴

Genus 1
# Using U+0020 space
┌─┬
│ │
└─┘

┼┬─┬
╵│ │
└┴─┘

# Using U+3000 space
┌─┬
│　│
└─┘

┼┬─┬
╵│　│
└┴─┘

Genus 2
# Using U+0020 space
┼┼┼┼
 ┼┼┼

# Using U+3000 space
┼┼┼┼
　┼┼┼

How does nesting work? For instance, this example. What is its genus? 1? 2? 3?

@Abigail It is not connected, so it falls in don't care situation.

You write, "Given a matrix of connected box drawing characters". What does "connected" mean in this context? Half the examples aren't what I would call "connected box drawing characters".

@Abigail By "connected" I mean it will look connected when the whitespace matches the width of the box drawing characters, and there is no space between lines. Half of the examples will not look connected, for they have wrong width of the whitespaces.

If the full-width space (U+3000) is considered the same as half-width one (U+0020), why should we include it in the question? I cannot see any benefit from it.

@tsh If you are referring the examples, it's my concern about rendering.

Suggested test case (Genus 3).

Suggested test case (genus 2)

APL (Dyalog Extended), 73 bytes
1-1⊥∘(∊∨/¨⍮2(-⊃⍤∧∘⌽/⍮(3⊃∧∘⌽)⌿)⊢)(⊂4⍴2)⊤¨(9467+⎕AV⍳'ð{dòlxõ _0h8p∆')⍳⎕UCS

Try it online!
Over half of the bytes were used in converting the char matrix into an easier-to-use format. Basically, converts each box-drawing char into [right, up, down, left], counts non-blanks and joints, and computes 1 - non-blanks + joints.
This works because of Euler characteristic V - E + F = 1 (not counting the surrounding area as a face), thanks to the assumption that the entire figure is connected. If we count any segment starting from the center to some boundary as an edge (and the respective endpoints as vertices), every non-blank char has V - E = 1, but the V in the entire shape is reduced by the number of joints. Plugging into the rearranged equation F = 1 - V + E gives the above formula 1 - non-blanks + joints.

Retina, 131 bytes
T`─┐┬╴┼┤┴┘│╵└├┌╶╷`L
(?=(.)*[BCEFILMO].*¶(?>(?<-1>.)*)[E-L])
-
(?=[ACEGK-N]-?[A-H])|^
-
+`-\s*\w

C`-

Try it online!
TIO counts the box drawing characters as only one byte even though they are not ASCII (the Retina code page).
How?
This uses a rearranged Euler characterstic F=1+E-V to find the number of faces under the assumption that there is only one connected component.
The number of vertices, V, is the same as the number of box characters.
There is +1 edge for every horizontally adjacent pair of box characters where the first has a right edge and the second has a left edge.
There is +1 edge for every vertically adjacent pair of box characters where the first has a down edge and the second has a up edge. This is harder to express in regex, so I borrowed the method of standard vertical matching to deal with vertical edges.
# Translate each of the box characters into letters to avoid repeating them
# We do this smartly:
# ─┐┬╴┼┤┴┘        correspond to A-H and all have a left edge
#     ┼┤┴┘│╵└├    correspond to E-L and all have an up edge
#           └├┌╶  correspond to K-N and all have a right edge
T`─┐┬╴┼┤┴┘│╵└├┌╶╷`L
# Prepend a '-' to the first character of a vertically adjacent pair with (down edge, up edge)
# Each '-' will represent one edge
(?=(.)*[BCEFILMO].*¶(?>(?<-1>.)*)[E-L])
-
# Prepend a '-' to the first character of a horizontally adjacent pair with (left edge, right edge)
# Simply pass over '-' from the previous step using -?
# |^: also prepend an extra '-', which counts as an extra edge, to the beginning of the whole string for the +1
(?=[ACEGK-N]-?[A-H])|^
-
# Now there is a - for each edge and a capital letter for each vertex, with some whitespace
# Compute #(edges) - #(capital letters)
# Until the output is constant:
# Replace an edge and a capital letter with the empty string (`\s*` to pass over whitespace)
+`-\s*\w

# Count the number of `-`s
C`-

The last stage defaults to being a Count stage, so you can save 2 bytes immediately.

I was able to rearrange the characters to save another byte: Try it online! however I think it's possible that you could probably net a bigger saving using T`─-┼╴-╷`5-u as your first line.

Charcoal, 100 bytes
ＷＳ⊞υιＢ×³⊕Ｌθ×³⊕ＬυψＦυ«⸿⸿⸿Ｆι«Ｍ³→Ｆ⁴¿＆Ｘ²λ⍘§”E←T¹÷S1²m[ω→℅P”﹪℅κ⊕⊘φφＰ✳⊗λ²»»≔⁰ηＦＬθＦＬυ«Ｊ×³ι×³κ↘≧⁺¬℅ＫＫη¤#»⎚Ｉ⊖η

Try it online! Link is to verbose version of code. Takes input as a newline-terminated rectangular character array. While I could have written a version that uses the Euler characteristic, I felt that I should really write a version using all of Charcoal's power to calculate the number of regions in any shape. Explanation:
ＷＳ⊞υι

Input the shape.
Ｂ×³⊕Ｌθ×³⊕Ｌυψ

Draw an empty box large enough to completely enclose the shape at three times scale.
Ｆυ«⸿⸿⸿Ｆι«Ｍ³→

Loop over each character of the input, positioning the cursor at the appropriate position.
Ｆ⁴¿＆Ｘ²λ⍘§”E←T¹÷S1²m[ω→℅P”﹪℅κ⊕⊘φφＰ✳⊗λ²

Loop over each direction, looking up the box lines based on taking the ordinal of the character modulo 501 and 23 (the latter automatically via Charcoal's cyclic indexing) in a table of hex digits (and gs for filler), drawing a line for each matching bit in the digit, thus drawing the original shape at triple size.
»»≔⁰η

Start with no regions.
ＦＬθＦＬυ«

Loop over each character.
Ｊ×³ι×³κ↘

Jump to the upper right of the character.
≧⁺¬℅ＫＫη

Increment the region count if it's empty.
¤#

And then try to fill it anyway.
»⎚Ｉ⊖η

Print one less then the resulting count (since this procedure counts the outside too).


text:
XOR two strings
Given two strings as input, return the result of XORing the code-points of one string against the code points of the other.
For each character in the first input string, take the code-point (e.g. for A, this is 65) and XOR the value against the corresponding index in the second string and output the character at the code-point of the result. If one string is longer than the other, you must return the portion of the string beyond the length of the shorter, as-is. (Alternatively, you may pad the shorter string with NUL bytes, which is equivalent.)
See the following JavaScript code for an example:
const xorStrings = (a, b) => {
  let s = '';

  // use the longer of the two words to calculate the length of the result
  for (let i = 0; i < Math.max(a.length, b.length); i++) {
    // append the result of the char from the code-point that results from
    // XORing the char codes (or 0 if one string is too short)
    s += String.fromCharCode(
      (a.charCodeAt(i) || 0) ^ (b.charCodeAt(i) || 0)
    );
  }

  return s;
};

Try it online!
Test cases
Input                         Output

['Hello,', 'World!']          '\x1f\x0a\x1e\x00\x0b\x0d'
['Hello', 'wORLD']            '?*> +'
['abcde', '01234']            'QSQWQ'
['lowercase', "9?'      "]    'UPPERCASE'
['test', '']                  'test'
['12345', '98765']            '\x08\x0a\x04\x02\x00' _not_ 111092
['test', 'test']              '\x00\x00\x00\x00'
['123', 'ABCDE']              'pppDE'
['01', 'qsCDE']               'ABCDE'
['`c345', 'QQ']               '12345'

Rules

The two input strings will only ever be code-points 0-255.
This is code-golf so the shortest solution, in each language, wins.

Are the two strings limited to ASCII?

@Bubbler the inputs string will only ever be code-points 0-255.

You might want to add a few other test cases of varying length besides just ['test', '']. I see many answers being posted which fail for this test case due to the length difference (or because one of the two is empty maybe).

@KevinCruijssen Done and emboldened (and hopefully added a viable alternative) the detail.

Alternatively, padding the shorter string with NUL bytes is equivalent.
Can you confirm that you mean we can, if we like, assume that the two strings will be of the same length with the originally shorter one padded with NUL characters? Or does this mean that the implementation should do the padding, and that this is equivalent to the requirement to "return the portion of the string beyond the length of the shorter, as-is"?

@user7761803 I've edited to clarify that I meant it should be padded as part of your answer. Hopefully it's clear now!

Is code-point 0 required to be valid?  Or can we reserve it as a terminator for implicit-length strings such as C strings?

Similar to Peter's question: May we input the strings from stdin with a separator character (which would mean that character could not occur in the strings themselves)? This seems like a natural input method, and I think I saw at least one existing answer using it, but it somewhat flies in the face of the strings being code points 0-255.

That JavaScript implementation doesn't seem correct, since it won't work with code points that encode to surrogate pairs in UTF-16.

@PererCirdes I certainly wouldn't want to exclude any languages. I think providing it works "in theory" for everything, I'd be happy to preclude NUL bytes from forcibly being accepted as input. I don't know if this flies in the face of any meta posts though, so if it does, please let me know. Would the program theoretically be able to output NUL bytes still?

@DLosc As per my response to Peter,no think as long as it works ok theory I personally wouldn't want to exclude an entry if it's necessary to have a terminator that doesn't appear in the input.  Same as my question to Peter though, would it preclude it from appearing in the output of it was generated as part of the operation?

@D.Pardal Oh encodings... Yeah, i imagine there are some interesting potential outputs. I'm not sure I'll get time to look at this today,, but I'll try and create a more bulletproof version. Thanks for the heads up!

In my case, no, output would not be affected.

"The two input strings will only ever be code-points 0-255." to be actually useful this clause should limit to 0-127, as 0-255 still makes it necessary to parse UTF-8 for languages that work at code-unit level; most of the posted examples ignore the issue, and, fed with e.g. "è"/"è" in UTF-8, they will output "\0\0" instead of just "\0". Or, even better, just drop the whole "code points" thing and rephrase it to work at code unit level, which is ultimately what most languages do (and if one works with codepoints they can still say they are working with UTF-32 code units).

Jelly, 4 bytes
O^/Ọ

Try it online!
Takes input as a list of the two strings, e.g. ['abcde', '01234'].
How?
O    # ord: cast to number (automatically vectorizes)
 ^/  # Reduce by XOR. XOR automatically applies to corresponding elements
         and pads as desired to work if the two strings are different lengths
   Ọ # chr: cast to character (vectorizes once again)

Raku, 4 bytes
*~^*

Try it online!
Raku has a built-in operator for XORing strings, along with string AND, OR and bitshift. This is a Whatever lambda that takes two parameters.

perl -Mfeature=say,bitwise -nl, 22 bytes
$.%2?($;=$_):say$;^.$_

Try it online!
This is way more characters than I first hoped for. If it weren't for those pesky newlines, the 9 character say<>^.<> would do.
How does it work?
For odd input lines, it saves the current line of input (without the trailing newline due to the -n and -l switches) into $;. For even lines, it xors the previous line ($;) and the current line ($_), and prints it. The ^. operator does required bitwise string operation.

I didn't even know about -Mbitwise, but I think you can drop it (and the .). For single inputs (which is fine IMO), your intended idea should work too: Try it online!

@DomHastings Yeah, but that relies on having the last line of STDIN to not be terminated with a newline, which is kind of icky (and hard to spot when looking at test input). BTW, it's not -Mbitwise, but -Mfeature=bitwise.

That's very true, it does! Without the -Mfeature=bitwise though, you can avoid the . in ^. for -1!

Q from someone less-experienced in Perl: do you use $; as a variable name for a clever reason, or is it just playful obfuscation?

@DominicvanEssen It has special uses (although I've not used it as intended: https://perldoc.perl.org/perlvar.html#%24%3b) but it's really useful to use if your script uses -n/-p as you can use $ alone, because -n wraps your code in while (<STDIN>) {...;} so you can use the implicit ;. I'm using a similar trick in this answer https://codegolf.stackexchange.com/a/205760/9365 using ; as the delimiter for s/// and relying on the implicit existence. @; and %; would work too!

That's very cunning!  But in the case of the particular answer above (where the $ isn't the last character), I take it that using $; instead of any other more-easy-for-me-to-understand variable name is just down to taste or habit?

When testing, I was running the program as perl -M5.032 -nl program.pl < input. This turns on strict, which prohibits an undeclared $x (or any other single letter variable). $; however is always a package variable.

@DomHastings I think ^ instead of ^. and skipping -M won't work if the strings match [0-9]+ (this is from memory; I haven't checked).

@Abigail The challenge specifies input is in the range 0-255. So I think you have to account for newlines in the strings. Maybe do it as a subroutine instead of a standalone script (is that still legal here?), something like pop^.pop?

@msh210 It seems to do what's expected in some basic tests without the -Mfeature=bitwise, but there's probably an edge case I'm not aware of... Try it online!

APL (Dyalog Unicode), 15 bytes
80⎕DR≠⌿↑11⎕DR¨⎕

Try it online!
As the OP clarified that the input codepoints will be in the range of 0-255, it is possible to manipulate the underlying data bits directly. Such a string is guaranteed to have data type 80 (8-bit char array), so we convert it to data type 11 (1-bit boolean array) to access the bits, XOR them, and convert back to data type 80.
80⎕DR≠⌿↑11⎕DR¨⎕  ⍝ Full program, input: two string literals on a line
        11⎕DR¨⎕  ⍝ Convert each string literal to bit array
       ↑         ⍝ Promote to matrix, padding with 0 as needed
     ≠⌿          ⍝ Bitwise XOR
80⎕DR            ⍝ Convert back to 8-bit char array

APL (Dyalog Extended), 17 bytes
⎕UCS⊥≠⌿⍤2⊤↑⎕UCS¨⎕

Try it online!
Well, the task involves converting char to charcode and back AND converting from/to binary, but all current implementations having ⍢ have some quirks so it can't be used here. So here is the very literal implementation of the task.
⎕UCS⊥≠⌿⍤2⊤↑⎕UCS¨⎕  ⍝ Full program, input: two string literals on one line
           ⎕UCS¨⎕  ⍝ Convert to codepoints
          ↑        ⍝ Promote into a 2-row matrix, padding zeros as necessary
                   ⍝ (doing on characters give spaces which is 0x20, not 0)
         ⊤  ⍝ Convert each number to binary
     ≠⌿⍤2   ⍝ Bitwise XOR
    ⊥       ⍝ Convert the binary back to integers
⎕UCS        ⍝ Convert the integers back to chars

J, 14 bytes
XOR@,:&.(3&u:)

Try it online!
How it works
XOR@,:&.(3&u:)
        (3&u:) strings -> code points
      &.       do right part, then left part, then the inverse of the right part
    ,:         pad shorter one with zeros by making a table
XOR@           XOR the code points
        (3&u:) revert back code points -> string

C (gcc), 60\$\cdots\$ 55 54 bytes
Saved 2 4 bytes thanks to AZTECCO!!!
Saved a 2 bytes thanks to ceilingcat!!!
#define f(a,b)for(;*a+*b;b+=!!*b)a+=putchar(*a^*b)!=*b

Try it online!

@AZTECCO Unfortunately, that doesn't print the end of the longer string. But found a way that does - thanks! :-)

Oh my bad, you can save 1 more btw Try it online!

And one more using macros Try it o

@AZTECCO Nice one - thanks! :-)

@ceilingcat Of course, nice one - thanks! :D

05AB1E, 8 7 bytes
thanks to Kevin Cruijssen for a byte!
Ç0ζε`^ç

Try it online!
Commented
	 implicit input          ["QQ", "`c345"]

Ç        convert to charcodes    [[96, 99, 51, 52, 53], [81, 81]]
  ζ      Zip with filler ...     [[96, 81], [99, 81], [51, "0"], [52, "0"], [53, "0"]]
 0       ... zero
   ε     Map ...                   [96, 81]
    `      Dump on stack           96, 81
     ^     XOR                     49
      ç    Convert to character    "1"

         implicit output         ["1", "2", "3", "4", "5"]

7 bytes by taking the input as a pair of strings.

Excel, 158 153 108 bytes
(Not counting closing parens)
Compatibility Notes:

Minimum version: CONCAT() came to be in later versions of Excel 2016 (from CONCATENATE()).

The Formulae

Inputs: A1, B1
A2: =MIN(LEN(A1:B1)), 14
B2: =LEN(A1)-LEN(B1), 15

Code (124):
=CONCAT(CHAR(BITXOR(CODE(MID(A1,SEQUENCE(A2),1)),CODE(MID(B1,SEQUENCE(A2),1)))))&RIGHT(IF(B2>0,A1,B1),ABS(B2))

One unfortunate caveat is that Excel ignores non-printable characters in cells. Alternatively, if you'd rather I use "\xXX" characters, I have this:
=CONCAT("\x"&DEC2HEX(BITXOR(CODE(MID(A1,SEQUENCE(A2),1)),CODE(MID(B1,SEQUENCE(A2),1))),2))&RIGHT(IF(B2>0,A1,B1),ABS(B2))

at 118 bytes. This just prints all XOR'ed characters as "\xXX" characters and leaves the trailing characters alone. Eg: Hello! and World!! produce \x3F\x2A\x3E\x20\x2B\x00!
How it Works:

The SEQUENCE(A2) effectively creates a range of (1..A2). As far as I can tell, I cannot re-use this by caching it in a cell, which is why I had to use it twice.
Each item is then converted to numbers with CODE() and BITXOR()ed against each other.
The CHAR() converts this to a character, while DEC2HEX(...,2) converts it to a 2 width 0-padded hex number.
CONCAT() puts the array together
RIGHT(...) tacks on the trailing characters of the longer string.

May want to throw in that as this uses the BitXOr function, this is limited to Excel 2013 and later

@TaylorScott True, but I think the minimum compatibility is actually 2019, because CONCATENATE() was changed to CONCAT()

You're right - Concat() is the limiting function here, but I think it limits to Office v 16.0.xx which would include Office 2016, 2019 and 365. At least I can confirm that it is functional in up-to date versions of Excel 2016 on Win 10

Yup, you're right. https://support.microsoft.com/en-us/office/concatenate-function-8f8ae884-2ca8-4f7a-b093-75d702bea31d

Python 3.8, 71 bytes
f=lambda a,b:chr(ord(a[0])^ord(b[0]))+f(a[1:],b[1:])if a and b else a+b

Try it online!

Nice solution! You can save 2 bytes by shortening the base case as f=lambda a,b:a>''<b and chr(ord(a[0])^ord(b[0]))+f(a[1:],b[1:])or a+b

print(''.join(chr(ord(x)^ord(y))for x,y in zip(*input().split()))) would be only 66 bytes but unfortunately, making it work on strings of different lengths would require many more bytes; and it doesn't handle strings that contain whitespace :-(

Java 10, 109 bytes
(a,b)->{int A=a.length,B=b.length;if(A<B){var t=a;a=b;b=t;A^=B^(B=A);}for(;A-->0;)a[A]^=A<B?b[A]:0;return a;}

I/O as arrays of characters.
Try it online.
Explanation:
(a,b)->{             // Input as 2 character arrays as parameters as well as return-type
  int A=a.length,    //  `A`: the length of the first array `a`
      B=b.length;    //  `B`: the length of the second array `b`
  if(A<B){           //  If the length of `a` is smaller than `b`:
    var t=a;a=b;b=t; //   Swap the arrays `a` and `b`
    A^=B^(B=A);}     //   And also swap the lengths `A` and `B`
                     //  (`a`/`A` is now the largest array, and `b`/`B` the smallest)
  for(;A-->0;)       //  Loop index `A` in the range [`A`, 0):
    a[A]^=           //   Bitwise-XOR the `A`'th value in `a` with, and implicitly cast
                     //   from an integer codepoint to a character afterwards:
      A<B?           //    If index `A` is still within bounds for `b`:
       b[A]          //     XOR it with the `A`'th codepoint of `b`
      :              //    Else:
       0;            //     XOR it with 0 instead
  return a;}         //  Return the modified `a` as result

Note that we cannot use a currying lambda a->b-> here, because we modify the inputs when swapping and they should be (effectively) final for lambdas.

Factor, 48 bytes
: f ( s s -- s ) 0 pad-longest [ bitxor ] 2map ;

Try it online!

JavaScript (Node.js), 66 bytes
f=(a,b)=>b[a.length]?f(b,a):(B=Buffer)(a).map((c,i)=>c^B(b)[i])+''

Try it online!

Scala, 64 bytes
(a,b)=>(""/:a.zipAll(b,'\0','\0').map(x=>x._1^x._2))(_+_.toChar)

Try it online!
Run with
val f: ((String,String)=>String) = ...
println(f("01","qsCDE"))
...

Uses zipAll to zip the input strings with null bytes as padding, then XORs, finally using foldLeft shorthand /: to turn the whole thing back into a string.

60 bytes?

Japt, 6 bytes
cÈ^VcY

Try it
cÈ^VcY     :Implicit input of strings U & V
c          :Map the charcodes in U
 È         :by passing each one at index Y through the following function
  ^        :  Bitwise XOR with
   VcY     :  Charcode at index Y in V

Lua, 105 bytes
i,a,b=0,...print(a:gsub('.',load'i=i+1return a.char((...):byte()~(b:sub(i,i):byte()or 0))')..b:sub(#a+1))

Try it online!
Taking two strings as arguments, this program calls per-character replace on one of them with essentially XOR function, then appends potentially missing fragment from second string (occurs if it is longer) and prints the result. TIO includes test suite.

PHP, 36 bytes
[,$a,$b]=$argv;echo"$a\r$b\r",$a^$b;

Usage:
$ php -r '[,$a,$b]=$argv;echo"$a\r$b\r",$a^$b;' -- 'ABCDE' '123';echo
> pppDE

Explanation: first output string A, then carriage return \r, output string B, then another carriage return, then output the XOR (which truncates to the shorter of the 2 strings). Any characters of the longer string will have already been printed.
PHP 7.4, 32 bytes
Using new arrow function syntax.
fn($a,$b)=>($a|$b^$b)^($a^$a|$b)

Explanation:
In PHP binary operators, only the | will keep the longest string length and pad with NULs. So we XOR string B with itself, leading to a string with NUL bytes of the same length as B, then OR that with A. This will pad A with NUL bytes and use the length of B, if B is longer than A. We do the same with B, and only then XOR.
Edits:

arrow function variant
missed the requirement of outputting the longest string

Vyxal, 4 bytes
C÷꘍C

Try it Online!
Because Vyxal auto-pads lol.
Explained
C÷꘍C
C     # convert each character in each string to it's ordinal value
 ÷꘍   # bitwise xor each item
   C  # and convert the result back to characters

Alternatively, using Keg mode:
Vyxal K, 1 byte
꘍

Try it Online!

Charcoal, 33 bytes
Ｆ⌈ＥθＬι«Ｆθ«≔ζη≔∧‹ιＬκ℅§κιζ»℅⁻｜ηζ＆ηζ

Try it online! Link is to verbose version of code. Takes input as an array of two strings. Explanation:
Ｆ⌈ＥθＬι«

Loop over the longer length of the strings.
Ｆθ«

Loop over the strings.
≔ζη

Save the result of the previous loop, if any.
≔∧‹ιＬκ℅§κιζ

Get the ordinal at the current index, if that is less than the current string.
»℅⁻｜ηζ＆ηζ

Emulate bitwise XOR by subtracting the bitwise AND from the bitwise OR, then convert back to a character.

Python 2, 80 72 69 bytes
lambda*a:''.join(map(lambda x,y:chr(ord(x or'\0')^ord(y or'\0')),*a))

Try it online!
Uneven lengths are annoying...

PowerShell, 86 81 bytes
$k=[char[]]($args[1]);([byte[]]([char[]]($args[0])|%{$_-bxor$k[$i++%$k.Length]}))

Try it online!
-5 bytes thanks to @mazzy

Welcome. You can use $args[1]|% t*y instead [char[]]($args[1]). The % t*y means "call the method toCharArray. And you can omit $i=0. See also Tips for golfing in PowerShell

Am I wrong or does this not work for two strings of unequal length?

@Thomas yep. You can see the two arguments are different length.

You have to quote your input, if it contains spaces. You are actually processing I and am instead of I am fat and You are thin. 2. As you can see in your result, it contains only 1 byte instead of two bytes (am has two bytes), because you process up to the length of the first string. In conclusion, you just omit bytes if the first string is the shorter one and your code crashes if the second string is shorter.

C (gcc),  44  43 bytes
x(o,r)char*o,*r;{*o|*r&&x(o+1,r+1,*o^=*r);}

Try it online!
Uses recursion, note that to print strings containing the null byte one will have to manage the strings as arrays. (See the footer of the link for an example)
C (gcc),  50  49 bytes
x(o,r)char*o,*r;{*o|*r&&x(o+!!*o,r+!!*r,*o^=*r);}

Try it online!
Slightly safer version (doesn't read past end of strings, requires enough memory to exist past them though - a la strcpy).
C (gcc),  61  60 bytes
x(b,o,r)char*b,*o,*r;{*o|*r&&x(b+1,o+!!*o,r+!!*r,*b=*r^*o);}

Try it online!
As safe as any standard C function taking a buffer, at the cost of a few more bytes.
-1 byte from each thanks to ceilingcat!

You're relying on the first string storing as much memory as the second string in case the second string is longer than the first. That's not really playing fair. Certainly not how strings work in C.

You're also relying on memory past the end of the shorter string to be initialised to zero.

I agree it isn't the fairest, but given how strings are represented in C there isn't a much cleaner way to write this as a function. Your solution doesn't provide any means by which to access the new string, other than trapping the output stream. The only truly portable way would be to take 6 parameters: a, len(a), b, len(b), buffer, len(buffer). But defensive coding has never really been the goal of these submissions ;)

There are many ways to make your code cleaner. Not reading past the end of strings for starters. The point is that work is being done outside of your function to make it work. To change mine to return a string is trivial and certainly doesn't involve passing string lengths. Simply malloc a string buffer based on the maximum strlens of the inputs and return that pointer after creating the result there.

same can be done in mine. it also still requires work outside of the function in terms of free. A solution would be something like this: Try it online!

You're still reading past the end of a string. Don't do that. It's making my eyes bleed! T_T

Wow, my bad :P wrote that out too quickly. Try it online! That one fixes the wrong name issue.

Let us continue this discussion in chat.

Stax, 7 bytes
ôM◙L╞@←

Run and debug it

Husk, 11 bytes
ż§oc-¤nc¤vc

Try it online!
Unfortunately Husk doesn't have a bitwise XOR command (that I could find), so we need to do:
arg1 OR (v) arg2 minus arg1 AND (n) arg2, costing an extra 5 bytes...

x86 machine code, 29 bytes
Machine code:
00000034: 31 d2 e3 08 8a 11 41 41 84 d2 e1 fe ac 84 c0 75  1.....AA.......u
00000044: 06 e3 09 89 ce 31 c9 30 d0 aa eb e4 c3           .....1.0.....

Commented assembly:
        .intel_syntax noprefix
        .globl .strxor
        // Doesn't follow standard calling convention.
        // Input:
        //      EDI: Output buffer large enough for longest string
        //      ESI, ECX: Null terminated strings to XOR
        // Output:
        //      NON-null terminated string stored in EDI.
.strxor:
.Lloop:
        // Always clear EDX.
        xor     edx, edx
        // We mark the end of the shorter string
        // by setting ECX to null.
        jecxz   .Lskip_ecx
.Lno_skip_ecx:
        // Read a byte from ECX into DL.
        mov     dl, byte ptr [ecx]
        // Increment twice because LOOPZ decrements.
        inc     ecx
        inc     ecx
        // Was it '\0'?
        test    dl, dl
        // If so, set ECX to NULL by using LOOPZ in place.
        // CMOVZ ECX, EAX also works, but needs P6.
        // This works with i386 and is the same size.
.Lclear_ecx:
        loopz   .Lclear_ecx
.Lskip_ecx:
        // Load from ESI and autoincrement
        lods    al, byte ptr [esi]
        // Test for '\0'
        test    al, al
        jnz     .Lno_swap
.Lswap: // '\0' found
        // If ECX is null, we are at the end of both strings.
        jecxz   .Lend
        // Otherwise, we swap ESI and ECX, and then clear ECX.
        // Set ESI to ECX.
        mov     esi, ecx
        // And set ECX to NULL.
        xor     ecx, ecx
        // fallthrough
.Lno_swap:
        // XOR the two bytes together
        xor     al, dl
        // Store to EDI and autoincrement
        stos    byte ptr [edi], al
        // Loop unconditionally.
        jmp     .Lloop
.Lend:
        ret

Try it online!
The code reads two null terminated strings from esi and ecx, and stores the NON null terminated string in edi.
The logic is probably easier to see in the equivalent C code.
void strxor(char *dst, const char *src1, const char *src2)
{
    for (;;) {
        char x = '\0';
        if (src2 != NULL) {
            x = *src2++;
            if (x == '\0') { // eos
                src2 = NULL;
            }
        }
        char y = *src1++;
        if (y == '\0') {
            if (src2 == NULL) { // both eos
                return;
            } else { // src2 is longer
                src1 = src2;
                src2 = NULL;
            }
        }
        *dst++ = x ^ y;
    }
}

I don't null terminate because null bytes naturally show up in the output and it saves a byte.
I may also add a version with explicit lengths which accepts null bytes, but the solution would be significantly less elegant.

Perl 5, 14 bytes
sub f{pop^pop}

Try it online!

Scala 3, 30 29 bytes
a=>b=>a zipAll(b,0,0)map(_^_)

Try it online
Scala 2, 41 39 38 bytes
Used infix notation to turn .map into just map
a=>b=>a zipAll(b,0,0)map(a=>a._1^a._2)

Inputs and output are lists of integers
Try it online


text:
When does hh:mm = mm.ss?
Let's begin with a thought experiment. You have a clock and a timer, in which you start the timer when the clock shows exactly hh:mm.00.

Clock: The clock employs 24-hour time. So the range of hh is 0<=h<23. (Because 23 inputs are unsolvable, you aren't required to handle that)
Timer: It starts exactly on 00.00. The number to the right of . isn't milliseconds; it's seconds.

What you need to do is to find out when the two numbers represented by clock time (hh:mm) is respectively equal to the timer time (mm.ss); e.g. 13:24 is "respectively equal" to 13.24. There can potentially be more than one time.
An example
Say the input is 1:59.
Clock: 1:59
Timer: 0.00   (The timer just started)

...
Clock: 1:59
Timer: 0.59   (59 seconds later...)

...

Clock: 2:00
Timer: 1.00   (As the timer's second section rounds up to the minute section, the clock time gets incremented by a minute. And the 59 minutes in the clock section gets rounded up to the hour section, hence the 2:00.)

...
Clock: 2:00
Timer: 1.59 (59 seconds later...)

...
Clock: 2:01
Timer: 2.00 (The timer minute gets rounded up, as the clock time increments by a minute)

...
Clock: 2:01
Timer: 2.01 (Now the clock time is "respectively equal" to the timer time)

Therefore you need to output 2:01 for the 1:59 input.
Examples
Here is a sample program I use to check my test cases.
0:59 -> 0:59 (or 1:00, if your answer supports that)
1:30 -> 1:31
2:59 -> 3:02
1:59 -> 2:01
3:58 -> 4:02
22:01->22:23

Specifications

Although in the test cases, the input is taken as hh:mm, you can nevertheless take input in a list, e.g. [hh,mm], or any format suitable for your answer.
You can output the time in the format [mm,ss].
You could start two physical timers, but you need to optimize their speed somehow. Your code running all of the test cases must terminate in 60 seconds.
You are allowed to take input/output as base 60.
You don't need to handle unsolvable inputs. I.e. The hour section in the clock will never be 23.
If you find more than one time for a specific test case, you can output any of them.

Is 1:00 also a valid output for 0:59?

@Nitrodon Yes it is. Edited to reflect that.

Why would hh == 23 be unsolvable? from 23:00 to 23:36 there are valid solutions.

Nice follow-up questions would be: How many start times with more than one solution like 0:59 exist? List them. What is the maximum number of solutions for any given start time?

No, there are 23 cases like that: 0:59, 1:58, 2:57, ..., 22:37. And as for what I said before, there are 23:00 → 23:23 up to 23:36 → 23:59.

MathGolf, 11 9 bytes
+α_╙╟/+╟%

Port of the approach used in @ovs' Python answer.
Input as two loose integers. Output as a pair.
Try it online.
Explanation:
+         # Add the two (implicit) inputs together: h+m
 α        # Wrap two items in a list, which will use the (implicit) first input: [h,h+m]
  _╙      # Duplicate it, and pop and push the maximum: h+m
    ╟/    # Integer-divide it by 60: (h+m)//60
      +   # Add it to both values in the list: [h+(h+m)//60,h+m+(h+m)//60]
       ╟% # Take modulo-60 on both: [(h+(h+m)//60)%60,(h+m+(h+m)//60)%60]
          # (after which the entire stack joined together is output implicitly as result)

Raku, 14 12 11 bytes
0+|*/.98334

Try it online!
Since we know the bounds of the input, we can substitute a constant operation and a floor on the input in base 60.  That number by the way is around 1358/1381, which is the maximum the input differs from the output in base 60. There may be a smaller constant, or at least a smaller way to represent it. For reference, the shortest constant you can multiply by, rather than divide, is 1.01694.

Lovely.  Looks like you can also leave-out the 0 for 11 bytes.

@DominicvanEssen a couple of minutes too late ;)

The constant .98334 is just a smidgen bigger than 59/60. While 59/60 exactly doesn't work, any very tiny increase from it does. It just needs to be not too large so as to mess up in the range of test case. Conversely, for 1.01694, anything a tiny bit below 60/59 would work. It seems like this would be hard to express shorter than you have with it written out though.

Python 3.8, 40 36 bytes
lambda h,m:(d:=h+(h+m)//60,(d+m)%60)

Try it online!

R, 42 bytes
function(h,m)c(t<-(h*60+m)/59,60*t%%1)%/%1

Try it online!
Version 2: -3 bytes thanks to clarification that we don't need to output the first match when the timer & clock show the same numbers.
So this version outputs the second match for an input of 0:59 (in other words, 1:00instead of the first match at 0:59), and similarly for all other outputs that can end with :59 or :00.
R, Version 1: 49 45 bytes
function(h,m)c(t<-(h+m/60)*6/5.9,60*t%%1)%/%1

Try it online!
Outputs the first timer-clock match (so, always a match ending 0:59 instead of a subsequent match ending :00).
This exploits the floating-point rounding of *6/5.9 to slightly less than *60/59, but using the same number of characters.  This effectively gives us a floor-like result that rounds-down exact integers in the output (the desired behaviour).  Using *60/59 gives an exact floating-point result and so doesn't do this.
(Frustratingly, though, it still isn't as short as simply porting ovs's approach for 43 bytes). Version 2 (above) is shorter.

Don‘t wont to cause any frustration, but my approach can be 41 bytes :P.

@ovs Ha ha!  Well done!  I will struggle some more, then!

05AB1E, 13 10 bytes
ηO¤60÷+60%

Port of the approach used in @ovs' Python answer.
I/O as a pair of integers.
Try it online or verify all test cases.
Explanation:
η          # Get the prefixes of the (implicit) input-pair: [h,m] → [[h],[h,m]]
 O         # Take the sum of each inner list: [h,h+m]
  ¤        # Push the last item (without popping): h+m
   60÷     # Integer-divide it by 60: (h+m)//60
      +    # Add it to both values: [h+(h+m)//60,(h+m)+(h+m)//60]
       60% # Take modulo-60 on both: [(h+(h+m)//60)%60,((h+m)+(h+m)//60)%60]
           # (after which the result is output implicitly)

Retina 0.8.2, 69 bytes
\d+
$*
^
$'
+`:1{60}
1:
(1*):1*:
$.1:$1
:(1{60})?(1{10})*(1*)
:$#2$.3

Try it online! Link includes test cases. Uses @ovs' formula. Explanation:
\d+
$*

Convert to unary.
^
$'

Duplicate the input, which effectively sums the two values together.
+`:1{60}
1:

Add a sixtieth of the sum to the first value.
(1*):1*:
$.1:$1

Delete the remainder of the sum, convert the first value to decimal, and also add it to the second value (still in unary).
:(1{60})?(1{10})*(1*)
:$#2$.3

Convert the second value modulo sixty to two decimal digits.

Japt, 11 (10?) bytes
Port of Jo's Raku solution
ì60'*1.0#©4

Try it
This might work for 10 but I haven't fully tested it:
ì60'*6/5.9

Try it
ì60'*1.0#©4     :Implicit input of integer array
ì60             :Convert from base-60
   '*           :Multiply by
     1.0#©4     :  1.01694
                :Implicitly convert back to base-60 and output

Javascript, 43 42 bytes
h=>m=>[~~(h+(i=h+m)/60)%60,~~(61*i/60)%60]

Port of the approach used in @ovs' Python answer.
Input: two integers, output: List of [mm,ss]
Try it online.

Save a byte by currying the parameters.

JavaScript (V8), 28 26 bytes
h=>m=>[h+=h+m>59,(h+m)%60]

Based off of SomoKRoceS' JavaScript answer
Input: two integers, output: List of [mm,ss]
Try it online!

You don't need the parentheses after the +=.

Thanks @Shaggy, didn't see that anymore. They were a leftover from a previous iteration where they were needed.

J, 23 bytes
Based on Jo King's Raku answer. Input and output is in the form of 2-vectors.
<.@(1.01694&*)&.(60&#.)

Explanation:
              &.(60&#.) NB. Under base 60,
   (1.01694&*)          NB. multiply by the magic number,
<.@                     NB. then floor the result.

Try it online!