text:
Machine Learning Golf: Multiplication
I'd like to propose a different kind of golfing challenge to this community:
(Artificial) Neural Networks are very popular machine learning models that can be designed and trained to approximate any given (usually unknown) function. They're often used to solve highly complex problems that we don't know how to solve algorithmically like speech recognition, certain kinds of image classifications, various tasks in autonomous driving systems, ... For a primer on neural networks, consider this excellent Wikipedia article.
As this is the first in what I hope to be a series of machine learning golf challenges, I'd like to keep things as simple as possible:
In the language and framework of your choice, design and train a neural network that, given \$(x_1, x_2)\$ calculates their product \$x_1 \cdot x_2\$ for all integers \$x_1, x_2\$ between (and including) \$-10\$ and \$10\$.
Performance Goal
To qualify, your model may not deviate by more than \$0.5\$ from the correct result on any of those entries.
Rules
Your model

must be a 'traditional' neural network (a node's value is calculated as a weighted linear combination of some of the nodes in a previous layer followed by an activation function),
may only use the following standard activation functions:

\$\textrm{linear}(x) = x\$,
\$\textrm{softmax}(\vec{x})_i = \frac{e^{x_i}}{\sum_j e^{x_j}}\$,
\$\textrm{selu}_{\alpha, \beta}(x) = \begin{cases}
\beta \cdot x & \text{, if } x > 0 \\
\alpha \cdot \beta (e^x -1 ) & \text{, otherwise}
\end{cases}\$,
\$\textrm{softplus}(x) = \ln(e^x+1)\$,
\$\textrm{leaky-relu}_\alpha(x) = \begin{cases}
x & \text{, if } x < 0 \\
\alpha \cdot x & \text{, otherwise}
\end{cases}\$,
\$\tanh(x)\$,
\$\textrm{sigmoid}(x) = \frac{e^x}{e^x+1}\$,
\$\textrm{hard-sigmoid}(x) = \begin{cases}
0 & \text{, if } x < -2.5 \\
1 & \text{, if } x > 2.5 \\
0.2 \cdot x + 0.5 & \text{, otherwise}
\end{cases}\$,
\$e^x\$

must take \$(x_1, x_2)\$ either as a tupel/vector/list/... of integers or floats as its only input,
return the answer as an integer, float (or a suitable container, e.g. a vector or list, that contains this answer).

Your answer must include (or link to) all code necessary to check your results -- including the trained weights of your model.
Scoring
The neural network with the smallest number of weights (including bias weights) wins.
Enjoy!

My personal best, which I'll submit later, uses 43 weights and I'm sure there's plenty of room for improvements.

Welcome to the site!  I think this challenge could benefit a good deal from a more robust definition of a neural network.  There are a couple of things here 1) It would be very nice for you to state it in language that does not already imply knowledge of NNs 2) You really should list the activation functions in your post rather than link out to an external source (outside links can change or disappear).

@SriotchilismO'Zaic I will add the activation functions but I don't think I want to include a definition of a neural network. I'm confident that my post contains enough information for people who are familiar with neural networks and for people who don't, this isn't the right place to learn about them.

Can we have constant offsets? e.g., for a node with a single input x, compute its value as ax+b? And if yes, does that count as 1 or 2 weights?

@Grimy I'd be fine with that. However, they must be counted as two weights as otherwise this would allow for some shenanigans (e.g. in my code, it would reduce the weights to 33).

Can we reuse weights/use convolutional layers? (I recommend removing the bonus, as it doesn't add anything to the challenge and just distracts from the main goal.) Are the weights supposed to be real or can they be complex?

Your wording implies nodes from layer 3 can't use inputs from layer 1. Does it cost a weight to have a layer 2 node simply doing f(x) = x to forward its input?

@flawr CNNs are allowed. Basically any forward propagation that is a chain of 'weighted sum of previous nodes followed by activation function' is permissible. In particular, you may also include RNN layers. The rules are meant to encourage experimentation while protecting this challenge from becoming trivialized (e.g. using a neural network that solves this problem as activation function or data preprocessing that simplifies the task).

@Grimy You're correct. My wording doesn't correctly reflect my intentions. I'll edit that. Skipping layers is allowed and if you do so with one of the listed activation functions, it doesn't cost you any weights.

How many  weights does a mapping like $x \mapsto (x,x,x)$ count as?

@flawr That's zero weights. You may reroute/duplicate your states as you wish. So, you may also have a map like $(x,y) \mapsto (x,y,y,x,y)$ for free. (I sure hope this doesn't break the game in some way I don't immediately foresee ;-))

Should we counts weights that are equal to 1? For example, would a node doing output = tanh(input) (or some other standard activation function) count as 0 or 1 weight?

@mbomb007 Sure, I'll add that.

Like Grimy, I'm also unclear whether a weight that's equal to 1 counts as a weight for scoring. How much does it cost to do z = x + y to get the sum of the two inputs?

@xnor That should count as 2 weights as this is equivalent to a dense layer with 2 inputs, one output without bias. Admittedly, this is awkward and certainly shows there a problems with the current set of rules. However, two points: 1. This is my first attempt at coming up with a machine learning golf challenge, so these kinds of problems are to be expected. 2. Because I've deliberately chosen a problem that has a trivial algorithmic solution, these quirks of the rules, unfortunately, are more problematic than they would be in an actual machine learning problem. Sorry about that!

If people are interested in machine learning golf (which I really hope they are), I'm confident we'll flash out these issues in no time and end up with a semi-standard set of rules similar to those for more traditional golfing challenges.

If we are reusing the same weights, do we have to count them each time or can we just count them once?

@flawr I've thought about that and I think reusing them is fine. It will have a significant impact on this particular challenge but it overall better captures what I intend to measure (model complexity) and it will allow for more creative solutions in this and future challenges. So, yes: Feel free to reuse your weights to improve your score!

Is there any particular reason you don't have y=ln(x) in your list of activation functions?

@FirefoxMetzger Yes, there is. And I'm glad you asked: $a \cdot b = e^{\ln(a \cdot b)} = e^{\ln(a) + \ln(b)}$

@StefanMesken I am aware that this would become a solution (in this case 1 neuron would be the anwer). I'm curious about the logic behind making exp(.) part of the 'standard activation functions', but not it's inverse.

@FirefoxMetzger $\exp$ is a total function which makes it more suitable as an activation function. Since I wanted to pick one and only one, $\exp$ seemed like the better choice.

IMO this fails to reach the required level of clarity on at least two counts: firstly, it's very vague what the criteria are for an answer to be valid (contrast https://codegolf.stackexchange.com/q/183036/194 , which took a lot of work to polish up to the required standard); and secondly, it's too vague about the scoring (see the same earlier question as an example of how to be clear enough).

@PeterTaylor I'm not sure that I fully agree with that criticism but I'm certainly willing to improve this post. In fact, I think these first attempts should be viewed as a trial run that guide the development of a better setup. (I don't imagine that the first challenges posted on code golf se were up to the current standards either and I'm making them up for ML golf as we speak. However, doing so without participants that bring up issues seems doomed which is why I plead for keeping this post open.)

There should be a link in the right column to the Sandbox, which was created expressly to fix these kind of issues before the question is even posted to the main site. And the network philosophy is that it's better to close a question, fix it, and reopen it than to get a bunch of answers which either will make no sense after the question is fixed or will tightly constrain the changes which can be made to the question.

@PeterTaylor 'These kinds of issues' are detected by participation -- not by looking at some preliminary version in a vacuum. Before I ever considered posting this challenge, I've spent a week worth of afternoons doing trial runs and coming up with ways to cheat the system and how to defend against that. We are walking a thin line here: Creating rules restrictive enough to make the challenge meaningful while allowing as much freedom as possible to make it accessible to a wide audience. Strongly disagree with that last comment.

Not at all. These kinds of issues are detected by many years' experience of seeing other people make the same kind of mistakes. Some ambiguities slip past the sandbox, but many more are caught there. And this would definitely have been caught, because as indicated in my first comment we had exactly the same problems with a neural net question two months ago.

Typo in the hard sigmoid function: should be 1 if x > 2.5, not -2.5.

Am I allowed to use gating (like in LSTM) and self-gating?

@CrabMan Only if you can realize them as a combination of weighted sums followed by one of the allowed activation functions. (Doing is naively would require a lot of weights... But maybe you can do it efficiently.)

From review queue, this question is not unclear. Just because the math and concepts are complicated and you don't understand them (I don't either) doesn't mean the question is not specific or clear.

@StefanMesken: Thank you for asking this question and resisting defining "neural network", as well as disagreeing with other parts of the "network philosophy".  I asked the first neural network question a couple months before you: https://codegolf.stackexchange.com/q/183036/ .  It received a lot of pushback from the community and was in fact closed. It was mentioned above that it took "a lot of work to polish up to the required standard", but in fact I believe that work I did was worthless. Good luck with further questions.

If linear activations are legal, then you can reduce every solution (up to machine precision) to another solution that has only two distinct weights. Indeed, every neural net whose weights are integer multiples of 10^(-2k) can be simulated with a much larger neural net whose weights are plus or minus 10^(-k). To see this, observe that multiplication by any such weight w can be implemented as w.x = sgn(w).v^T.v.x, where v is the column vector consisting of 10^(2k).abs(w) entries, each entry equaling 10^(-k).

21 13 11 9 weights
This is based on the polarization identity of bilinear forms which in the one dimensional real case reduces to the polynomial identity:
$$ x\cdot y = \frac{(x+y)^2 - (x-y)^2}{4}$$
So y1 just computes [x+y, x-y] using a linear transformation, and y3 is just the absolute value of y1 as a preprocessing step for the next one: Then the "hard" part is computing the squares which I will explain below, and after that just computing a difference and scaling which is again a linear operation.
To compute the squares I use an exponential series \$s\$ which should be accurate for all integers \$\{0,1,2,\ldots,20\}\$ within around \$0.5\$. This series is of the form
$$ \text{approx_square}(x) = \sum_{i=0}^2 w_i \exp(0.0001 \cdot i \cdot x)$$
where I just optimized for the weights W2 (\$=(w_i)_i\$). This whole approximation comprises again just two linear transformations with an exponential activation sandwiched in between. This approach results in a maximal deviation of about 0.02.
function p = net(x)
% 9 weights
one = 1;
mone =-1;
zero = 0;
fourth = 0.25;
W1 = [1e-4, 2e-4];
W2  = [-199400468.100687;99700353.6313757];
b2 = 99700114.4299316;
leaky_relu = @(a,x)max(a*x,x);

