text:
Can Jimmy escape the ghosts?
It is Halloween and Jimmy (/o\) has gone into a mysterious neighborhood for trick-or-treating (ask himself why). Now some evil ghosts are chasing him. Can Jimmy escape the ghosts?
Challenge:
Input:
A board showing position of Jimmy, ghosts, solid objects and empty spaces.
An example 10x5 board, o is Jimmy (we needed a single character Jimmy), gs are ghosts, #s are solid objects and .s are empty spaces:
##########
......g...
#.o.......
#.....g...
##########

Output:
A truthy value if Jimmy can escape at least in one scenario, otherwise a falsy value.
How things work:
Ghosts and Jimmy can move one space each turn. There are 4 possible movements: left, right, up, down (no diagonal movements, no skipping).
On each turn, first ghosts move one space towards Jimmy. Ghosts always select the closest path to Jimmy, if two possible moves towards Jimmy have the same cost, the move going to left or right is chosen. Ghosts can go through solid objects, meaning at the end of a turn a ghost can be on same space as a solid object. Multiple ghosts can stay on same space too. This basically means all the ghosts on the same space will move exactly like each other after that point (they are all like a single ghost now).
After all ghosts have moved, if any of the ghosts ends up on the same space as Jimmy, Jimmy is caught and you have to try another scenario.
If Jimmy is not caught, he moves next. You have to decide on Jimmy's moves. Jimmy cannot go through solid objects. If Jimmy moves to a space with a ghost, he is caught. Jimmy cannot move into a space he has already visited. If Jimmy has no valid moves, consider him caught.
After Jimmy has moved, if he ends up on an empty border space (i.e. a space on the edge of the grid without a ghost on it), he has escaped.
If you can find at least one scenario where Jimmy can escape, output a truthy value. Also if the input position before doing any moves is already an escape position, it is valid and you should return truthy. If Jimmy is caught or out of valid moves in all possible scenarios, then return a falsy value.
Challenge rules:

You can use any consistent characters that you like for Jimmy, ghosts, solid objects and empty spaces in the input. You cannot use same character for different types of items though.
The input board is always a rectangle or square with a minimum size of 2x2 and a maximum size of 10x10.
Input is flexible as long as you don't include anything more than initial board information (for example, you cannot include if the initial board is already an escape position or not). It can be a multi-line string, a list of strings, a 2d array or matrix of characters or numbers, etc. It can also be position of items, for example a (x, y) for Jimmy and two lists of (x, y)s for ghosts and solid objects. You can also pass board size as a separate input if you like. Basically any format and combinations of inputs that don't include more than the initial board information are allowed.
Input is guaranteed to always have a single Jimmy.
Input always has at least one ghost.
Input always has at least one solid object.
Input can never start in a position where more than one item is on same space.
Input can start in a position which already is an escaped position for Jimmy (any input with Jimmy on a border space), you should return truthy for cases like this.

General rules:

This is code-golf, so shortest answer in bytes for every language wins. Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Test cases:
Truthy:
Jimmy can move left, up, left to escape:
##########
......g...
#.o.......
#.....g...
##########

Jimmy is already on a border space, this is an escape:
#.
og

If Jimmy moves only left or only right, he escapes:
#########
.........
....g....
...g.g...
....o....
...g.g...
....g....
.........

Jimmy has only two ways, one of them is an escape:
##########
#g.o.....#
########.#
#........#
#.########
#........#
########.#
#........#
#.########

Falsy:
Jimmy is caught by first move of any of the ghosts:
.....
..g..
.go..
.....
.....

Jimmy has no valid moves:
###.......
#o#......g
###.......

Jimmy will run out of valid moves before ghost can catch him:
#####.....
#o..#....g
#####.....

Remember, ghosts can go through solid objects:
g#.#
.#.#
.#.#
.#o#
.#.#
.#.#
g#.#

Oh poor Jimmy! It is a dead end...
##########
#...o....g
##########

Jimmy!!? How did you get there in the first place?
#.########
#g.......#
#....g...#
#......g.#
#..g.....#
#....g...#
#........#
#....g...#
#..g....o#
##########

Jimmy will run out of valid moves before ghost can caught him.

@A_ fixed, sorry for my poor English.

Is the rule "Jimmy cannot move into a space he has already visited" necessarily? Could anyone find an input which may yield different result when this rule is removed?

@tsh I believe it makes a difference. Without that rule, Jimmy can go left and right infinitely against a single ghost without escaping or getting caught. I put that rule in place to prevent infinite loops or very long scenarios that would make TIO not work for them.

@tsh example of infinite loop: https://i.imgur.com/66ZlURr.gif

Second truthy case looks wrong. You say the ghost moves first, so the ghost will catch Jimmy before he can even move. Otherwise, please update the rules.

How flexible is the input? Ideally, I'd like to take a integer position (x,y) for jimmy, a list of initial ghost integer positions [(g1x,g1y), ...] and then a 2-D matrix of integers 0/1 representation of the maze and its walls.

@LevelRiverSt: It is already specified twice: "Also if the input position before doing any moves is already an escape position, it is valid and you should return truthy." and "Input can start in a position which already is an escaped position for Jimmy (any input with Jimmy on a border space), you should return truthy for cases like this."

@ChasBrown input is flexible, you can use what you mentioned. Added an item under "Challenge rules:" section to clarify it more.

Python 2, 236 235 227 212 bytes
def f((x,y),G,M,U=[]):
 R=1-(len(M[0])-1>x>0<y<len(M)-1);H=[(u+cmp(x,u),v+cmp(y,v)*(u==x))for u,v in G];d,e=0,1
 for _ in' '*4*(R<1>((x,y)in H)):J=z,w=x+d,y+e;d,e=-e,d;R|=M[w][z]>(J in U)<f(J,H,M,U+[J])
 return R

Try it online!
-15 bytes thx to Bubbler
As input, takes a tuple (x,y) as jimmy's initial position, a list G == [(g1x,g1y), ...] of initial ghost positions, and a list of lists M which is the 2-dimensional binary matrix where cells are 0 if they contain "an object" (i.e., #) and 1 otherwise.
Returns 1 for truthy, 0 for falsey.
Loosely speaking, the idea here is that we're going to depth-first recurse over down, left, up, right to seek a border cell. To start,
R=1-(len(M[0])-1>x>0<y<len(M)-1)

R is truthy if jimmy starts on a border cell. We could just return R if he does, but that would add an additional return. So in any case, we calculate where the ghosts would move to next.
H=[(u+cmp(x,u),v+cmp(y,v)*(u==x))for u,v in G]

cmp(a,b) returns the sign of a-b as -1,0,1; so this updates the ghosts positions with preference for horizontal movement if possible. Next,
for _ in' '*4*(R<1>((x,y)in H)):