% Linear
y0 = [one, one; one, mone] * x;

% Linear + ReLU
y1 = mone * y0;
y2 = [leaky_relu(zero, y0), leaky_relu(zero, y1)];

% Linear
y3 = y2 * [one; one];

% Linear + exp
y4 = exp(y3 * W1);

% Linear + Bias
y5 =  y4 * W2 + b2;

% Linear
y6 = [one, mone]*y5;
p = y6 * fourth;

end

Try it online!

I think your checking code in the footer of the TIO link misses an application of abs. But everything is fine anyway.

@ChristianSievers Thanks, I updated the TIO link!

I'm not an expert on NN, out of curiosity, how is the weight count done? y0 needs 4, y1 needs 2, y3 needs 2, y4 needs 1, y5 needs 1 and y6 needs 2. That's 12?

@MargaretBloom Yes this is indeed a little bit unusual, but the OP said in the comments that we can reuse weights and only ever have to count them once, even if we use the same weight multiple times. So all the weights I'm using are defined in the first part of the function.

7 weights
eps = 1e-6
c = 1 / (2 * eps * eps)

def f(A, B):
	e_s = exp(eps * A + eps * B)  # 2 weights, exp activation
	e_d = exp(eps * A - eps * B)  # 2 weights, exp activation
	return c * e_s + (-c) * e_d + (-1 / eps) * B  # 3 weights, linear activation

Try it online!
Uses the following approximate equality for small \$\epsilon\$ based on the Taylor expansion \$ e^x \approx 1 + x + \frac{x^2}{2}\$:
$$ AB \approx \frac{e^{\epsilon A+\epsilon B} - e^{\epsilon A-\epsilon B}}{2 \epsilon^2} - \frac{B}{\epsilon} $$
Picking \$\epsilon\$ small enough gets us within the required error bounds. Note that eps and c are constant weights in the code.

Not sure that this counts as a 'traditional neural network' (rule #1) but it's obvious that it can be reformatted into one, so I see no issue with that. Nice solution!

You could define C = -B (1 weight) and then have [e_s, e_d] = conv([A,B,C], [eps, eps]) (2 weights) to save one weight:) (BTW: Very clever approach!)

(I forgot to add the exp)

You can even get a lot lower by reusing the weights - you don't have to count the same weight multiple times.

@flawr That's a nice trick, but I think the allowances for convolution and reusing weights in the comments make this so much a different challenge that I'm going to keep this answer as is.

33 31 weights
# Activation functions
sub hard { $_[0] < -2.5 ? 0 : $_[0] > 2.5 ? 1 : 0.2 * $_[0] + 0.5 }
sub linear { $_[0] }

# Layer 0
sub inputA() { $a }
sub inputB() { $b }

# Layer 1
sub a15() { hard(5*inputA) }

# Layer 2
sub a8()  { hard(-5*inputA + 75*a15 - 37.5) }

# Layer 3
sub aa()  { linear(-5*inputA + 75*a15 - 40*a8) }

# Layer 4
sub a4()  { hard(aa - 17.5) }

# Layer 5
sub a2()  { hard(aa - 20*a4 - 7.5) }

# Layer 6
sub a1()  { linear(0.2*aa - 4*a4 - 2*a2) }

# Layer 7
sub b15() { hard(0.25*inputB - 5*a15) }
sub b8()  { hard(0.25*inputB - 5*a8) }
sub b4()  { hard(0.25*inputB - 5*a4) }
sub b2()  { hard(0.25*inputB - 5*a2) }
sub b1()  { hard(0.25*inputB - 5*a1) }

# Layer 8
sub output() { linear(-300*b15 + 160*b8 + 80*b4 + 40*b2 + 20*b1 - 10*inputA) }

# Test
for $a (-10..10) {
        for $b (-10..10) {
                die if abs($a * $b - output) >= 0.5;
        }
}

print "All OK";

Try it online!
This does long multiplication in (sorta) binary, and thus returns the exact result. It should be possible to take advantage of the 0.5 error window to golf this some more, but I'm not sure how.
Layers 1 to 6 decompose the first input in 5 "bits". For golfing reasons, we don't use actual binary. The most significant "bit" has weight -15 instead of 16, and when the input is 0, all the "bits" are 0.5 (which still works out fine, since it preserves the identity inputA = -15*a15 + 8*a8 + 4*a4 + 2*a2 + 1*a1).

I did expect someone to come up with a hard-coded, ANN-ified multiplication algorithm. But I didn't think it would be the first response. Well done! (I'm also eager to see whether you'll be able to pull something like this off with the MNIST dataset or some other, more relastic ML problem :D.)

43 weights
The two solutions posted so far have been very clever but their approaches likely won't work for more traditional tasks in machine learning (like OCR). Hence I'd like to submit a 'generic' (no clever tricks) solution to this task that hopefully inspires other people to improve on it and get sucked into the world of machine learning:
My model is a very simple neural network with 2 hidden layers built in TensorFlow 2.0 (but any other framework would work as well):
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(6, activation='tanh', input_shape=(2,)),
tf.keras.layers.Dense(3, activation='tanh'),
tf.keras.layers.Dense(1, activation='linear')
])

As you can see, all layers are dense (which most certainly isn't optimal), the activation function is tanh (which might actually be okay for this task), except for the output layer that, due to the nature of this task, has a linear activation function.
There are 43 weights:

\$(2+1) \cdot 6 = 18\$ between the input and first hidden layer,
\$(6+1) \cdot 3 = 21\$ between the hidden layers and
\$(3+1) \cdot 1 = 4\$ connecting the last hidden and the output layer.

The weights have been trained (with an adam optimizer) by a layered fitting approach: First they've been fitted to minimize the mean squarred error not only on integer multiplication between \$-10\$ and \$10\$ but actually on inputs in a certain neighborhood around these values. This results in much better convergence due to the nature of gradient descent. And it accounted for 400 epochs worth of training on 57,600 training samples each, using a batch size of 32.
Next, I've fine-tuned them -- optimizing for the maximum deviation on any of the integer multiplication tasks. Unfortunately, my notes don't show much fine tuning I ended up doing, but it was very minor. In the neighborhood of 100 epochs on those 441 training samples, with a batch size of 441.
These are the weights I ended up with:
[<tf.Variable 'dense/kernel:0' shape=(2, 6) dtype=float32, numpy=
 array([[ 0.10697944,  0.05394982,  0.05479664, -0.04538541,  0.05369904,
         -0.0728976 ],
        [ 0.10571832,  0.05576797, -0.04670485, -0.04466859, -0.05855528,
         -0.07390639]], dtype=float32)>,
 <tf.Variable 'dense/bias:0' shape=(6,) dtype=float32, numpy=
 array([-3.4242163, -0.8875816, -1.7694025, -1.9409281,  1.7825342,
         1.1364107], dtype=float32)>,
 <tf.Variable 'dense_1/kernel:0' shape=(6, 3) dtype=float32, numpy=
 array([[-3.0665843 ,  0.64912266,  3.7107112 ],
        [ 0.4914808 ,  2.1569328 ,  0.65417236],
        [ 3.461693  ,  1.2072319 , -4.181983  ],
        [-2.8746269 , -4.9959164 ,  4.505049  ],
        [-2.920127  , -0.0665407 ,  4.1409926 ],
        [ 1.3777553 , -3.3750365 , -0.10507642]], dtype=float32)>,
 <tf.Variable 'dense_1/bias:0' shape=(3,) dtype=float32, numpy=array([-1.376577  ,  2.8885336 ,  0.19852689], dtype=float32)>,
 <tf.Variable 'dense_2/kernel:0' shape=(3, 1) dtype=float32, numpy=
 array([[-78.7569  ],
        [-23.602606],
        [ 84.29587 ]], dtype=float32)>,
 <tf.Variable 'dense_2/bias:0' shape=(1,) dtype=float32, numpy=array([8.521169], dtype=float32)>]

which barely met the stated performance goal. The maximal deviation ended up being \$0.44350433\$ as witnessd by \$9 \cdot 10 = 90.443504\$.
My model can be found here and you can also Try it online! in a Google Colab environment.

2 weights
I was inspired by the other answers to approximate the polarization identity in a different way. For every small \$\epsilon>0\$, it holds that
$$ xy \approx \frac{e^{\epsilon x+\epsilon y}+e^{-\epsilon x-\epsilon y}-e^{\epsilon x-\epsilon y}-e^{-\epsilon x+\epsilon y}}{4\epsilon^2}.$$
It suffices to take \$\epsilon=0.01\$ for this challenge.
The obvious neural net implementation of this approximation takes weights in \$\{\pm\epsilon,\pm(4\epsilon^2)^{-1}\}\$. These four weights can be golfed down to three \$\{\pm\epsilon,(4\epsilon^3)^{-1}\}\$ by factoring \$\pm(4\epsilon^2)^{-1}=\pm\epsilon\cdot(4\epsilon^3)^{-1}\$. As I mentioned in a comment above, every neural net with weights in machine precision can be golfed to a (huge!) neural net with only two distinct weights. I applied this procedure to write the following MATLAB code:
function z=approxmultgolfed(x,y)

w1 = 0.1;   % first weight
w2 = -w1;   % second weight

k  = 250000;
v1 = w1*ones(k,1);
v2 = w2*ones(k,1);

L1 = w1*eye(2);
L2 = [ w1 w1; w2 w2; w1 w2; w2 w1 ];
L3 = [ v1 v1 v2 v2 ];
L4 = v1';

z = L4 * L3 * exp( L2 * L1 * [ x; y ] );

All told, this neural net consists of 1,250,010 weights, all of which reside in \$\{\pm0.1\}\$.
How to get away with just 1 weight (!)
It turns out you can simulate any neural net that has weights in \$\{\pm0.1\}\$ with a larger neural net that has only one weight, namely, \$-0.1\$. Indeed, multiplication by \$0.1\$ can be implemented as
$$ 0.1x = w^\top wx, $$
where \$w\$ is the column vector of \$10\$ entries, all equal to \$-0.1\$. For neural nets in which half of the weights are positive, this transformation produces a neural net that is \$10.5\$ times larger.
The obvious generalization of this procedure will transform any neural net with weights in \$\{\pm 10^{-k}\}\$ into a larger neural net with the single weight \$-10^{-k}\$. Combined with the procedure in my comment above, it therefore holds that every neural net with machine-precision weights can be transformed into a single-weight neural net.
(Perhaps we should modify how re-used weights are scored in future neural net golfing challenges.)


text:
Report divisibility with arithmetic integer operations only
Given two numbers, the first is greater than the second, check whether the first number is divisible by the second without a remainder. If divisible, answer "yes"(or any other string), otherwise "no"(or any other string you like).
Conditions: You cannot use conditional operators, loops, arrays, bitwise operations, functions and methods. You can use variables, all arithmetic integer operations (that is, integer division), even the operation of taking the remainder of a division.
Numbers can range from 1 to 1,000,000. Maximum running time is 1 second.
You can of course write in any language, but here is my non-golfed solution in C++:

int main() {
  int a,b; cin >> a >> b;
  int c = a%b;
  int n = (c+1-(c-1)((2(c-1)+1)%2))/2;
  int y = 121, e = 101, s = 115;

  cout << (char)(y-11*n) << (char)(e+10*n) << (char)(s-83*n) << endl;
}

"you can not use conditional operators, cycles, bitwise operations, functions and methods" I assume this includes builtins to check if b can divide a? And how about array/list indexing? Could I use (in pseudo-code): list = ["no","yes"]; int isDivisible = b can_divide_evenly a; print(list[isDivisible]);?

@KevinCruijssen no arrays

Welcome to Code Golf! Especially for a new user, do not post "Do X without Y" questions. Also, why are you restricting the output to "yes" and "no"? Thanks!

@MilkyWay90 Cause it is strings, it may be any other strings, so just for example.

@Mouvre You should probably explicitly state that in your question

So for a language where each byte is an instruction, which part is the "conditional"? The part that coerces the boolean, or the part that consumes the boolean? E.g. for this program which part violates the restriction: the = (check equality: push 0 or 1), the ? (skip n instructions), both (i.e. both commands are individually invalid), or the combination of both in sequence (i.e. invalid only if both are used)? What about commands that act differently based on the value of the top-of-stack (e.g. the J command)?

Aren't all unary or higher operators conditional, since their behaviour changes based on the value on which they are acting.

@ExpiredData I don't know about "all" but certainly a lot. (e.g. does x++ operate "differently" depending on the value of x? Certainly Math.sign(x) does, no argument there).

Well x++ is effectively the binary + between x and 1, and it's result is conditional on x, I.e imagine a program which took x and returned x+1, it can conceivably be programmed as a set of n bit if statements where n is the number of bits in your representation of x, or a countable infinity of if statements if the size of x is unbounded @draco18s

@ExpiredData Ah, I suppose you have a point there.

Welcome to the site. We really do recommend the sandbox for new challenges especially for new members. It saves you from getting too many downvotes for a question that could have been improved without downvotes harming your rep :-)