executes a loop 4 times (' '*4 is shorter than range(4)). Note that if jimmy is on the boundary (not R<1) or a ghost has landed on jimmy (not 1>((x,y)in H), then we skip the for loop and so we return 1 if jimmy has escaped, or 0 if a ghost got him.
    J=z,w=x+d,y+e;d,e=-e,d

d,e is the offset to jimmy's next position, starting as 0,1; and each time through the loop, d,e=-e,d rotates us through the 4 possible orthogonal positions.
    R|=M[w][z]>(J in U)<f(J,H,M,U+[J])

R gets set to truthy if jimmy's next position J is not an on "object" (M[w][z]>0), AND we haven't visited this position before (1>(J in U)), AND via recursion, jimmy can escape starting at position J with ghosts at H (0<f(J,H,M,U+[J])).

Well done! I tested with some more random test cases and could not break it.

Change the third line to for _ in' '*4*(R<1>((x,y)in H)):J=z,w=x+d,y+e;d,e=-e,d;R|=M[w][z]>(J in U)<f(J,H,M,U+[J]) for 212 bytes.

Python 2, 199 bytes
def g(I,G,W,w,h):
 u,v=I.real,I.imag;R=1-(w-1>u>0<v<h-1);H=[z+cmp(u,z.real)+cmp(v,z.imag)*(u==z.real)*1jfor z in G]
 for d in(R<1>(I in H+W))*range(4):J=I+1j**d;R|=(J in W)<g(J,H,W+[I],w,h)
 return R

Try it online!
Rewrite of Chas Brown's solution using complex numbers.
All the coordinates are represented as a complex number x+y*1j. I is Jimmy's position, G is the list of ghosts and W is the list of walls. w and h are the width and height of the board, respectively.
The output values and the algorithm are the same as the linked solution.

Javascript (ES6), 208 bytes
Recursive, depth-first search. A breadth-first approach would be probably faster, but less golfy.
Input: a multi line string, using 1 for ghosts, 4 for solid objects, 6 for Jimmy and 2 for empty space.
f=(s,l=-~s.search`
`,j=s.search(6),g=[...s],x=j%l)=>j<l|!g[j+l]|!x|x>l-3||(g[j]=6,![...g].some((a,i)=>a&1&&(g[--g[i],t=i%l,i+=t<x?1:t>x?-1:i<j?l:i>j?-l:0]|=1,i==j))&&[l,-l,1,-1].some(d=>2==g[d+=j]&&f(g,l,d)))

Less golfed
// using parameters with default values instead of declared variables

f = (s,  // input board (as a string at first call, then as an array)
     l = -~g.search('\n'), // line size +1, that is distance to next line
     // at first call it is calculated, for recursive calls is passed
     j = g.search(6), // position of jimmy in grid
     // at first call it is calculated, for recursive calls is passed
     grid = [...s], // modifiable copy of board (converted to char array)
     x = j % l, // x position of jimmy, always obtained from j
) =>
{
  // first, check if Jimmy is out
  if (j<l | !grid[j+l] | !x | x>l-3) // top,bottom,left,right border
  {
    return true
  }
  // move all ghosts and check if some ghost can take Jimmy
  // the loop is on a copy of grid, so I can safely modify grid during the loop
  var taken = [...grid].some( // check all ghosts
        (a,i) => a & 1 && ( // is it a ghost?
         --grid[i], // remove ghost from grid, as it will move
         t = i % l, // x position of ghost
         // move ghost towards Jimmy
         i += t < x
           ? 1
           : t > x
             ? -1
             : i < j
               ? l
               : i > j
                 ? -l
                 : 0,
         grid[i] |= 1, // put ghost on grid in its new position
         i == j // return true if it reached Jimmy
  )
  return !taken && // if taken return false immediately
  // else recurse
  [l,-l,1,-1].some( // try to move Jimmy in all directions
    d => (
      d+=j, 2==g[d] && f(grid, l, d))
    )
  )
}

Test

cases=['##########\n......g...\n#.o.......\n#.....g...\n##########\n'
,'#.\nog\n'
,'#########\n.........\n....g....\n...g.g...\n....o....\n...g.g...\n....g....\n.........\n'
,'##########\n#g.o.....#\n########.#\n#........#\n#.########\n#........#\n########.#\n#........#\n#.########\n'
,'.....\n..g..\n.go..\n.....\n.....'
,'###.......\n\#o#......g\n###.......\n'
,'#####.....\n#o..#....g\n#####.....\n'
,'g#.#\n.#.#\n\.#.#\n.#o#\n.#.#\n.#.#\ng#.#\n'
,'##########\n#...o....g\n##########\n'
,'#.########\n#g.......#\n#....g...#\n#......g.#\n#..g.....#\n#....g...#\n#........#\n#....g...#\n#..g....o#\n##########\n'
]

f=(s,l=-~s.search`
`,j=s.search(6),g=[...s],x=j%l)=>j<l|!g[j+l]|!x|x>l-3||(g[j]=6,![...g].some((a,i)=>a&1&&(g[--g[i],t=i%l,i+=t<x?1:t>x?-1:i<j?l:i>j?-l:0]|=1,i==j))&&[l,-l,1,-1].some(d=>2==g[d+=j]&&f(g,l,d)))

cases.forEach(x=> (
  console.log(x,
    f(x.replace(/#/g,4).replace(/\./g,2).replace(/o/,6).replace(/g/g,2|1)))
))

Jelly, 94 89 bytes
Ø.,U$;N$+®ŒṬ€×8+®ŒṬ¤+&7$Ç€Ẹ
&Ɱ8,2ŒṪ€Ḣ©_¥/Ṡ01¦Ạ¡€+ƲṪŒṬḤ+&13$ÑÇFṀ>8Ʋ?
|Ø.¦4Z$⁺FṀ=12ƲÇFṀ>8Ʋ?

Try it online!
A full program that takes an integer matrix as its argument, with 0 as space, 1 as wall, 2 as ghost and 8 as Jimmy. Returns 1 for escape and 0 for no escape.


text:
Slash the matrix
You are given a matrix of forward and back slashes, for instance:
//\\
\//\
//\/

A slash cuts along the diagonal of its cell corner-to-corner, splitting it in two pieces.
Pieces from adjacent (horizontally or vertically) cells are glued together.
Your task is to count the number of resulting pieces. For the same example, the pieces are easier to see in this illustration - 8 of them:

Write a function or a complete program. Input is a non-empty matrix in any convenient form. You may choose any pair of values (characters or numbers) to represent / and \; in the tests below we use 0=/ and 1=\. Loopholes forbidden. Shortest wins.
in:
[[0,0,1,1],
 [1,0,0,1],
 [0,0,1,0]]
out:
8

in:
[[1]]
out:
2

in:
[[1,0],
 [1,1],
 [0,1],
 [0,0]]
out:
6

in:
[[1,0,1,1,0,1,0,0,0,1,1,1],
 [1,0,1,0,1,1,1,1,1,1,1,0],
 [1,1,1,0,1,1,0,1,1,1,1,0],
 [0,1,0,1,0,1,0,0,1,0,1,1],
 [1,1,1,1,0,0,1,1,1,0,0,1]]
out:
19

in:
[[1,0,1,1,0,1,0,0,0,1,1,1,1,0,1,0,1],
 [1,1,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1],
 [1,0,0,1,0,1,0,1,0,0,1,0,1,1,1,1,1],
 [1,0,0,1,1,1,0,0,1,0,0,1,0,1,1,1,1],
 [0,1,0,0,0,0,1,0,1,0,0,1,0,1,1,1,1],
 [0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,1,0],
 [0,1,1,1,1,1,0,0,1,0,1,0,0,1,1,1,0]]
out:
27

in:
[[0,1,1,1,1,1,1,1,0,0,1,0,1,0,0,0,0],
 [1,1,1,0,0,0,1,1,1,1,1,0,1,1,0,1,0],
 [1,0,0,1,1,1,0,0,0,1,0,1,0,0,1,1,1],
 [0,0,0,1,1,0,1,0,0,0,1,1,0,1,1,1,0],
 [1,1,0,1,0,0,1,0,0,1,0,1,0,0,0,1,0],
 [0,1,0,1,0,0,0,1,0,1,0,1,0,1,1,0,0],
 [0,1,1,1,0,0,1,0,1,0,0,0,0,1,1,1,1]]
out:
32

MATL, 21 bytes
3XytPJ*-X*Xj~4&1ZIunq

The input is a matrix with 1 for \ and j (imaginary unit) for /.
Try it online! Or verify all test cases.
With some extra code, you can see the different pieces in random colours. Or increase the resolution for a better looking result.
Explanation
Consider input [1,j; 1,1; j,1; j,j] as an example. This corresponds to
\/
\\
/\
//

3Xy creates a 3×3 identity matrix:
1 0 0
0 1 0
0 0 1

tP pushes a copy of this matrix and flips it vertically. J* multiplies each entry by the imaginary unit, to give
0 0 j
0 j 0
j 0 0

- subtracts the two matrices:
 1     0    -j
 0   1-j     0
 -j    0     1

X* takes the input matrix implicitly and computes the Kronecker product. This  replaces each entry in the input matrix by its product with the above 3×3 matrix:
 1    0   -j    j    0    1
 0  1-j    0    0  1+j    0
-j    0    1    1    0    j
 1    0   -j    1    0   -j
 0  1-j    0    0  1-j    0
-j    0    1   -j    0    1
 j    0    1    1    0   -j
 0  1+j    0    0  1-j    0
 1    0    j   -j    0    1
 j    0    1    j    0    1
 0  1+j    0    0  1+j    0
 1    0    j    1    0    j

Xj takes the real part:
1 0 0 0 0 1
0 1 0 0 1 0
0 0 1 1 0 0
1 0 0 1 0 0
0 1 0 0 1 0
0 0 1 0 0 1
0 0 1 1 0 0
0 1 0 0 1 0
1 0 0 0 0 1
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0

Note how the above matrix is a "pixelated" version of
\/
\\
/\
//

~ applies logical negation, that is, swaps 0 and 1:
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
0 1 1 0 1 1
1 0 1 1 0 1
1 1 0 1 1 0
1 1 0 0 1 1
1 0 1 1 0 1
0 1 1 1 1 0
1 1 0 1 1 0
1 0 1 1 0 1
0 1 1 0 1 1

4&1ZI specifies 4-connectivity, and finds connected components considering 1 as foreground and 0 as background. The result is a matrix of labelled connected components, where each original 1 is replaced by an integer label:
0 3 3 3 3 0
1 0 3 3 0 5
1 1 0 0 5 5
0 1 1 0 5 5
2 0 1 1 0 5
2 2 0 1 1 0
2 2 0 0 1 1
2 0 4 4 0 1
0 4 4 4 4 0
4 4 0 4 4 0
4 0 4 4 0 6
0 4 4 0 6 6

unq computes the number of unique elements and subtracts 1. This gives the number of components, which is implicitly displayed.

would it help if you chose [1,0,0; 0,1,0; 0,0,1] and [0,0,j; 0,j,0; j,0,0] as the two values for \ and /?

The essential idea of resizing the slashes so that connected components work naturally is fantastic.

@ngn I assumed that wasn't allowed. Yes, it would help, but allowing that would make the challenge less interesting in my opinion. (Also my answer would be less interesting, as Jonah's eloquent comment illustrates). By that rule, using [1,0,0; 0,1,0; 0,0,1] and [0,0,1; 0,1,0; 1,0,0] would probably be valid too?, and then the challenge would just be "find connected components", which is less interesting and possibly a dupe. So my recommendation, if I may say so, is to require two different characters or numbers as inputs. That's how I understood "Given a matrix of forward and back slashes"

@LuisMendo tbh, when i designed the challenge i didn't anticipate that reduction to connected components could be done so easily - that's the beauty of your solution. i'll amend it as you recommend.

MSX-BASIC, 226 199 bytes
1SCREEN2:READC,L:W=256/C:H=192/L:FORJ=1TOL:FORI=1TOC:A=H:B=H:READD:IFDTHENA=0:B=-H
2LINE(I*W,J*H-A)-STEP(-W,B):NEXTI,J:FORY=0TO191:FORX=0TO255:IFPOINT(X,Y)=4THENR=R+1:PAINT(X,Y)
3NEXTX,Y:SCREEN0:?R

This script draw slashes on a whole screen and use PAINT operator to count closed areas.

To test:

copy to clipboard the script with test cases data (see below)
open online emulator https://webmsx.org/
press Alt-V and Ctrl+V to past test script into MSX
press Enter and F5 to run test script
wait a some time to see a result (press Shift-Alt-T to switch in CPU Turbo 8X mode to save your time)

1SCREEN2:READC,L:W=256/C:H=192/L:FORJ=1TOL:FORI=1TOC:A=H:B=H:READD:IFDTHENA=0:B=-H
2LINE(I*W,J*H-A)-STEP(-W,B):NEXTI,J:FORY=0TO191:FORX=0TO255:IFPOINT(X,Y)=4THENR=R+1:PAINT(X,Y)
3NEXTX,Y:SCREEN0:?R
10 ' this and below lines are not counted
20 ' the script runs first uncommented test case.
30 ' comment unnecessary test cases
100 '
110 'test case 1: expected output=8
120 'DATA 4,3
130 'DATA 0,0,1,1,1,0,0,1,0,0,1,0
200 '
210 'test case 2: expected output=2
220 'DATA 1,1
230 'DATA 1
300 '
310 'test case 3: expected output=6
320 'DATA 2,4
330 'DATA 1,0,1,1,0,1,0,0
400 '
410 'test case 4: expected output=19
420 'DATA 12,5
430 'DATA 1,0,1,1,0,1,0,0,0,1,1,1
440 'DATA 1,0,1,0,1,1,1,1,1,1,1,0
450 'DATA 1,1,1,0,1,1,0,1,1,1,1,0
460 'DATA 0,1,0,1,0,1,0,0,1,0,1,1
470 'DATA 1,1,1,1,0,0,1,1,1,0,0,1
500 '
510 'test case 5: expected output=27
520 DATA 17,7
530 DATA 1,0,1,1,0,1,0,0,0,1,1,1,1,0,1,0,1
540 DATA 1,1,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1
550 DATA 1,0,0,1,0,1,0,1,0,0,1,0,1,1,1,1,1
560 DATA 1,0,0,1,1,1,0,0,1,0,0,1,0,1,1,1,1
570 DATA 0,1,0,0,0,0,1,0,1,0,0,1,0,1,1,1,1
580 DATA 0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,1,0
590 DATA 0,1,1,1,1,1,0,0,1,0,1,0,0,1,1,1,0
600 '
610 'test case 5: expected output=32
620 DATA 17, 7
630 DATA 0,1,1,1,1,1,1,1,0,0,1,0,1,0,0,0,0
640 DATA 1,1,1,0,0,0,1,1,1,1,1,0,1,1,0,1,0
650 DATA 1,0,0,1,1,1,0,0,0,1,0,1,0,0,1,1,1
660 DATA 0,0,0,1,1,0,1,0,0,0,1,1,0,1,1,1,0
670 DATA 1,1,0,1,0,0,1,0,0,1,0,1,0,0,0,1,0
680 DATA 0,1,0,1,0,0,0,1,0,1,0,1,0,1,1,0,0
690 DATA 0,1,1,1,0,0,1,0,1,0,0,0,0,1,1,1,1

Wait a second... this isn't powershell

oops! ¯\(ツ)/¯

JavaScript (ES6),  175  174 bytes
This is probably overcomplicated.
a=>a.map((r,y)=>r.map((v,x)=>[2,4].map(s=>v&s||(n++,g=(x,y,s,i,v=(r=a[y])&&r[x])=>!(v&(s^=i%2==v%2&&6))/v&&g(x+1-(r[x]|=s,s&2),y++,s^6)|g(x,y-=v%2*2^s&2,s,v))(x,y,s))),n=0)|n

Try it online!

Charcoal, 70 bytes
≔×³Ｌθη≔×³Ｌ§θ⁰ζＢζηψＦＬθ«Ｊ¹⊕×³ιＦ§θι«¿κＰ\²Ｐ/²Ｍ³→»»Ｆη«Ｊ⁰ιＦζ«⊞υ¬℅ＫＫ¤#→»»⎚ＩΣυ

Try it online! Link is to verbose version of code. Uses the same format as the examples (except Charcoal requires the list of inputs as an outer array). Explanation:
≔×³Ｌθη≔×³Ｌ§θ⁰ζ

Like @LuisMendo, we're going to be drawing the matrix at 3x scale, so calculate that in advance.
Ｂζηψ

Draw an empty rectangle of that size so that we can fill the edge pieces.
ＦＬθ«Ｊ¹⊕×³ιＦ§θι«

Loop over the rows and columns.
¿κＰ\²Ｐ/²Ｍ³→»»

Draw each slash at triple size and move to the next one.
Ｆη«Ｊ⁰ιＦζ«

Loop over all of the squares.
⊞υ¬℅ＫＫ

Record whether this square was empty.
¤#→»»

But try filling it anyway before moving on to the next square. (Fill does nothing if the current square is not empty.)
⎚ＩΣυ

Clear the canvas and output the total number of empty squares found, which equals the number of pieces (because each piece would have been immediately filled in as soon as we counted it).

C# (Visual C# Interactive Compiler), 292 bytes
n=>{var x=n.SelectMany(l=>"\0".Select(g=>l.SelectMany(r=>r.Skip(g).Concat(r.Take(g))).ToList())).ToList();int i=0,j=0,t=0;for(;i<x.Count;i++)for(j=0;j<x[0].Count;k(i,j++))t+=x[i][j]%2;void k(int a,int b){try{if(x[a][b]<50){x[a][b]='2';k(a+1,b);k(a-1,b);k(a,b-1);k(a,b+1);}}catch{}}return t;}

The \0 should be a literal null byte.
112 for /, 211 for \
Try it online!

Jelly, 50 46 bytes
®_ż+¥"SƝż€"Jż‘$$ḞṖ
ZJḤ©Żż‘$;€þJ;ÇẎfƇ@Ẏ¥€`Q$ÐLL

Try it online!
A full program taking a matrix as its input with -0.5 as / and 0.5 as \. Returns an integer with the number of pieces.
Full explanation to follow, but works by generating a list of all the pairs of connected cells, and then merging overlapping sets until there’s no change. The final number of sets is the desired answer.

source: Stack Exchange

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

sort: votes


text:
Multigraphs with a given degree sequence
This challenge will give you an input of a degree sequence in the form of a partition of an even number. Your goal will be to write a program that will output the number of loop-free labeled multigraphs that have this degree sequence.
Example
For example, given the input [3,3,1,1], you should output the number of labeled multigraphs on four vertices \$\{v_1, v_2, v_3, v_4\}\$ such that \$\deg(v_1) = \deg(v_2) = 3\$ and \$\deg(v_3) = \deg(v_4) = 1\$. In this example, there are three such multigraphs:

See Gus Wiseman's links on OEIS sequence A209816 for more examples.
Target data
input           | output
----------------+--------
[6,2]           | 0
[5,3,2]         | 1
[3,3,1,1]       | 3
[4,3,1,1,1]     | 6
[4,2,1,1,1,1]   | 10
[1,1,1,1,1,1]   | 15
[3,2,2,2,1]     | 15
[2,2,2,2,2]     | 22
[7,6,5,4,3,2,1] | 7757

Challenge
This is code-golf so shortest code in bytes wins.

Haskell, 57 bytes
f(h:t)=sum[f l|l<-mapM(\n->[0..n])t,sum t-sum l==h]
f _=1

Try it online!

Haskell, 127 bytes
e=[]:e
h a b=mapM id$b<$a
f a=length[0|x<-h a$h a[0..maximum a],x==foldr(zipWith(:))e x,all(<1)$zipWith(!!)x[0..],map sum x==a]

Try it online!
Very very inefficient (superexponential), but I believe it should work in theory. Exceeds Tio's 60 second limit with [3, 3, 1, 1] as input, but works with [1, 1, 1, 1].
Considers the adjacency matrices of the multigraphs.
h a$h a[0..maximum a] is a list of all square matrices with entries between 0 and maximum a, with size length a.
x==foldr(zipWith(:))e x checks if a matrix is symmetric.
all(<1)$zipWith(!!)x[0..] checks that the diagonal entries are zero, since there are no loops.
map sum x==a checks that each vertex has the proper degree.

Haskell, 75 bytes
f(h:t)=sum$f<$>h%t
f[]=1
r%(h:t)=[h-i:x|i<-[0..r],x<-(r-i)%t]
r%_=[[]|r==0]

Try it online!
It's faster (and easier to understand) when i<-[0..r] is replaced by i<-[0..min r h]. Also, it's faster to give the degrees (whose order obviously doesn't matter) in increasing order.

i<-[0..h] seems to be the better way to trade time for code length...

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


text:
Generate input for this hardware
I have a hardware that has a 32-bit input register. The register has the following characteristics:

The 32-bit register consists of eight 4-bit fields.
Each 4-bit field holds a value in signed-magnitude; it can hold an integer between -7 and +7 inclusive, including -0 and +0 (signed zeroes).

For example, the hexadecimal value 0xABCD1234 represents the field values [-2, -3, -4, -5, +1, +2, +3, +4]. In fact, one hex digit represents one 4-bit value with the following mapping:
Hex    |  Input value
---------------------
0 ~ 7  |  +0 ~ +7
8 ~ F  |  -0 ~ -7

In order to operate this hardware, I figured that the most natural inputs would be 8 consecutive increasing values, treating -0 and +0 as distinct. So the input values will be one of the following:
field values for 8 fields        => 32-bit register value
[-7, -6, -5, -4, -3, -2, -1, -0] => 0xFEDCBA98 (offset -4)
[-6, -5, -4, -3, -2, -1, -0, +0] => 0xEDCBA980 (offset -3)
...
[-3, -2, -1, -0, +0, +1, +2, +3] => 0xBA980123 (balanced, offset 0)
...
[+0, +1, +2, +3, +4, +5, +6, +7] => 0x01234567 (offset +4)

I define the input 0xBA980123 as balanced, and the other inputs have an offset from the balanced input. The balanced input itself has offset 0.
Task
Given the offset, output the desired value for the input register for my hardware as described above.
Input and output
The input (offset) is an integer between -4 and 4 inclusive. You can take it as a string, optionally with explicit sign (e.g. +4).
You can output the result value as an integer or a string. If you choose to output as a string (either returning or printing), you can use base 2, 8, 10 or 16. In case of hexadecimal, mixing upper- and lowercase letters are allowed. Base prefixes (e.g. 0b or 0x), leading zeros, and leading/trailing whitespaces are also allowed.
You may use signed 32-bit values for output instead (imagine the values being used in a C program); in that case, the output values will be subtracted by 2^32, except for the input +4.
Scoring
The standard code-golf rules apply. The shortest code in bytes wins.
All test cases
There are only nine possible inputs, so here is the list of all input/output values your program/function needs to support.
input =>  output hex | decimal    | signed 32bit
-4    =>  0xFEDCBA98 | 4275878552 | -19088744
-3    =>  0xEDCBA980 | 3989547392 | -305419904
-2    =>  0xDCBA9801 | 3703216129 | -591751167
-1    =>  0xCBA98012 | 3416883218 | -878084078
 0    =>  0xBA980123 | 3130523939 | -1164443357
 1    =>  0xA9801234 | 2843742772 | -1451224524
 2    =>  0x98012345 | 2550211397 | -1744755899
 3    =>  0x80123456 | 2148676694 | -2146290602
 4    =>  0x01234567 | 19088743   | 19088743

It seems you've gone a long way to accept many base representation outputs, are lists of the place values as integers acceptable? (e.g. 0 -> [11,10,9,8,0,1,2,3] as a raw hexadecimal notation)

@JonathanAllan Sorry, but I feel like it's a bit of stretch.

It is somewhat more natural than a string IMO, but OK, a 2 byte cost to convert from base 16 to an integer for Jelly it is.

Ruby, 30 bytes
Simple and clean. Outputs a substring of the larger with the right offset because it seemed cheaper than any method I could think of that calculated it properly.
->o{"FEDCBA9801234567"[o+4,8]}

Try it online!

If you would believe it, I came up with the exact same idea that you did, just about a minute later

@EmbodimentofIgnorance I believe it. This seemed like the easiest option right off the bat, anyways, so it's literally a matter of who sees the challenge first haha

Am I missing something or should it be FEDCBA...?

C (gcc), 35 32 bytes
f(n){n=0xFEDCBA99l*~0u>>16-4*n;}

Try it online!

Jelly, 14 bytes
12_r8Ḋ;8Ḷ¤ḣ8ḅ⁴

A monadic Link accepting an integer which yields an integer.
Try it online!
How?
12_r8Ḋ;8Ḷ¤ḣ8ḅ⁴ - Link: integer N     e.g. 4              or     -2
12             - literal twelve           12                     12
  _            - subtract N               8                      14
    8          - literal eight            8                      8
   r           - inclusive range          [8]                    [14,13,12,11,10,9,8]
     Ḋ         - dequeue                  []                     [13,12,11,10,9,8]
         ¤     - nilad followed by link(s) as a nilad:
       8       -   literal eight = 8
        Ḷ      -   lowered range = [0..7]
      ;        - concatenate              [0,1,2,3,4,5,6,7]      [13,12,11,10,9,8,0,1,2,3,4,5,6,7]
           8   - literal eight            8                      8
          ḣ    - head to index            [0,1,2,3,4,5,6,7]      [13,12,11,10,9,8,0,1]
             ⁴ - literal sixteen          16                     16
            ḅ  - to integer from base     3130523939             3703216129

JavaScript (Node.js), 38 bytes
n=>~(p=19088743)*16**(n+4)|p*16**(n-4)

Try it online!
In two's complement representation, 0xfedcba98 is "not 0x01234567 (19088743)". We first shift 0xfedcba98 \$ 4(n+4) \$ bits left, and shift 0x01234567 \$ 4(4-n) \$ bits right. Then use bit or to add them up.
JavaScript do not support n << 32, so we use n * 2 ** 32 instead. And bitwise or in JavaScript automatically convert operand to int32. The two float value trimed to int32 and calculated the result.

Another not quite interesting answer:
JavaScript (Node.js), 35 bytes
n=>'FEDCBA9801234567'.substr(4+n,8)

Try it online!

Python 3, 60 56 52 37 bytes
lambda n:"FEDCBA9801234567"[4+n:12+n]

Try it online!

+1. I had basically the same idea: lambda n:"FEDCBA9801234567"[4+n:][:8] (Same length)

@pizzapants184 i find your solution even more elegant :)

APL (Dyalog Unicode), 23 22 bytes (SBCS)
8↑('FEDCBA98',⎕D)↓⍨4+⊢

Try it online!
First time trying to use APL for golf. Any suggestions for improvement would be greatly appreciated. I put s← in the code field for testing purposes; is there a better way to do that?
(Edit: Removed the s← and saved a byte thanks to Bubbler)

You can wrap a line of code into a function like this. Also, save a byte by going tacit. For general tips, check out APL golfing tips.

Charcoal, 20 bytes
Ｎθ⭆…⁻θ⁴⁺θ⁴⎇‹ι⁰⍘⁻⁷ιφι

Try it online! Link is to verbose version of code. Outputs 8 hex digits. Explanation:
Ｎθ                      Input the offset
  ⭆…                    Map and join over range
    ⁻θ⁴                 From offset - 4 (inclusive)
       ⁺θ⁴              To offset + 4 (exclusive)
          ⎇‹ι⁰          If current value is negative
              ⍘⁻⁷ιφ     Then subtract from 7 and convert to hex
                   ι    Else use directly as digit
                        Implicitly print

Haskell, 38 bytes
f n=take 8$drop(n+4)"FDECBA9801234567"

Try it online!

Perl 6, 28 26 bytes
{:16[11-$_...^7,|^($_+4)]}

Try it online!
Explanation
{                        }  # Anonymous block
     11-$_...^7             # Range 11-n down to 7 exclusive
               ,|^($_+4)    # Followed by range 0 to n+4 exclusive
 :16[                   ]   # Convert from base 16

Wren, 40 bytes
Fn.new{|a|"FEDCBA9801234567"[a+4..a+11]}

Try it online!
Simply a port of most other answers.
Wren, 70 67 bytes
Horribly long answer; outputs to STDOUT.
Fn.new{|a|
for(i in a..a+7)System.write("4567FDECBA980123"[i%16])
}

Try it online!
Explanation
Fn.new{                                                // New anonymous function
       |a|                                             // with parameter a
                                                       // newline because this is
                                                       // not an expression
for(i in a..a+7)                                       // For every item in the range
                                                       // from a to a+7
                                                       // (Select 8 items in the string)
                System.write("4567FDECBA980123"        // Output the string
                                               [i%16]  // with the index of i modulo'd by 16.
                                                       // Moduloing maps the items in
                                                       // the iteration back to the start
                                                       // of the string.
)                                                      // Pretty self-explanatory.
}                                                      // no need to explain this

Keg, 19 bytes (SBCS)
7Ï89AFɧ(¿4+|")^(8|_

Try it online!

Turns out the 22 byter I gave earlier was kinda broken. Fixed 22 byter

19 bytes

05AB1E, 12 11 bytes
4Ø4Ÿα7ÝÂ‡hJ

Try it online!

You can remove the trailing J and just output as a list of characters, can you not?

Bash, 35

1 byte saved thanks to @79037662.

s=FEDCBA9801234567
echo ${s:$1+4:8}

Try it online!

I believe the last 8 in line 1 is unnecessary.

@79037662, thanks! not sure how that one crept in!

Gaia, 12 11 bytes
11⁻7N8…+8<h

Try it online!
Test suite
11⁻          11 - input
   7N        Downward range from result to 7 (excluding 7, empty list if first number is 7)
     8…+     Append the range 0-7 (inclusive)
        8<   First 8 numbers
          h  Convert from hexadecimal

PHP, 38 bytes
<?=substr(FEDCBA9801234567,4+$argn,8);

Try it online!

K (ngn/k), 22 bytes
(8':"FEDCBA98",/$!8)4+

Try it online!

"FEDCBA98",/$!8 is shorthand for "FEDCBA9801234567" (sets up a raze seeded with "FEDCBA98", run over a list of strings each containing one digit from 0..7)
(8':...) take 8-length sliding windows of the generated string (creates a list of 9 items)
(...)4+ index into that list using the (implicitly) provided index, offsetting by +4 so -4 => 0, -3 => 1, ..., 4 => 8

JavaScript (ES6), 42 bytes
f=(o,n=8)=>n&&f(o-1,n-1)*16+(o<-3?4-o:o+3)

Try it online!

C# (Visual C# Interactive Compiler), 38 bytes
x=>"FEDCBA9801234567".Substring(x+4,8)

Each valid output is just a rotation of the string FEDCBA9801234567
Try it online!

JavaScript (Node.js), 32 bytes
f=n=>n+4?f(--n)*16|n+4:-19088744

Try it online!
Shorter than hardcode


text:
Find the shortest route on an ASCII road
You want to find the length shortest path between two points, on an 2d ASCII "map". The roads are made up of + characters, and the two endpoints are represented by #s (not counted in the length). This road can be arranged in any way, and any other characters can be ignored. You can assume the endpoints will always connect to each other through roads.
Examples:
Output: 1
#+#

Output: 5
   #+
+   +
++++++
   +
   #

Output: 8
++++#+++
+      +
+      +
++#+++++

Output: 4
#+++
++++
+++#

Output: 2
+++++
+   +
+#  +
+++#+
   +
 +++

Undefined output:
##

#   +++#
+    +

#+++#
    +
    +
    #

#++
  +

Rules:

You can take input as a 2d array, matrix, string separated by newlines, etc.
Output should be a number
Can be a snippet, function, or full program
You can represent one endpoint with a different character if necessary

Shouldn't ## output 0? What should output for ##\n++?

@tsh Assume they aren't touching

May we use different ascii characters for start and end?

@Jitse Sure, I guess. I'll update the rules to allow that

Can you include a test case where the end points are not on the edges?

@Jitse Okay. Didn't even notice I'd forgotten that (:

Thanks! It seems that for your new example the shortest path is 2 and not 4, though.

@Jitse facepalm I'll fix that

Python 3, 146 bytes
def f(k,*s):w=k.find('\n')+1;*p,x=k.find('#'),*s;return len(k*(x in p or'#'>(k+w*' ')[x])or('+'<k[x])*s[1:])or min(f(k,*s,x+a)for a in(-1,1,-w,w))

Try it online!
Uses # for start and @ for end. Finds all paths along + and returns the shortest. Each path ends when either a space is encountered, the range is outside the box or a previous position is visited.

Python 3 (+ numpy), 183 bytes
Assuming the input can be passed in as a numpy character array, here is a different approach. It works by calculating a distance matrix from the start point by repeatedly 'diffusing' distances along roads. Uses '#' for start and '@' for end.
from numpy import*
def f(A):
 B=(A!=" ")-1+(A=="#")
 for _ in nditer(A):B=pad(B,1);B+=(B==0)*stack(roll(B+(B>0),n%3-1,n%2)for n in[0,2,3,5]).max(0);B=B[1:-1,1:-1]
 print(*B[A=="@"]-2)

Try it online! (11 bytes longer as the version of numpy on TIO requires an explicit mode parameter for pad, which is no longer the case)

JavaScript (ES7),  131  130 bytes
Takes input as a matrix of characters. Expects 1 for the starting point and 2 for the arrival.
m=>(M=g=(X,Y,n)=>m.map((r,y)=>r.map((c,x)=>(X-x)**2+(Y-y)**2^1?c^1||g(x,y,r[x]=g):1/c?c^2|M>n?0:M=n:r[g(x,y,r[x]=~-n),x]=c)))()|-M

Try it online!

Java 8, 421 408 403 400 351 bytes
int M[][],v[][],l,L;m->{int i=(l=m.length)*(L=m[0].length);for(M=m,v=new int[l][L];m[--i%l][i/l]!=65;);return f(i%l,i/l,-1>>>1,-1);}int z(int x,int y,int r,int d){return x<l&y<L&x>=0&y>=0&&M[x][y]>32&v[x][y]<1?f(x,y,r,d):r;}int f(int x,int y,int r,int d){return M[x][y]>65?r>d?d:r:z(x,y-1,z(x-1,y,z(x,y+1,z(x+1,y,r,d+=v[x][y]=1),d),d),d)+(v[x][y]=0);}

-57 bytes thanks to @ceilingcat.
Input as a matrix of bytes, with A as start and B as finish.
Try it online.
Explanation:
int M[][],                // Matrix on class-level, starting uninitialized
    v[][],                // Visited matrix on class-level, starting uninitialized
    l,L;                  // x and y dimensions on class-level, starting uninitialized

m->{                      // Method with integer-matrix as input and integer as return
 int i=(l=m.length)       //  Set `l` to the amount of rows
       *(L=m[0].length);  //  Set `L` to the amount of columns
                          //  And set `i` to the product of the two
 for(M=m,                 //  Set `M` to the input-matrix
     v=new int[l][L];     //  Create the visited-matrix filled with 0s
     m[--i%l][i/l]!=65;); //  Loop as long as the current cell doesn't contain an 'A'
 return f(                //  Start the recursive method `f` with:
   i%l,i/l,               //   The current cell as the starting x,y-coordinate
   -1>>>1,                //   Integer.MAX_VALUE as starting minimum-distance
   -1);}                  //   And -1 as amount of steps

int z(int x,int y,int r,int d){
                          // Method `z` to check whether we can travel to the given cell
  return x<l&y<L&x>=0&y>=0//  If the x,y-coordinate is within the matrix boundaries,
    &&M[x][y]>32          //  and that the current cell does NOT contain a space,
    &v[x][y]<1?           //  and we haven't visited this cell yet:
      f(x,y,r,d)          //   Return a call to the recursive method `f` with the same arguments
    :                     //  Else:
     r;}                  //   Return the row

int f(int x,int y,int r,int d){
                          // Create the recursive method `f`
  return M[x][y]>65?      //  If the current cell contains 'B':
     r>d?d:r              //   Return the minimum of the min-distance and amount of steps
    :                     //  Else:
     z(x,y-1,             //   Do a recursive `z`-call westward,
       z(x-1,y,           //   do a recursive `z`-call northward,
         z(x,y+1,         //   do a recursive `z`-call eastward,
           z(x+1,y,r,     //   do a recursive `z`-call southward,
             d+=v[x][y]=1),d),d),d)
                          //   after we've first marked the current cell as visited
     +(v[x][y]=0);}       //   And unmark the current cell as visited afterwards

J, 65 bytes
Takes the ASCII map with # and * for end goals.
1 i:~&,('*'i.~,){&,"2<@#@,((,-)#:i.3)&(*@]*[:>./|.!.0)3|' +# 'i.]

Try it online!
How it works
3|' +# 'i.       converts streets/goal to 1, start to 2, space to 0
((,-)#:i.3)      the 4 offsets + identity
(         |.!.0) shift the matrix in the directions,
     [:>./       join them by taking the greatest number,
 *@]*            and setting spaces back to 0
<@#@,            call the above function NxM times,
                   building up the results
('*'i.~,){&,"2   flatten the results, taking the position of the goal
1 i:~&,          last place the goal was 1 (before being overwritten to 2)

Jelly, 31 28 27 bytes
Takes input as a list of lines. Incredibly slow.
œẹⱮ⁾+#ŒP;€¥/Œ!ạƝ§ṀƊ€ṂƊÞḢL_2

Try it online!
Comments (slightly outdated):
ạƝ§=1Ạ   -- helper function: is this a connected path?
ạƝ       -- element-wise absolute differences of adjacent coordinates
  §=1Ạ   -- do all differences sum to 1?

  Ɱ⁾+#   -- call with right arguments '+' and '#'
œẹ       --   multidimensional indices of right argument in inputs
    ¥/   -- call next two functions with '+'-indices on the left and '#'-indices on the right
ŒP       --   all subsets of the '+'-indices
  ;€     --   append '#'-indices to each subset

     ƊƇ  -- filter; keep subsets where the following three functions yield a thruthy result
Œ!       --   all permutations of the subsets
  Ç€     --   call the helper function for each subset
    Ẹ    --   is any result truthy?
Ḣ        -- take first (shortest) subset
 L_2     -- length - 2


text:
Who's Who in the Name-Change Game?
Very recently, I changed my SE username because I made this account some years ago and wanted to get back into asking questions. However, I’m still planning to post questions and potentially earn votes. We can imagine a site that has some issues dealing with name changes. The problem: given a list of names, reputation changes, and name changes, can you create a leaderboard of reputation? Assume everyone's reputation starts at 0.
Input comes in any reasonable format, and has two forms: a name change <String, String> and a rep change <String, Number>.
What does any reasonable format mean? When I write questions, it usually means the input can be rearranged or repackaged to work with the way your language takes in input (do you want a list of pairs? two lists? a string? that’s all fine) as long as it doesn’t add information or otherwise offload some of the computational work onto the human.
Name changes change a person’s username to any username not currently in use. For example, if A changes name to D, and B changes name to C, D (previously known as A) could still change their name to A or to B, even though these names have been used before. However, at any given moment the set of names are unique.
Rep changes represent something like getting up/down votes on a post, receiving a bounty, etc. All rep changes are guaranteed to be integers. They might come in the form <“Bob”, 5> or <“Alice”, -53000>. At the end, you must output all usernames that are currently in existence, and their rep counts, in descending order.
Test case:
Alice 5
Bob 7
Bob John
John 113
Alice Cheryl
Daniel 13
John Alice
Alice 12

Result:
Alice 132
Daniel 13
Cheryl 5

Test case, suggested by Unrelated String:
Jimmy Adam
Donald 12
Amelia -11

Result:
Donald 12
Adam 0
Amelia -11

Test case:
CodegoLfer65 12
Bluman 9
CodegoLfer65 n4me
n4me -3

Result:
Bluman 9
n4me 9 (note: these two can be in either order)

Usernames are composed of only [A-Za-z0-9], i.e. alphanumerics. However, the input will not be a number in your language. This means usernames like 144, 015, 0x0F, 1e7 will not appear in the input. Numbers such as 1/3, 2.8 do not appear due to the character specification in the first place.
This question seems heavy on data structures, so golfing languages may not perform as well. Maybe other languages will have a fighting chance? Scoring is by lowest number of bytes, i.e. tag:code-golf .

Can a user be instantiated by changing their name, without having gained rep?

Yes. I will add this test case. Note that the "old name" in that case really doesn't matter at all.

May I assume rep change will never be zero?

What order should I use in case their rep are tie?

@tsh "May I assume rep change will never be zero?" I would vote yes, as 0 is not a change.

What assumptions may we make about the user names? [A-Z][a-z]+?

@Adám Updated posts to clarify alphanumeric.

@tsh If tied, any order is valid.

@Adám Additionally though I clarified that usernames won't be composed of only numbers, because otherwise it's impossible to know if Name 97 is a rep change or a username change.

Do we need to deal with illegal name changes?  Error or ignore them?

Suggested test case of Bob 5, Bob John, Bob 10. That should result in Bob 10, John 5, right?

Must names such as 1e4 and 0x123 be permitted? If so, there should probably be a test case such as Alice 1e4, Bob 0x123. A few of the answers treat 1e4 as a number.

@Jonah As is the case in general, no. Valid inputs are the only inputs.

@Tesseract I just added the note that whatever the input is, it won't be able to be parsed as a number. The intent of the challenge isn't to force some weird string parsing, and it will unnecessarily penalize languages that parse numbers that way.

Suggested test case: Alice 12, Ali 10, Ali Lauren, Laurence 18 -> Laurence 18, Alice 12, Lauren 10 (Alice shouldn't become Laurence after Ali Lauren, in case someone uses a string-replace).

Python 3, 115 bytes
def f(l):
 r={}
 for n,m in l:q=m*0!=0;r[[n,m][q]]=r.pop(n,0)+[m,0][q]
 return sorted(r.items(),key=lambda i:-i[1])

Try it online!

Ruby, 102 101 95 94 93 90 bytes
->c{l={};c.map{|a,b|x=l[a]||0;b*0!=0?(l[b],l[a]=x,p):l[a]=x+b};l.compact.sort_by{|a,b|-b}}

This takes input in the form of a list of ["name", "new_name"/score] pairs. And it outputs in an ordered list of ["name", score]
Golfy Tricks

I used p with no args to get a nil value.
I used String===b instead of b.is_a?String
I used b!=b.ord b.ord!=b to find out if it's a string or not. See String.ord and Integer.ord
I'm using b*0!=b to check if it's a string or not.
For some reason, b.ord!=b means that I don't need a space between the ? ternary operator and the following (, but if I swap it to b!=b.ord, then another whitespace is needed.
I sorted by -b, rather than by b and then reversing (d'oh!)

Try it online!
Edit: Thanks to Veskah, for pointing out some problems this solution was missing. Somehow adding a temporary variable to hold l[a]||0 has shortened the code by a byte.
Edit: Thanks to G B, for suggesting b*0!=0 instead of b.ord!=b, which also allowed me to get rid of the space before the ?, saving 3 characters.

@Veskah: Yep, good find. Forgot about the implication of just setting the default value, as I set the values to nil when the name changes.

I also misunderstood that test case. Thanks for helping iron out the "edge cases" (read: cases that I just plain missed).

use b*0!=0 to check if b is a string (-3 bytes)

PHP, 111 bytes
for(;$n=$argv[++$i];+$r&&$a[$n]+=$r)if(!+($r=$argv[++$i])&&$a[$r]=+$a[$n])unset($a[$n]);arsort($a);print_r($a);

Try it online!
Inputs are command arguments ($argv) as a plain list like: Alice, 5, Bob, 7. Every item is a separate argument.
Commented
for(;
  $n=$argv[++$i];    // $n is set to the first parameter (name) for each event
  +$r&&$a[$n]+=$r)   // at the end of each iteration if $r is a number
                     //   add it to reputation of $n
  if(
    !+(
      $r=$argv[++$i] // $r is set to the second event parameter (name or reputation change)
    )&&
    $a[$r]=+$a[$n])  // if $r is a name, transfer reputation of $n to $r
      unset($a[$n]); //   and remove $n from $a
arsort($a);          // after the loop, sort $a by its values in descending order
print_r($a);         // print $a as string

PHP, 98 bytes
This one shows non-existing users too (at the end of the list), but shows nothing as their reputation.
for(;$n=$argv[++$i];arsort($a))+($r=$argv[++$i])?$a[$n]+=$r:[$a[$r],$a[$n]]=[+$a[$n]];print_r($a);

Try it online!

K (ngn/k), 65 bytes
{(>x)!x@>x}(0#`!0){(n;a):y;$[`i~@a;@[x;n;+;a];@[x;a;:;0^x@n]_n]}/

Try it online!
Input is taken as a list of pairs; user names are symbols (rather than strings).

(0#`!0){...}/ set up a reduce, seeded with an empty dictionary (mapping symbols to integers) that tracks the active usernames and their respective reputation scores
{(n;a):y;...} destructure the next pair into its name and action
$[`i~@a;...;...] check whether or not the action is an integer (representing a reputation change) or not
if the action was a reputation adjustment...

@[x;n;+;a] add the reputation change to that user (if this is the first time the username appears, use 0 as the fill element)

if the action was a username change...

@[x;a;:;0^x@n] carry over the reputation from the previous name to the new name (if the prior name didn't have any reputation or name changes yet, set its reputation to 0)
..._n delete the old user name from our reputation tracker

once done handling the reputation/name changes...

{(>x)!x@>x} sort the users by their reputation, descending (outputting both the username and their "final" reputation)

Pip -rS, 71 53 bytes
{IaNI@ZllPB[a0](lY@Zl@?a1)+:bI+bNEb(ly0):b}MUg^sRVSNl

Try it online!
I'm gonna golf this some more before writing a thorough explanation. The basic idea:

Keep a list of [name score] pairs in l
Loop through the lines of input, split on spaces, using MU (for each line, the first item is a and the second item is b):

If a is not one of the names in l, append [a 0] to l
Add b to the score in l associated with the name a (if b is a name, this adds 0*)
If b is not a number, change the name a in l to b

Once the loop is done, sort l in descending numerical order (since all the names are 0 in numeric context*, this sorts by the scores)

* Assuming that no names start with a digit, which I argue is the best Pip-specific interpretation of "whatever the input is, it won't be able to be parsed as a number."

JavaScript (Node.js), 118 bytes
a=>a.flatMap(v=>([p,q]=v,u=a[p])?(q+-q?a[a[u[0]=q]=u,p]=0:u[1]+=q,[]):[q+-q?a[q]=[q,0]:a[p]=v]).sort((a,b)=>b[1]-a[1])

Try it online!
Expect input ([string, string]|[string, number])[] type.
q+-q is used to test whether q is a number or string. if q is number, q+-q will be falsy. If q is string, q+-q will be truthy.

@Arnauld That won't work for string 0x1, so I had changed to something just testing number type vs. string type.

Oh, I see. My bad. You should however fix your code in the footer so that it really works, e.g. for 1e4 instead of Alice in the 1st test case.

Haskell, 253 bytes
import Text.Read
import Data.List
m l(k,d)=maybe((d,o):n)(\a->(k,a+o):n)(readMaybe d)where o=maybe 0id(lookup k l);n=filter(\(x,_)->x/=k)l
f v=sortBy(\(_,x)(_,y)->compare y x)$filter(\(x,y)->maybe("",0)id(find(\(a,_)->a==x)r)==(x,y))r where r=foldl m[]v

The function takes a list of String pairs  and returns a list of (String, Int) pairs
Full programme, 355 bytes
module Main where
import Text.Read
import Data.List
m l[k,d]=maybe((d,o):n)(\a->(k,a+o):n)(readMaybe d)where o=maybe 0id(lookup k l);n=filter(\(x,_)->x/=k)l
main=getContents>>= \c->let r=foldl m[]$map words$lines c in putStr$unlines$map(\(x,y)->unwords[x,show y])$sortBy(\(_,x)(_,y)->compare y x)$filter(\(x,y)->maybe("",0)id(find(\(a,_)->a==x)r)==(x,y))r

The programme takes input as specified in the testcases via STDIN
Try it online!

A couple of tricks can make this a bit shorter

05AB1E, 48 bytes
¯svÐ˜y`Uk;©di®èX.ïi`X+‚ëy`:}®ǝëX.ïiyëX¾‚}ª]Σθï}R

Input as a list of pairs.
Try it online or verify all test cases.
Explanation:
¯                # Start with an empty list: []
 sv              # Loop over each input-pair `y`
   Ð             #  Triplicate the current list
    ˜            #  Flatten it
     y`          #  Push the key and value of the current item `y` separated to the stack
       U         #  Pop the value, and store it in variable `X`
       k         #  Get the index of the key in the flattened list
        ;©       #  Halve it, and store it in variable `®` (without popping)
    di           #  If this index/2 is non-negative (>= 0):
      ®è         #   Get the `®`'th pair from the current list
        X.ïi     #   If `X` is an integer:
            `    #    Push the key and value of the indexed pair separated to the stack
             X+  #    Add `X` to the value
               ‚ #    And pair the key and this new value back together
           ë     #   Else (it's a rename):
            y`   #    Push the key and value of the current item `y` separated to the stack
              :  #    And replace key with value in the indexed pair
           }     #   After the if-else:
            ®ǝ   #   Insert this modified pair at index `®` back into the list
     ë           #  Else (the current key doesn't exist yet):
      X.ïi       #   If `X` is an integer:
          y      #    Simply use the current item `y`
         ë       #   Else:
          X¾‚    #    Pair `X` with 0
         }       #   After the if-else:
          ª      #   Append this new pair to the list
  ]              # After the loop:
   Σ  }          # Sort the resulting list in ascending order by:
    θ            #  The last item of each pair (the values)
     ï           #  Casted to an integer (because the `:` might have made it a string)
       R         # And then reverse this sorted list to make it descending
                 # (after which it is output implicitly as result)

AWK (with shell callout to "sort"), 105 bytes
b=$1,d=$2{g=f[b]=d+0==d;f[d]=!g;g?m[b]+=d:m[d]=0+m[b]}END{for(n in m)if(f[n])print n" "m[n]|"sort -k2rn"}

Try it online!
This one builds two arrays, one with the score for a give name, and one that's a boolean flag indicating if a name is active or not.  At the end, the code prints the reputation scores for all the active accounts and pipes those lines to a sort call.  Sorting things in AWK is a nightmare...
Here's a description of the components.
b=$1,d=$2{                                              }

This test/code-block runs for each input line.  The b=$1 and d=$2 are just a shortcuts for positional variables used repeatedly in the code.  The first one is always truthy, so the code block runs even if the reputation is 0.
g=f[b]=d+0==d;

The first expression sets the "is an active account" flag (the f[] array) to true or false depending on whether or not the second token on the input line is a number.  The test d+0==d catches that since AWK converts a non-numeric string to 0 if you try an use it as an integer in a mathematical expression.  And g is set just to shorten the code when f[b] is needed later.
f[d]=!g;

The "is an active account" flag for the second token is the opposite of the value computed for the first token.  That will set some garbage entries for input lines that have a numeric reputation as the second token, but they will be ignored.
g?m[b]+=d:m[d]=0+m[b]

This ternary sets increments the reputation counter (the m[] array) for the first token if we got a numeric second token.  Otherwise it sets the reputation token for the second token to the reputation token of the first token.  In other words, it copies the reputation to the new name.
END{for(n in m)if(f[n])print n" "m[n]|"sort -k2rn"}

Once all the input lines have been handles, the code loops through all the names in the reputation array m[] and for any that are active users per the f[] array, it prints the name and final reputation.  The sort -k2rn command sorts the whole set and prints the output.

AWK, 132 bytes
/.* -?[0-9]/{a[$1]+=$2}
!/.* -?[0-9]/{a[$2]=a[$1]+0;delete a[$1]}
END{PROCINFO["sorted_in"]="@val_num_desc";for(k in a)print k,a[k]}

Try it online!
We're careful to +0 to make sure the new name has reputation.
The hardest part of this problem is printing the list out sorted by values. Thankfully, GNU Awk has an array called PROCINFO, and by writing the special value "@val_num_desc", the array will be numerically sorted in descending order by value.

Perl 5 -a, 114 bytes
$_=pop@F;/^-?\d+$/?$k{$F[0]}+=$_:($k{$_}=$k{$F[0]}+0,delete$k{$F[0]})}{say"$_ $k{$_}"for sort{$k{$b}-$k{$a}}keys%k

Try it online!

Java 10, 166 251 bytes
import java.util.*;a->{var r=new HashMap<String,Long>();for(var l:a)if(l[1].matches("-?\\d+"))r.merge(l[0],new Long(l[1]),Long::sum);else{var t=r.remove(l[0]);r.put(l[1],t==null?0:t);}return r.entrySet().stream().sorted(Map.Entry.comparingByValue());}

+85 bytes because I hadn't noticed the output should be sorted by value.. >.>
Input as a 2D list of Strings, output as a sorted stream of key-value pairs.
Try it online.
Explanation:
import java.util.*;            // Required import for Map and HashMap
a->{                           // Method with 2D String-array as parameter
                               //  and a Stream of String-Long KeyValue-pairs as return-type
  var r=new HashMap<String,Long>();
                               //  Map, starting empty
  for(var l:a)                 //  Loop over the lines of the input:
    if(l[1].matches("-?\\d+")) //   If the second part is an integer:
      r.merge(l[0],            //    Use the first part as key
              new Long(l[1]),  //    Convert the second part to an integer
              Long::sum);      //    And sum it with a potential existing value for this key
    else{                      //   Else (it's a rename):
      var t=r.remove(l[0]);    //    Remove the first part from the map;
                               //    store the current value (of null if not present) in `t`
      r.put(l[1],              //    Use the second part as new key
            r.remove(l[0]));   //    And remove the first part from the map,
                               //    which will return the current value
                               //    (or null if not present)
  return r                     //  Return the Map as result
    .entrySet().stream()       //  after we've converted it to a steam of KeyValue pairs,
    .sorted(Map.Entry.comparingByValue());}
                               //  and sorted it by value


text:
Play the card game "Set"
"Set" is a card game played with a deck of 81 cards, twelve of which are pictured below:

Each card has four attributes, each of which may assume three values:

Number: the number of symbols, either 1, 2, or 3
Shape: the shape of the symbol, either squiggle, diamond or oval
Colour: either purple, red or green
Shading: symbols may be solid, half-shaded or empty.

Each of the 3^4 = 81 possible combinations of these attributes appears on exactly one card in the deck.
Cards can be specified via a four-character string where one character specifies each attribute: "1", "2", or "3" for number; "s", "d", or "o" for squiggle, diamond or oval; "p", "r" or "g" for colour, and "s", "h" or "e" for solid, half or empty shading.
In this notation, the top row above is "3sph", "2dre" and "1ops".
Given a collection of twelve such cards, the object of the game is to be the first player to identify a subset containing three cards such that, for each of their four attributes, either:

each card has a different value for that attribute, or
all cards have the same value for that attribute.

To quote Wikipedia: 'The rules of Set are summarized by: If you can sort a group of three cards into "two of ____ and one of ____", then it is not a set.'
In the image above, an example of a valid set would be the first, second and seventh cards ("3sph", "2dre" and "1ogs"). There are five other valid sets in this image.
Challenge
Take as input a list of twelve cards. They may be specified in the four-character notation described above, or you may invent your own.
Output a list of all valid three-card sets therein.

Although the input here is less of a mess, it's pretty much the same challenge.

Although considering the old challenge's various flaws, and how long it's been inactive, we may want to keep this one... relevant Meta discussion

Maybe one could increase the scope of the challenge to make it something new, like giving a list of sets which removes as many cards from the 12 given as possible.