05AB1E, 1 byte
Ö

Try it online!
Outputs 1 if divsible 0 if not

Old version with string must be Yes or No
05AB1E, 13 12 10 bytes
Ö'…Ü„nor.D

Ö              // Test to see if they are divisible
 '…Ü           // The string yes
     „no      // the string no
         r     // reverse the stack
          .D   // push whether they are divisible copies of "yes"
               // Implicitly output the result

Try it online!

“…Ü“ can be '…Ü for -1 and "no" can be „no for -1.

Pretty pointless to ban all those things but not builtins.. >.> Anyway, my first comment is also a tip for future challenges. :) '„… are all three builtins for 1, 2, or 3-char string builtins, or 1, 2, or 3 word dictionary strings. More info can be found in this first section here.

@KevinCruijssen thanks, I was trying to use that for reference but sometimes it's hard to pick things out! and yeah well this is a terrible challenge anyway, I think it should probably be closed.

Yeah, my tip answer is a bit large these days, because more was added in the process.. And you learn as you go along with it. Even now I sometimes come across builtins which are barely used and I didn't even knew were there.. PS: If you ever have any questions, feel free to ask any of us in the 05AB1E chat.

JavaScript (ES6), 17 bytes
Takes input as (a)(b). Returns "Y" for yes or "undefined" (as a string) for no.
a=>b=>"Y"[a%b]+''

Try it online!

JavaScript (ES6), 50 bytes
Takes input as (a)(b). Returns "yes" or "no", as per the original rules.
a=>b=>(22724-21872*((2*(a%b-1)+1)%2)).toString(36)

Try it online!

APL (Dyalog Unicode), 17 3 bytesSBCS
Anonymous tacit infix function. Takes lesser and greater numbers as left and right arguments. Prints the string "0" if divisible and "1" if not.
1⌊|

Try it online!
| division remainder when dividing right argument by left argument (gives 0 for divisible or strictly positive integer for non-divisible)
1⌊ the minimum of that and 1 (gives 0 for divisible or 1 for non-divisible)

Of course, this depends on if = is considered the "conditional" in the challenge specification, or whether the if(...) part is.

@Draco18s Good point. Fixed.

Runic Enchantments, 6 bytes
0ii%p@

Try it online!
Outputs 1 if divisible 0 if not.
Determines 0/1-ness by raising 0 to the power of the remainder, which returns 0 for all x except 0 (due to the indeterminate nature of 00 having been decided to be 1).
Version with string output
Runic Enchantments, 20 bytes
10ii%p-4´36*6X+d-E@

Try it online!
Utilizes the word dictionary to convert from a 0/1 value to the strings "yes" and "no" by multiplying the result by 436 and adding 47 (ok, it adds 60 and subtracts 13; the byte cost is ironically the same either way: 4X7++ vs. 6X+d- vs. 4´7+).
May be invalid due to using an array? There is certainly no array in the submission code but rather in the the interpreter due to how E is executed when the top of the stack is not a string.

Befunge-98 (FBBI), 6 bytes
%1\k0.

Arguments should be pushed onto the stack, and requires the current IP delta to be (1,0). Prints 1  if divisible and 0  if not.
Try it online!
Link includes I/O boilerplate.

source: Stack Exchange

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

sort: votes


text:
Will Jimmy fall off his platform?
Backstory
Meet my friend Jimmy:
/o\

Jimmy is a little character who likes to stand on platforms. Here's Jimmy safely standing on a platform:
         /o\
  -------------

Now, Jimmy has a good sense of balance, so he can safely stand with one leg off of the platform, like so:
   /o\
    -------------------

Although if he stands with two or more body parts off of the platform, he will fall. Both of these are examples where Jimmy will fall:
/o\                                       /o\
  ----------        ----------------------

The challenge
Your challenge is to write a program to determine, given a string with Jimmy's platform and position, if Jimmy can stand on the platform without falling off.

Input: Two lines showing Jimmy's position and the position of the platform under him. This can be from two separate inputs, a single input, or an array of some sort.

You may take input through any reasonable form, includings functions and standard input. Only resort to hard-coding if your language does not support the other input methods.

Output: The boolean values true and false, or the integers 1 or 0 to represent true/false respectively.

The boolean value is based off of whether Jimmy can stay on the platform or not - true if Jimmy can stay on the platform, or false if he will fall off.

The platform size is arbitrary and can be changed at will. Your program should account for that.

The platform cannot be a length of zero, and the platform must be complete (no holes in the platform).

Remember that Jimmy falls off when two of his body parts are hanging off the platform. A body part is one ASCII character of his body.

Trailing whitespace at the end of the platform is not required, but your program should account for both situations, where there is whitespace after the platform and where there is not.

Be mindful of the standard loopholes that are forbidden.

Test cases
         /o\               ✔ TRUE
  -------------

/o\                        ✔ TRUE
 ----------

                    /o\    ❌ FALSE
  ------------------

               /o\         ❌ FALSE
  -------

    /o\                    ❌ FALSE
     -

Scoring
This is code-golf, so lowest byte count wins.

Can we assume trailing whitespace after Jimmy? Also if you’re allowing arrays of characters, in some languages those will have to be padded with whitespace.

@NickKennedy You need to account for trailing whitespace or no trailing whitespace. I didn't set strict rules on that.

What if the input is taken as a matrix which has to be rectangular? Is that just not an accepted input method?

@dzaima That is accepted, since you literally cannot make it anything but rectangular. I'm fine with that.

Title is "will jimmy fall of the platform" and you required to output "will jimmy stay on the platform". Is this expected behavior?

When you say we have to account for trailing whitespace or not past the end of the platform, do you mean any amount of trailing whitespace, or enough to pad it to the length of the other line, or something else?

Can you reformat your test cases to make them easier to copy & paste, please?

Suggested test case: /o\ & <sp><sp>---. My initial approach worked for all your test cases, but not for one where Jimmy falls of at the left side.

Is swapping truthy-falsy values allowed? (i.e. output true when Jimmy falls and false when that doesn't happen?)

Are we guaranteed only 1 platform?  What if there's 2 platforms with a 1-space gap in between them, and he has one arm on each platform but his body is over the hole?

@DarrelHoffman I said the platform must be complete (fully connected) in the question.

Now I'm wondering whether one of the marbles-like languages here allows the input to be the program. If, by any chance, an o is a marble and the language outputs something different for whether that marble reaches the bottom or not, it would work.

@tomsmeding Sounds like a convoluted quine in the works.

Is PETSCII acceptable in place of ASCII? And do you mean true ASCII, or extended ASCII? -> https://en.wikipedia.org/wiki/PETSCII

...to be continued on the next episode of Jimmy!

@facepalm42 Next Jimmy challenge coming soon?

Jelly, 6 bytes
n⁶Sċ2Ẓ

Try it online!
Explanation:
n⁶Sċ2Ẓ  args: z (e.g. [['/', 'o', '\\'], [' ', '-']] => 0)
        implicit return value: z ([['/', 'o', '\\'], [' ', '-']])
n⁶      dyad-nilad pair ([[1, 1, 1], [0, 1]])
 ⁶       4th command-line argument or space [4th CLA assumed absent] (' ')
n        vectorized inequality ([[1, 1, 1], [0, 1]])
  S     reduction by addition with base case 0 ([1, 2, 1])
   ċ2   dyad-nilad pair (1)
    2    literal (2)
   ċ     number of occurrences of right in left (1)
     Ẓ  primality (0)

@IMustBeSomeone, if I'm going to fall off a platform to my doom, I'd want someone to be quick in telling me!

@Shaggy I always thought it was funny when people made challenges with an introduction: "Because we don't want to spend too much time on X, the code has to be as short as possible.", even though code-golf and performance are in most cases opposites. If we can save a byte going from $O(\log(n))$ to $O(n^n)$, who cares about performance, we got a byte off! ;p

I don't know Jelly, but why does the S sum the columns instead of the rows? :S If I looked at the wiki correctly the code does: n⁶ check for each character that it's not equal to a space (i.e. ['/o\\', ' -'] -> [[1,1,1],[0,1]]); S sum list (but for some reason this sums columns instead of rows.. so [[1,1,1],[0,1]] -> [1,2,1]); ċ2 count the amount of 2s; Ẓ check if this is a prime (so 2 or 3), after the result is output implicitly. But I would have expected [[1,1,1],[0,1]] to sum to [3,1]..

@KevinCruijssen S is equivalent to 0;+/Ɗ, that is, reduce by addition (which vectorizes) with initial value 0. § does what you expected S to do.

@KevinCruijssen I've gotten around to adding an explanation.

JavaScript (ES6), 38 bytes
Takes input as (a)(b). Returns \$0\$ or \$1\$.
a=>b=>b[a.search`o`]=='-'&/--/.test(b)

Try it online!
How?
We look for the position of the middle part "o" of Jimmy's body in the first string and test wether there's a dash in the second string at the same position.
b[a.search`o`] == '-'

The only case where Jimmy would be unsafe in this situation is with a single-dash platform:
/o\
 -

So we additionally make sure that the platform has a width of at least \$2\$:
/--/.test(b)

JavaScript (ES6), 36 bytes
Alternate version if we assume that there's always either dashes or spaces below Jimmy (i.e. the input is rectangular).
a=>b=>b[a.search`o`]!=0&/--/.test(b)

Try it online!
Takes advantage of the fact that the coercion to a numeric value is \$0\$ for a space and NaN for a dash.

Wow. Could you explain how that works?

@connectyourcharger I've added an explanation.

Genius! JS answers usually aren't that short.

Would this work for 35 bytes?

@Oliver will fail for "/o\\\n__"

Could you not replace b[a.search\o`]!=0with!!b[a.search`o`]` in the second program?

@GezaKerecsenyi No, because (' '!=0) === false, but (!!' ') === true (see the footnote and see this test).

Python 3,  88 43 bytes
Input is given in the form of a list containing two strings: the first string is the first line; the second string is the second line.
lambda a:sum(1-(" "in i)for i in zip(*a))>1

Try it online!
Another version, tying for 43 bytes (I haven't been able to get it shorter than 43):
lambda a,b:b[a.find("/"):][:3].count("-")>1

Try it online!
Down by 42 bytes thanks to a tip from Jo King.
Old Version:
lambda s:sum((s.split("\n")[1]+" "*len(s))[i]=="-"and s[i]!=" "for i in range(len(s)))>1

-2 bytes thanks to Sriotchilism O'Zaic.
This works by taking two separate inputs, then pairing up corresponding letters. It counts the number of pairs where neither character is a space, then returns True if that number is greater than 1.

Excel, 67 45 44 bytes
=(MID(A2,FIND("o",A1),1)="-")*(TRIM(A2)>"-")

Put Jimmy in A1, on a platform in A2.
2 conditions checked:

Is Jimmy's torso (o) on the platform?
Is the platform more than just -?

@Keeta Edits within the first five minutes aren't shown in the edit history.

From the limited testing I did, I think that you can change <> to >

Python 2, 42 37 bytes
lambda j,p:'--'in p[j.find('/'):][:3]

Try it online!
5 bytes thx to negative seven

"--"in [...] for -5 bytes

@negative seven: nice; thanks!

Perl 6, 18 bytes
{?/''B|Bq/}o&[~^]

Try it online!
Takes a two parameters and returns a boolean of whether Jimmy will stay on the platform. This works by XORing the two lines together and checking if either part of Jimmy is still on the platform.
Explanation:
             &[~^]   # String XOR operator
{          }o        # Combined with the anonymous function
 ?/       /          # That checks for the regex match
   ''B              # Unprintable, B, which is "/o" ~^ "--"
       |Bq           # Or B, q, which is "o\" ~^ "--"

Haskell, 34 bytes
a#b=[1|(p,'-')<-zip a b,p>' ']>[1]

Try it online!
I got this one by combining my below technique with the other haskell answer.
Haskell, 45 bytes
x#'-'|x/=' '=1
x#y=0
(((>1).sum).).zipWith(#)

Try it online!
This counts the number of body parts (non-space characters) that are on top of the platform and then checks it is greater than 1.  The reason we count body parts on the platform rather than body parts off is that zipWith will chop the top line to be the length of the bottom and thus can chop off Jimmy's body parts.  This prevents us from having to do something like cycle" " to pad the list.

Can't you reduce by 2 bytes by converting to infix?

@cole Yep I was just doing the edit when you commented :)

///, 85 93 87 bytes
/~/\/\///\/o\\/(o)~
/
~
~/ (o) /(o)~ (o)-/(o)~- -/--~(o) - ~/) ~/)-~/o~/(-/1~-~/(~/)~

Try it online!
Output's a 1 if Jimmy is safe. Otherwise outputs nothing. (Unary 1 and 0.) Because there is no other way to take input in ///, it needs to be hard-coded:
/~/\/\///\/o\\/(o)~
/
~
~/ (o) /(o)~ (o)-/(o)~- -/--~(o) - ~/) ~/)-~/o~/(-/1~-~/(~/)~ //<INPUT HERE>

For example:
/\/o\\/(o)//
/
//
/// (o) /(o)// (o)-/(o)//- -/--//(o) - ///) ///)-///o///(-/1//-///(///)//         /o\
  -------------

(Try it online!)
Note the space after the <INPUT HERE>.
Explanation:
NOTE! The explanation code cannot be run due to the comments. The comments are enclosed in curly braces. Also, the original code uses a golf where // is replaced with ~. This code is omitted from the explanation.
/\/o\\/(o)/            {replace Jimmy with a Jimmy with curvy arms, because slashes are hard to manipulate in this language}
/
/
/                      {remove unneeded spaces after Jimmy, but before the floor}

/
//                     {get rid of the line break

/ (o) /(o)/            {remove all the spaces before both Jimmy and the floor}
/ (o)-/(o)/            {for each floor tile, remove it and one space before Jimmy. This detects whether Jimmy lines up with the floor.}
                       {If Jimmy is before the floor, then there will be extra floor.}
                       {If Jimmy is behind the floor, then there will be extra spaces before Jimmy.}
/- -/--/               {Handle the case where there is a hole beneath Jimmy but he is still well-supported}

/(o) - //              {Handle the case where only Jimmy's head is on the floor. The space at the end of the code is necessary for this.}
/) //                  {The rest of the substitutions clean up the result and handle each of the possible results that could exist at this point}
/)-//
/o//
/(-/1/
/-//
/(//
/)//

              /o\
               --
 {there is a space right before this comment. The comment is only here to make the space visible and explain itself.}

+8 bytes to fix a bug
-6 bytes by applying a standard /// golf trick.

The source code looks like some strange emoji.  \(o)-(o)//

///, 57 bytes
/|/\/\///\/o\\/J| J/J*|
/|* /|  -/  | /|*-/|--/!|-/|*/|J|

Try it online!
Append the input to the end of the program in order to run. Returns the empty string if Jimmy falls off the platform, a string of exclamation points otherwise.

/|/\/\// replaces | with //, which makes the code both shorter and more readable (| is used to demarcate each replacement)
/\/o\\/J| J/J*/ replaces Jimmy with J for brevity and changes the space to the left of him to * to the right of him
The next replacement gets rid of newlines.
/* /|  -/  | // cancels out *s and with the space to the left of the platform. If there are two or more spaces left, Jimmy is falling off to the left, and the platform is deleted. This part also removes any whitespace to the right of the platform.
/*-/|--/!/ cancels out *s and with length of the platform. If there are at least two - left, Jimmy isn't falling off to the right, so they are replaced with a !.
/-/|*/|J// deletes every remaining character that isn't !

Dyalog APL Extended, 11 10 8 bytes
2≤1⊥∧⌿⍤<

Try it online!
Explanation:
2≤1⊥∧⌿⍤<  a monadic train
       <  Compare the input with the implicit prototype element - a space.
          Returns a boolean matrix of characters that are greater than 0x20
    ∧⌿⍤   and-reduce that, i.e. places where both Jimmy and a platform is
  1⊥      base 1 decode, aka sum - the amount of body parts over the platform
2≤        is that greater-or-equal to 2?

-2 thanks to Adám.

-2: 2≤1⊥∧⌿⍤<

MathGolf, 6 14 bytes
`^@╞^αmÆû-oñ╧╙

Try it online!
8 bytes had to be added to account for the edge case presented by Nick Kennedy.
Checks if "-o-" is a substring of the zipped string of both lines, and the zipped string where the first input line has the first character removed. Takes input as two separate strings, with the only change being that the character is input as /o\\, since \\ is the correct way to input a backslash in a string in MathGolf.
Explanation
`                duplicate the top two items
 ^               zip top two elements on stack
  @              rrot3
   ╞             discard from left of string/array
    ^            zip top two elements on stack
     α           wrap last two elements in array
      mÆ         explicit map using 5 operators
        û-oñ     push "-o" and palindromize to make "-o-"
            ╧    pop a, b, a.contains(b)
                 map block ends here
             ╙   max of list

Oh, that's a better approach than my MathGolf answer.. After the interleave I split it into parts of size 2 again instead of directly checking for "-o-".

Fails for https://tio.run/##y00syUjPz0n7/z/u8G7d/MMbH01d/v@/un5@TIy6grqurvp/3RQA

@NickKennedy good catch! I'll see how I can fix the code, and update the post once it passes. It'll probably add a few bytes though, which is unfortunate.

chevron - 126 bytes
not an improvement over my old answer (at all), but rewritten after a rewrite of chevron itself.
> >^j
0>^i
^i+1>>^i
^j,^i~c>>^h
->+2??^h=/
->-3
> >^q
^q~s>>^s
->+5?^i>^s
^_p>^s
^q^s^s,^i,3~c>>^p
->+2??^s^s^s~^s^p^s
><1
><0

EXCEL, 94 71 bytes    . VBA (Excel), 87 bytes
A1 = Jimmy , A2 = platform
-23 bytes. Thank you @Wernisch.
=(FIND("-",A2)-FIND("/",A1)<2)*(FIND("\",A1)-LEN(A2)<2)*(TRIM(A2)<>"-")

?[(FIND("-",A2)-FIND("/",A1)<2)*(FIND("\",A1)-LEN(A2)<2)]*(len(replace([A2]," ",""))>1)

Can't you use trim instead of len(replace?

oh! that never sink in my head. haha Thanks @Wernisch :)

05AB1E (legacy), 9 8 7 bytes
ζðм2ùgp

-1 byte thanks to @Mr.Xcoder with the approach of ðм2ù.
Input as a list of two strings.
Only works in the legacy version of 05AB1E, because ζ can transpose a list of strings as well as a 2D list of characters, whereas the ζ in the new 05AB1E version only works with the 2D list of characters.
Try it online or verify all test cases.
Explanation:
ζ        # Zip/transpose; swapping rows/columns, with space as default filler
 ðм      # Remove all spaces from each string
   2ù    # Only leave strings of size 2
     g   # Count how many there are left
      p  # Check if this is a prime (2 or 3)
         # (after which the result is output implicitly)

Your title breaks the leaderboard, smh :)

@connectyourcharger Ah, probably because I always link the bytes to the code-page so you know it isn't encoded in UTF-8 but uses a custom encoding instead. ;) If you want I can edit my answer to put the encoding below the title, but honestly the leaderboard code should be able to handle it imho.

I feel like I need to add a special case for 05AB1E - it is one of the only languages that has issues with the codepage. Fix incoming soon-ish.

Struggling to come up with a modified regex. For now that will be a persisting bug. If you'd like to contribute here's the script: https://github.com/xMikee1/ppcg-leaderboard/edit/master/docs/script.js. I may have to refactor the bytes parsing entirely.

Can't you modify the URL to https://github.com/Adriandmen/05AB1E/wiki/Codepage?7 to make 7 the last number without invalidating the URL?

Ruby, 28 bytes
->a,b{!(/--/!~b[a=~/\//,3])}

Try it online!

Excel, 36 bytes
=LEN(TRIM(MID(A2,FIND("/",A1),3)))>1

Jimmy in A1, on a platform in A2.
Finds the position of Jimmy, and takes the 3 bytes of the platform and trims off spaces.  If the resulting platform length is long enough, Jimmy stands.

Husk, 5 bytes
¬εδ#&

Try it online! This function takes the two lines as separate arguments. δ#& zips the two strings together and counts the number of pairs in which both characters are truthy, i.e., neither is a space character, and ¬ε tests that the count is greater than 1.

Kotlin, 60 bytes
fun String.c(b:String)=zip(b){i,j->i>' '&&j>' '}.count{it}>1

Explanation:
fun String.c  # Define an extension function on string, so we don't have to provide a first argument (and we also have string method calls for free)
(b:String)    # Pass the second string as argument
=             # Shorthand syntax for fun body
zip(b)        # Essentially a.zip(b). Creates a List<Pair> by joining both arrays.
              # Takes care of trailing whitespace, because it will be the size of the smaller array
{i,j->        # Declare a transformer lambda as second function argument
i>' '&&j>' '} # This essentially translates to: If i!=' ' and j=='-'
.count{it}    # Count the true values
>1

Welcome to Code Golf! That's certainly a very nice first answer.

R, 35 bytes
function(x)sum(colSums(x!=" ")>1)>1

Try it online!
Based on @EriktheOutgolfer’s excellent Jelly answer so please upvote that one too!
Input is a 2-d matrix of characters.

Haskell, 59 bytes
f a b=sum[1|(p,q)<-zip a$b++cycle" ",elem p"/o\\",q==' ']<2

Try it online!
The function is called like so: f "/o\\   " "  -- "
How it works (for f "/o\\" " -"):
b++cycle" " - Adds an infinite number of spaces after b to ensure that Jimmy is always above a - or  (" -" → " -         ..."
zip a$b++cycle" " - Zips the two strings together ([('/',' '), ('o','-'), ('\\',' ')])
(p,q)<-zip a$b++cycle - For each pair in the zipped list
[1|(p,q)<-zip a$b++cycle" ",elem p"/o\\",q==' '] - Generates a list of 1s, whose length is the number of pairs satisfying the conditions:
elem p"/o\\" - The character in the top string is one of Jimmy's body parts. (Satisfied by all three pairs in this example)
q==' ' - The character in the bottom string is a space. (Satisfied by ('/', ' ') and ('\\', ' '))
So, the pair has to be one where one of Jimmy's body parts is above a space.
Because in this example, two pairs satisfy both conditions, the list is [1,1]
sum[1|(p,q)<-zip a$b++cycle" ",elem p"/o\\",q==' '] - Take the sum of those 1s (i.e. the length of the list), which in this example is 2.
sum[1|(p,q)<-zip a$b++cycle" ",elem p"/o\\",q==' ']<2 - Check if the number of body parts above a space is less than 2. In this example, it's not, so Jimmy will fall off. :(

I just thought I would let you know that your answer helped me to shorten my own answer.  So thanks!

C (gcc), 73 bytes
f(s,t,c)char*s,*t;{for(t=strchr(s,c=10);*s%5**t;)c-=*++t%2**s++%8;c=c<0;}

Try it online!

Suggest index() instead of strchr()

Julia 1.0, 42 40 bytes
y(a,b)=strip(b[findfirst("/o\\",a)])>"-"

Try it online!

SnakeEx, 13 bytes
j:<R>o<T>\-\-

SnakeEx does well because it's a 2D pattern-matching language, but not too well because it wasn't designed to be very golfy. Try it here!
Explanation
j:             Define the main snake, j (for Jimmy)
  <R>          Pivot right (i.e. downward, since the snake starts out moving to the right)
     o         Match Jimmy's torso (or is it his head?) and move down
      <T>      Turn either left or right
         \-\-  Match two platform characters

This will match if there are two platform characters under Jimmy, or fail to match if there are not. We don't need to consider the case where there are platforms only under his legs, since the platform cannot have holes.

Ruby 2.5.3, 44 bytes
->a,b{a.zip(b).map(&:join).grep(/\S-/).size>1}

Input taken as two arrays. Definitely not the most golf-friendly approach (see G B's answer), but I like any excuse to use the zip function.

40 column Commodore BASIC (C64, C16/+4, C128, PET, C64Mini) - non-competing* - 98 tokenized and BASIC bytes used
 0a=rN(.)*36:b=rN(.)*39:c=-rN(.)*(b-39):fOi=0tob:a$=a$+"-":nE:?tAa)"/o\
 1?tAc)a$:?-(a>c-2anda<c+b+2)

Here is the unobfuscated listing for explanation purposes
 0 let a=rnd(0) * 36
 1 let b=rnd(0) * 39
 2 let c=-rnd(0) * (b - 39)
 3 for i=0 to b
 4  let a$=a$+"-"
 5 next i
 6 print tab(a);"/o\"
 7 print tab(c);a$
 8 print -(a>c - 2 and a<c + b + 2)

The variable a is used for positioning Jimmy (using PRINT TAB(A) which is zero-indexed).
The varaible b is used for the length of the platform.
And finally the variable c is used for the position of the platform.
The loop in lines 3 through to 5 inclusive builds the platform for Jimmy, with line 6 printing Jimmy at his pre-determined position, and 7 for the pre-determined position of the platform. Finally, 1 or 0 is outputted to represent our TRUE or FALSE value.
Note, the listing includes keyword abbreviations to ensure we break the 80 character limit per line on standard Commodore C64 BASIC.

* Assumed non-competing because PETSCII is not ASCII. Jimmy looks better in PETSCII though, of course.

Japt, 8 bytes
Õ·kèS Êz

Try it

Sorry, didn't see this before posting mine last night :\

C# (Visual C# Interactive Compiler), 44 40 39 bytes
-4 bytes thanks to Jo King
a=>b=>a.Zip(b,(x,y)=>x>y?y:0).Sum()>109

Try it online!

40 bytes that works

Does not quite work; https://tio.run/##Sy7WTS7O/O9WmpdsU1xSlJmXroPMTsrPz7GzU0hTsP2faGuXZGuXqBeVWaCRpKNRoVOpaWtXoV1pZ25ub2hloKkXXJqroWln9N@aiyu8KLMk1SczL1UjTUNJPz8mRgEZKGlyIfE0lECkLjJQ0tT8DwA

@CharlesS I believe I fixed it and saved a byte in the process

@ExpiredData yep, nice!

Retina 0.8.2, 16 bytes
 (.*¶).
$1
¶ ?--

Try it online! Link includes test suite. Explanation:
+`^ (.*¶).
$1

While there is still a space on the first line, and both lines still have more than one character, delete the space and the first character of the next line. Note: This assumes that there is no trailing space after Jimmy. +1 byte needed if trailing space needs to be allowed.
¶ ?--

Check that there are at least two pieces of platform under Jimmy.

PowerShell, 63..55 53 bytes
-1 byte thanks to mazzy
param($j,$f)''+($f|% t*y|?{$j[$i++]-gt32})-match'- -'

Try it online!
Takes input as two lines.
Unrolled:
param($j,$f)            #Take $jimmy and $floor
''+                     #Implicitly converts next part to string
($f |% ToCharArray      #Convert $f to a char[] and...
    |?{                 #Only take the chars where...
        $j[$i++]-gt32   #The same indexed char in $j's ASCII # is > ' ' i.e. only get /o\
     }
)-match'- -'            #Arrays.ToString are joined with a space and we need 2 -'s

Huh. I never considered PowerShell a great golfing language, but I guess it's actually not that bad.

@connectyourcharger It can do some pretty neat stuff with the pipeline but there's definitely a few areas where it's a huge pain in the ass.

I never bothered to learn it because of those pain-in-the-ass reasons.

nice! step back and save one more :)

Perl 5 -pl, 42 bytes
/o/g;$_=(($_=<>)=~/./g)[-1+pos]eq'-'&&/--/

Try it online!

Python 3.7, 71 56 Bytes
lambda s:sum(j in'/o\\'and p=='-'for j,p in zip(*s))>1

Very simple version and the shortest I could think of using this approach. Input s is a list of two strings, the first one for the Jimmy-row, the second one for the platform.
Zip the characters which are above one another and then check whether - is below a part of Jimmy in at least two instances.
EDIT: Reduced by quite a few Bytes thanks to Blue!

Hi, welcome to Code Golf! Couple things: you might want to specify the input format in your answer (looks like s should be two lists, one for jimmy and one for the platform?). Also, there are a few places you can save bytes: instead of summing a list, you can sum the raw iterator (remove the brackets); instead of checking >=2, check >1; you can sum True and False like 1 and 0, no need for the if-else. Finally, before posting a new answer in the same language, you should look at the previous ones to see if you can improve.

@Blue Hi, thanks a lot! And yeah I will keep that in mind in the future. :)

Bash, 49 bytes
[[ "${1:$((`expr index "$0" /`-1)):3}" =~ "--" ]]

Jimmy input as command line parameter 0, the platform as parameter 1; Must be aware of Bash's separating and eating whitespace (use single quotes):
bash -c '[[ "${1:$((`expr index "$0" /`-1)):3}" =~ "--" ]]' '   /o\' '  -------'

Attache, 38 bytes
{2>Sum!`~&Sum[Ord@Grid@_-39]=>1'46'65}

Try it online!
Explanation
We convert the input string to a grid of ASCII codepoints, subtract 39 from each, then take the Sum, columnwise. (Sum[Ord@Grid@_-32]). Then, we bind this array to the ~ operator, which in this case counts the number of times the argument occurs in the bound array. We apply this function to each member of the array 1'46'65 with =>, which correspond to various body parts not above a platform. We then take the sum of this resulting array with Sum!. This is the count of body parts not above the platform. Finally, we check to see that 2 exceeds this sum; if it does, then we return false, for Jimmy has fallen. If it does not, we return true, for Jimmy is quite safe on his perch.

Charcoal, 19 bytes
η⸿Ｐθ…θ⌕θo≔№ＫＭ-ζ⎚›ζ¹

Try it online! Link is to verbose version of code. Outputs - if the Jimmy will balance, nothing if he will fall off. Explanation:
η

Print the platform.
⸿

Move down a line. (Reversed gravity turned out to be golfier.)
Ｐθ

Print Jimmy without moving the cursor.
…θ⌕θo

Print Jimmy's leg leaving the cursor over his body.
≔№ＫＭ-ζ

Count the number of adjacent -s from the platform.
⎚

Clear the canvas.
›ζ¹

Output a - if the platform was large enough.

The challenge asks for boolean output rather than the two distinct value sort of output that tends to be common.

@SriotchilismO'Zaic That's just the default output of a boolean expression in Charcoal.

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

Try it online!
String parsing is hard in Brain-Flak.  It considers anything on the first line other than space to be Jimmy and anything on the second line other than - to be open air.  The reason we test for - instead of space is that Brain-Flak pads the input indefinitely to the right with nulls (ASCII codepoint 0) which we need to consider open air.  This luckily means we don't have to worry about needing trailing whitespace in the input.

C (gcc), 103 bytes
i,j,l;f(char*s){for(i=0;*s-10;j=*s++-47?j:i)++i;l=strlen(s)>j+1;s+=j;return l&&*s+s[1]+(s[2]?:32)>109;}

Try it online!
Would be much shorter (75 bytes), if it could be assumed that there is trailing whitespace after the platform.

95 bytes

Retina, 31 29 bytes
^(.)*/.*¶(?<-1>.)*(?(1)!) ?--

Try it online!
Saved 2 bytes thanks to Neil!
A simple regex that determines whether at least two pieces of the platform are directly beneath Jimmy. Assumes that the input will contain no ! characters.

I don't think you need the trailing -?.

@Neil Quite right, I don't know what case I thought I was covering with that.

Japt -¡, 9 bytes
-1 byte if the input can be reversed.
VtUao)è-²

Try it online

@SriotchilismO'Zaic Updated

V, 18 bytes
0vt/"_dj.d3lVkp0#x

Try it online!
Output whitespace only if jimmy fall of the platform. Output something non-whitespace if jimmy stay on the platform.

Not using Ctrl or Esc in Vim is funny.

Japt -!, 7 bytes
ÕèSi.)z

Try it
ÕèSi.)z     :Implicit input of multi-line string
Õ           :Transpose
 è          :Count the occurrences of
  S         :  Space
   i.       :  Prepended with ".", giving the regex /. /g
     )      :End count
      z     :Floor divide by 2
            :Implicit output as Boolean

Pyth, 9 bytes
!!tt#rL6C

Try it here! (Note: This is a temporary interpreter, hosted on pythtemp.herokuapp.com; the official pyth.herokuapp.com can't be used for now)
If swapping truthy-falsy values were allowed, this would become 8 bytes by dropping one of the !s (awaiting confirmation). Moreover, if outputting an empty list for the case when Jimmy falls  and a non-empty list otherwise would be an option, both !s could be dropped.
How it works
!!tt#rL6C – Full program. Receives a list of two strings through STDIN.
        C – Transpose / Zip (switch from rows to columns)
     rL6  – Strip the whitespace on both sides of each column.
   t#     – Filter-keep those that have a tail (i.e. that are length-2).
  t       – Tail. The result will be non-empty iff Jimmy doesn't fall.
!!        – Double negation (to output as a boolean...).

PHP, 90 80 bytes
Code
<?=substr_count(substr(($v=explode("
",$argv[1]))[1],strpos($v[0],"/"),3),"--");

Try it online!
Mistakenly coded allowwing jimmy with just a leg on the edge

<?=count($v=explode("
",$argv[1]))>1&&substr_count(substr($v[1],strpos($v[0],"/"),3),"-");

Try it online!
Explanation
<?=
substr_count(
substr(($v=explode("\n",$argv[1]))[1],// explode and get Jimmy body
        strpos($v[0],"/"),  // find "/" position (position start)
        3),                 // substring of the platform length
        "--");              // platform has to contain "--" somewhere
//
//

The puzzle states that the input is two lines, and the second one is not empty, so you can remove that check

I tested the code on the TIO, and it fails with two spaces before the platform, or if jimmy is only with it's left leg (test case 3). it also fails the last test case

Thank you @Einacio, i mistakenly coded allowing jimmy to have 1 leg and nothing else on the platform, also ty for the advice on removing the condition for 2 lines as input.

Elm 0.19, 99 bytes
f j p=List.sum(List.map2(\a b->if a/=' '&&b/=' 'then 1 else 0)(String.toList j)(String.toList p))>1

Port of Maxwell's Python 3 answer. Verify all test cases here.

Pip, 29 bytes
sN(STbALsRL#a)@>(a@?"/")@<3<2

The padding with spaces part took a while to figure out.
The second argument must have atleast one space before it, otherwise the program will error. Add a space to the first argument as well for testing.
Explanation:
sN(STbALsRL#a)@>(a@?"/")@<3>1
  (STbALsRL#a)                pad second line with spaces, convert to a simple string
                (a@?"/")      Find index of jimmy's right hand in first line
              @>              Get substring of second line after index taken in prev step
                        @<3   cut it to the three planks under Jimmy
sN                            Find number of spaces in substring i.e.
                                "---" => 0, " - " => 2
                           <2 find out if Jimmy is standing on thin air(hopefully not)

Try it online!

APL (Dyalog Unicode), 11 chars
2>1⊥' '<.=↑

          ↑  ⍝ from nested vector of char vectors to char matrix
    ' '<.=   ⍝ for each column gives 1 if there's a space in the
             ⍝ lower row but not in the upper row, 0 otherwise
2>1⊥         ⍝ is the count of 1s less than 2?

Try it online!

Burlesque, 22 bytes
lnp^'/FiR@3.+si'-CN1.>

Try it online!
lnp^  # Split into lines and push onto stack
'/Fi  # Find the index of '/' (Jimmy's left leg)
R@3.+ # Index..Index+2
si    # Select these indices from the platforms
'-CN  # Count of -s
1.>   # Greater than 1

your 14 byte solution returns the wrong answer for this, should be 0 according to test cases. Your 22 byte solution works correctly.

Yeah, I feared that might be the case, hence the 22, editing to remove.

Stax, 7 bytes
╔≈╔'♀B┬

Run and debug it

Batch 233 198 bytes
@Set j=%~1&set p=%~2
@Set v=%p:-=&Set/Az+=1+0%
@Set v=%v: =&Set/Az+=1%
@Cmd/VON/C"For /l %%i in (0 1 !z!)Do @(Echo(!j:~%%i,2!!p:~%%i!|Findstr/c:"/o--" /c:"o\\--">nul&&Exit/b 0)"&&Echo(1||Echo(0

Note:

input is done using args when the program is run from the command line

IE: Jimmy.bat "/o\" " - "

How:
    @Set j=%~1&set p=%~2

Take input for jimmy and platform

    @Set v=%p:-=&Set/Az+=1+0%

Count number of - characters - +0 avoids missing operator error for undefined z variable

    @Set v=%p: =&Set/Az+=1%

Count number of   characters

@Cmd/VON/C"For /l %%i in (0 1 !z!)Do @(Echo(!j:~%%i,2!!p:~%%i!|Findstr/c:"/o--" /c:"o\\--">nul&&Exit/b 0)"&&Echo(1||Echo(0

Iterate over the length of the string in a new cmd instance with delayed expansion, trim jimmys string to 2 characters to test String pairings from the offset of the iterations count and test for a match to "/o--" or "o\--" using findstr. On match, exit the instance using exit /b 0 to return a 0 errorlevel to indicate success.

&&Echo(1||Echo(0

ouput result using && success || Fail conditional logic. (findstr returns a positive errorlevel if no match is made)

ayr, 11 bytes
:2>+/</.32=

Explanation
       32=   Find spaces
    </.      Flatten to vector, 1 if lower row has a space but the upper does not
  +/         Sum this list
2>           Is less than two?

Vyxal, 7 bytes
ð=†∑2Oæ

Try it Online!
How?
ð=†∑2Oæ
ð=†     # For each, is it not a space?
   ∑    # Sum
    2O  # Count the amount of twos
      æ # Is this a prime?

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


text:
Smallest web server
Create your smallest web server in your preferred language!
Requirements
Must respond to atleast 1 type of request (get,post,patch,delete), with a specified string.
Smallest implementation wins!
*String can be empty
You may use any library you want
My personal record for this was 56B in node
require('express')().use((r,w)=>w.send('')).listen(8080)

I could return a 404 if you want

Sure, anything that works

Possible duplicate of 418: I'm a teapot

APL (Dyalog Unicode) with MiServer, 8 bytes
Start'.'

Starts a website on port 8080 serving the current directory.
This is what an interactive session transcript can look like:
      )xload miserver
.\miserver.dws saved Thu Apr  4 23:27:46 2019
      Start'.'
Virtual alias "PlugIns" overrides site path of same name.
MiServer for "." started on http://10.101.1.172:8080
Running in Debug mode (configured by setting <Production> in /Config/Server.xml)

Python 3 with -m http.server, 11 bytes
No code. Just run python.
Try it online!

Isn't that 0 bytes with a language of "Python 3 -m http.server"?

The inclusion of "http.server" on the command line accounts for the 11 bytes.

Yeah but isnt that just equivalent to a compiler flag.. like -u in c#


text:
n-level Ouroboros Quine
This 128-language quine ouroboros (a program which outputs a program in another language, which outputs a program in yet another language, (125 languages later), which outputs the original program) is pretty impressive. But unfortunately, it has a static number of iterations.
Write a program which outputs a program (not necessarily in another language, but it can be), which outputs a program, which outputs a program, etc., which after n iterations, outputs the original program for the first time (i.e. no intermediate program should be the same as the original, because otherwise a quine which ignores its input would work), where n is a non-negative integer provided as input. The input can't be just a number in the original source code (e.g. putting x = <the value of n> at the start of your program), it should be one of the following:

Passed as a command-line argument
Read from standard input
Passed as an argument to a function, which returns/outputs the new program.

For intermediate stages in the ouroboros, your program can either be a fully-functioning program, or a function with no arguments, which, when called, will return/output the next one.
You may not read from the source file itself, or use any quine-like builtins (I don't think there are any which would do this, but there might be)
To be clear, if n = 0, the program should output its own source code.
If n = 1, the program should output a different program, which outputs the original source code.
And so on...
Fewest bytes wins!
Edit:
I should have written "For intermediate stages in the ouroboros, your program can either be a fully-functioning program with no input, or a function with no arguments". If your program outputs the next one in the chain, then waits for input, that's fine, but your program shouldn't need the original value of n.

Related, related.

Can we 1 index n? So n = 1 means print source code, n = 2 means print code which will print source code etc.

Will the iteration versions still have the initial input? So let's say my first input is 3, and I run the program it output. Will there still be an input 3, or no input at all? If there is no input, I guess we need to handle that in case something like getInput() is used without any input provided. Or can we let's say input something random that's unused for later iterations, to prevent errors for the getInput()? A.k.a. is the current Python answer valid?

I suspect that what we're asked to do is, given an integer n, output a program that is the "initial program" of an ouroboros quine of n iterations, and that our answer shouldn't count as one of the n iterations. Is this correct?

@KevinCruijssen I probably should have been more clear about that. The intermediate stages can't have input in any form. I guess if the program outputs the next one and then waits for input, that would be fine.

@EriktheOutgolfer Yes...

05AB1E, 28 bytes
-4 bytes + fix thanks to Kevin Cruijssen
"34çìD«s<©di®ì"34çìD«s<©di®ì

Try it online!

Explanation
This works by appending the remaining number to print to the front of the code, which means it's added to the stack the same way an input would be. In the base case of input of "0" it will not concatenate the 0 on the front.

d is non-negative (>=0) instead of positive (>0). Problem is that to check d without popping it, you need to duplicate it first, but then it also need to be discarded on iteration 0"quinsting", otherwise it will output the duplicated 0. :(

"34çìD«s<©di®ì"34çìD«s<©di®ì for 28 bytes perhaps (which is still pretty close to your intended approach)? (I'm afraid your current version for iteration 0"34çìD«s<Ddiì"34çìD«s<Ddiì outputs -1 from the Duplicate..)

Runic Enchantments, 39 bytes
"3X4+kSql1=c*?S:1-}C'LA-}!i:0)2*?~!'´@

Try it online!
Would be 4 bytes shorter than 05AB1E using the same tactic if inputs where less than or equal to 10. But as we need to support arbitrarily large values, it gets more complicated.
Numerical value of n gets placed at the front and parsed as a continuous number literal using ´. "3X4+kSq is the basic quine code. If no value is present at the front, the stack length will only be 1 (the quine) otherwise 2 letting l1=d*? determine how to handle things from there.

If there is a value, S:1-}'LA2+-} runs: swap the value to the top, subtract 1, duplicate it, leaving a copy on the bottom of the stack, get the Log10 of that value times 100 (resulting in the value's own character length, plus 1 for the ´), remove that many characters from the end of the string (effectively truncating itself off the end, both where it isn't needed and because it has the wrong value). C is one byte shorter than 2+ and results in the same value.
If there is not a value, read one from input.

Regardless: :0)2*? duplicate and compare with zero.

If non-zero push ´.
If zero, pop the value. We can cheat using ! instead of 2? and save a byte because when ´ tries to execute the first byte it sees is non-numeric and immediately drops out of number mode at the same position.

Print entire stack top to bottom.

Java 10, 145 bytes
n->{Long N=n;var s="n->{Long N=%s;var s=%c%s%2$c;return s.format(s,N>0?N-1+%2$cL%2$c:%2$cn%2$c,34,s);}";return s.format(s,N>0?N-1+"L":"n",34,s);}

Try it online and see the outputs of some iterations.
Explanation:
quine explanation:

The var s contains the unformatted source code
%s is used to put this String into itself with s.format(...)
%c, %1$c, and 34 are used to format the double-quotes
s.format(s,34,s) puts it all together

Challenge part:
The first lambda function takes a long input as parameter.

This is set in variable Long N=n; in the first iteration. Or in Long N=%s; for next iterations.
The ternary check N>0?N-1+"L":"n" will fill this %s with value N-1, appended with L since it's a long and to convert it to a String for the %s, if N is larger than 1. If N is 0 instead (initial input was 0 or this is the last iteration of the interquine-'loop'), it will fill this %s with the initial n instead.

The spec says intermediate outputs have to be a full program or a function without arguments

@EmbodimentofIgnorance I know, that's what I have. The first lambda function takes a long function-parameter, and the other lambda functions take an unused Void parameter, which I also always use for challenges stating to take no input because v-> is 1 byte shorter than ()->.

Python 3.8 (pre-release), 60 56 55 53 bytes
lambda n=-1,s='lambda n=%d,s=%r:s%%(~-n,s)':s%(~-n,s)

Try it online!
-2 bytes thanks to Jo King
As of the 53 byte version, also works in Python 2 and Python 3.

The intermediate function doesn’t seem to be a full program or a function that takes no arguments.

That walrus operator := is a welcome addition to Python, that's for sure.

"For intermediate stages in the ouroboros, your program can either be a fully-functioning program, or a function with no arguments, which, when called, will return/output the next one."

@NickKennedy Updated to comply with the spec, and coincidentally saved 4 bytes.

53 bytes without using :=

Jelly, 22 20 bytes
“Ṫ_1xẸƲ;Ṿ⁾v,⁾¥ ”v,¥

Try it online!
Try repeated calls of code
A full program that takes a single argument \$n\$. Main version outputs correctly to stdout but cannot be used as a function with a function return. The repeated calls version is 2 bytes longer but returns programmatically usable output. L

Haskell, 195 164 bytes
main=putStr(x++show x++"\na=")>>(getLine:cycle[pure$show$a-1])!!a>>=putStr
x="main=putStr(x++show x++\"\\na=\")>>(getLine:cycle[pure$show$a-1])!!a>>=putStr\nx="
a=0

Try it online!
This uses a pretty simple quine technique.  We modify it with a variable a which is set to a number.  If that number is zero (which it is at the start) we take input and output our source with a set to the input number.  If a is not zero we output our source with a set to one less.  This way a counts down to zero before outputting the original source.

R, 92 bytes
f=function(n=-1){gsub("\\s","",paste("f=",sub("-?\\d+",n-1,paste(deparse(f),collapse=""))))}

Try it online!
If deparse is deemed cheating, here’s an alternative:
R, 108 bytes
function(n=-1){s="function(n=%d){s=%s%s%2$s;sprintf(s,n-1,intToUtf8(34),s)}";sprintf(s,n-1,intToUtf8(34),s)}

Try it online!

C# (Visual C# Interactive Compiler), 112 bytes
void f(int n=-1){var s="void f(int n={2}){{var s={0}{1}{0};Write(s,(char)34,s,n-1);}}";Write(s,(char)34,s,n-1);}

Saved a lot of bytes thanks to @NickKennedy!
Try it online!

The intermediate outputs are neither a full program nor a function that takes a single argument. Also I think you have some ns that should be ls. How about https://tio.run/##Sy7WTS7O/P@/LD8zRSFNIzOvRCHPVtdQs7ossUih2FYJRbzaqFazGipTbVBbbVgLJK3DizJLUjWKdTSSMxKLNI1NdIp18oAmWNfWKuGW@5@WXwQ2NdPWyMA60w6IdXU1q4E2aUI0@WTmpWqAFAIA

Perl 6, 44 bytes
<say '<',S{\d+}=get||0-1,'>~~.EVAL'>~~.EVAL

Try it online!
Takes input via standard input and returns a program where the only thing changed is the first number. Each subsequent program will then output the same program, except with that number decremented.


text:
Multi-user CRUD: Valid, Problem, or Error?
Introduction:
Ever used Dropbox with some other people and you both modified the same file? Ever had a multi-user application with a relational database, and two people were modifying (or worse, one was deleting and the other modifying) the same object? Well, let's simulate that with this challenge (sort-of).
For the sake of this challenge, we only have two users and either one or two relevant files. Both users have in general privileges to CRUD (Create, Read, Update, and Delete) all files.
Challenge:
Input:
We'll have a few inputs (input format is flexible, and any reasonable format is allowed):
1) Locking mode (on/off): Kinda the difference between optimistic and pessimistic concurrency locking.
Both users are allowed to CRUD (Create, Read, Update, and Delete) everything, but sometimes errors or problems can occur. Depending on the locking mode a problem when turned off, could be an error when turned on. This is explained below in the Output section.
2 & 3) Two user-actions. These actions always consist of two things: What the user does (Create, Read, Update, or Delete) and for which file.
Output:
We'll have three possible outputs:

Valid: Both actions by both users can be done simultaneously without any issues occurring.
Error: Both actions by both users cannot be done simultaneously and causes an error for one of the users (which user is irrelevant for this challenge). This can occur when:

one user Reads or Updates a file, which the other user Deletes;
both users Update the same file with locking mode turned on;
a user Creates a file, which the other user Reads/Updates/Deletes (this means the file already exists, so it cannot be Created);
both users Create the same file.

Problem: Both actions by both users can be done simultaneously, but can cause unexpected problems. This can occur when:

both users Update a file when locking mode is turned off;
one user Updates a file, which the other user Reads;
both users Delete the same file (practically this will causes an error for the second user, but since it will still be deleted like the user wants, it will be a problem instead of an error for the sake of this challenge)

Challenge Rules:

All input and output is flexible, and everyone should state which one they've used in their answer!
Example inputs: 0/1 for locking mode & 31 (third action: Update; file: 1) & 21 (second action: Read; file: 1); true/false for locking mode & ['C','A'] (action: Create; file: A) & ['D','B'] (action: Delete; file: B); etc.
Example outputs: null/true/false (null = valid; true = error; false = problem); -1/0/1 (-1 = error; 0 = problem; 1 = valid); etc. The three possible outputs have to be unique and distinct for the three output-type, though.
What the files are called is irrelevant, which can also be seen with the input-examples above. So feel free to use any type of file name in your answers consisting of a single (ASCII) letter or digit. They do have to be consistent across all your test cases however, so you can't use A/B in one test case and 1/2 in another.
The four actions for CRUD have to be unique and consistent values as well. So you cannot use 'D'/'C' in one test case, and then 4/1 in another test case.
You can assume that the file chosen by a user always exists when they want to Read, Update, or Delete it.

General rules:

This is code-golf, so shortest answer in bytes 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.

All possible test cases (where the actions can be in either input-order†):
†: You should support all (up to four) variations of the test cases below. So if a test case states action1: Create file A; action2: Update file B, that test case should also hold the same results for action1: Create file B; action2: Update file A; action1: Update file B; action2: Create file A; and action1: Update file A; action2: Create file B.
Valid use-cases:

locking mode: either;  action1: Create file A;  action2: Create file B
locking mode: either;  action1: Create file A;  action2: Read file B
locking mode: either;  action1: Create file A;  action2: Update file B
locking mode: either;  action1: Create file A;  action2: Delete file B
locking mode: either;  action1: Read file A;    action2: Read file A
locking mode: either;  action1: Read file A;    action2: Read file B
locking mode: either;  action1: Read file A;    action2: Update file B
locking mode: either;  action1: Read file A;    action2: Delete file B
locking mode: either;  action1: Update file A;  action2: Update file B
locking mode: either;  action1: Update file A;  action2: Delete file B
locking mode: either;  action1: Delete file A;  action2: Delete file B

Error use-cases:

locking mode: either;  action1: Create file A;  action2: Create file A
locking mode: either;  action1: Create file A;  action2: Read file A
locking mode: either;  action1: Create file A;  action2: Update file A
locking mode: either;  action1: Create file A;  action2: Delete file A
locking mode: either;  action1: Read file A;    action2: Delete file A
locking mode: on;      action1: Update file A;  action2: Update file A
locking mode: either;  action1: Update file A;  action2: Delete file A

Problem use-cases:

locking mode: either;  action1: Read file A;    action2: Update file A
locking mode: off;     action1: Update file A;  action2: Update file A
locking mode: either;  action1: Delete file A;  action2: Delete file A

I feel like there will be a 1 byte solution if I can just come up with the right input/output methods (maybe some kind of bit masking)

@ExpiredData Altered a few parts of the possible outputs, that they have to be consistent, but not necessarily unique. And also that the inputs have to be consistent.

@Arnauld Ah, I excluded all B/B cases in my counting, since I deemed them similar as A/A. That's where the difference is coming from. But I guess that thinking is incorrectly if you have a specific value for the files..

JavaScript (ES6), 36 bytes
Without a lookup table
(m,a,f,A,F)=>f-F?2:a^A?a*A&8:a&4?m:a

Try it online!
I/O

Locking mode (\$m\$): \$0\$ = On, \$8\$ = Off
Actions (\$a\$ and \$A\$): \$0\$ = Create, \$2\$ = Read, \$4\$ = Update, \$8\$ = Delete
Files (\$f\$ and \$F\$): any integers
Output: \$0\$ = Error,  \$2\$ = Valid, \$8\$ = Problem

How?
If the files are different, all operations are safe and we just return \$2\$ (valid).
If the files are identical, we need to return:

\$2\$ (valid) if we have two read operations
\$8\$ (problem) if we have two delete operations, or one update and one read
\$m\$ (either problem or error) if we have two update operations
\$0\$ (error) for everything else

Using a \$4\times4\$ CRUD matrix (which is symmetric by definition), we can see that the above values can be computed with:
$$\underbrace{\text{a ^ A}}_{a\neq A?}\text{ ? }\color{blue}{\text{a * A & 8}}\text{ : }\underbrace{\text{a & 4}}_{\text{update?}}\text{ ? }\color{red}{\text{m}} : \color{magenta}{\text{a}}$$
$$\begin{array}{cc|cccc}
&&\text{C}&\text{R}&\text{U}&\text{D}\\
&&0&2&4&8\\
\hline
\text{C}&0&\color{magenta}{0}&\color{blue}{0}&\color{blue}{0}&\color{blue}{0}\\
\text{R}&2&\color{blue}{0}&\color{magenta}{2}&\color{blue}{8}&\color{blue}{0}\\
\text{U}&4&\color{blue}{0}&\color{blue}{8}&\color{red}{\text{m}}&\color{blue}{0}\\
\text{D}&8&\color{blue}{0}&\color{blue}{0}&\color{blue}{0}&\color{magenta}{8}
\end{array}$$

JavaScript (ES6),  46 45  40 bytes
With a lookup table
(m,a,f,A,F)=>f-F?0:[m,1,1,0][a*2+A*9&23]

Try it online!
I/O

Locking mode: undefined = On, \$1\$ = Off
Actions: \$0\$ = Update, \$1\$ = Read, \$2\$ = Create, \$3\$ = Delete
Files: any integers
Output: undefined = Error, \$0\$ = Valid, \$1\$ = Problem

Retina 0.8.2, 53 bytes
^(.)(?!\1).+|..RR.
V
..DD.
P
..UUL
E
.+[CD].+
E
..+
P

Try it online! Link includes test suite. Takes input as a string of 5 characters, two characters representing the file names, then two characters from CRUD, then L or U (locked/unlocked), and outputs one of VPE (valid/problem/error). Explanation:
^(.)(?!\1).+|..RR.
V

Different file names are always valid, as are two reads. Annoyingly, this is the only test that forces me to use a header. (It would cost an extra byte to make the header unnecessary.)
..DD.
P

Two deletes are always a problem.
..UUL
E

Two locked updates are an error.
.+[CD].+
E

Any other creates or deletes are an error.
..+
P

Everything else is a problem.

Octave, 96 bytes
@(a,b,c)[a(1)!=b(1)|a(2)+b(2)==20,mod((m=a+b+c)(2),10010)<1|mod(m(2),1020000)<1|mod(m(2),200)<1]

Try it online!
Definitely can be shorter, but I don't have time right now to do that
File 1 = 0
File 2 = 1
Read = 10
Delete = 100
Create = 1000
Update = 10000
Lock on = 100000
Lock off = 1000000

Valid Values:
[1 0]

Problem Values:
[0 1]

Invalid Values:
[0 0]

Input as a = [file, action], b = [file2, action2], c = lock


text:
Sum of multiples of powers of ten of an integer
Write a function to produce, for a non-negative integer, a string containing a sum of terms according to the following:
3 -> "3"

805 -> "800 + 5"

700390 -> "700000 + 300 + 90"

0 -> "0"

13 -> "10 + 3"

200 -> "200"

Any input other than a non-negative integer can be ignored. Zero terms must be skipped unless the input is 0. Terms must go from largest to smallest. The plus signs must have only a single space on either side.
This is code golf; fewest number of bytes wins.

The edge case of an input of zero seems awkward and yet easily avoidable with "for a positive integer...".

Thank you so much for detecting the inconsistency. Regarding the +, I'd like to see how people can golf the join, so it was intentional. I say "nonnegative" instead of "positive" on purpose as well. Nonnegative includes 0 which will indeed make the code longer and IMHO more of a challenge to golf. It's true that a list of positive integers (filtered to remove zeros) is way easier, but I did add the two complications as a challenge. I don't use this site too often so if these kinds of complications are frowned upon please let me know for sure. Thanks.

...not really frowned upon, just seems like the core of the challenge on its own would make for a better question. Are the single spaces required or optional?

Required. Though I think I have an idea of how to ask next time. :) Cheers :)

Flexibile output format is generally preferred

Thanks good to know. For next time.

Subset of this question. Enough so, that I would consider this a dupe

Didn't see that. Should I delete? Okay if anyone wants to close it.

Jelly, 14 bytes
DḊƬḌINḟ0ȯ0j”+K

A full program which prints the result
Try it online!
How?
DḊƬḌINḟ0ȯ0j”+K - Main Link: integer, n       e.g. 805
D              - to base ten                      [8,0,5]
  Ƭ            - collect until a fixed point:
 Ḋ             -   dequeue                        [[8,0,5],[0,5],[5],[]]
   Ḍ           - from base ten (vectorises)       [ 805,    5,    5,  0]
    I          - incremental differences          [    -800,   0,   -5 ]
     N         - negate                           [     800,   0,    5 ]
      ḟ0       - filter discard zeros             [     800,         5 ]
        ȯ0     - OR zero (replacing an empty list with 0)
          j”+  - join with '+' characters         [     800,  '+',   5 ]
             K - join with space characters       [800,' ','+',' ',5]
               - implicit, smashing print         "800 + 5"

APL (Dyalog Unicode), 31 bytesSBCS
Anonymous tacit prefix function, taking the number as a string.
(1↓∘∊1@1∘×⊆⌽∘⍳∘≢('+',10⊥↑)¨⊢)⍎¨

Try it online!
⍎¨ execute each character (this gives the digits as numbers)
(…) apply the following anonymous tacit prefix function to that:
 …(…)¨⊢ apply the below function between each element and the corresponding element of…
 ⌽ the reversal
 ∘ of
 ⍳ the ɩndices (1…N)
 ∘ of
 ≢ the tally of digits
  ↑ take that many elements, padding with zeros (as there's only ever one)
  10⊥ evaluate that in base ten
  '+', prepend a plus
 …⊆ partition it beginning a new segment where indicated by:
 1@1 a one at the first element
 ∘ of
 × the sign (0 for 0; 1 for all other)
1↓ drop the first
∘ of
∊ the ϵnlisted (flattened) data

Perl 5 -p, 53 bytes
$&&&push@a,$&.y//0/cr while s/.//;$"=" + ";$_="@a"||0

Try it online!