text:
I'm in your subnets, golfing your code
Challenge
Given an IPv4 address in dotted-quad notation, and an IPv4 subnet in CIDR notation, determine if the address is in the subnet. Output a distinct and consistent value if it is in the subnet, and a separate distinct and consistent value if it is not in the subnet. The output values do not necessarily need to be truthy/falsey in your language.
CIDR subnet notation brief primer
IPv4 network addresses are 32 bits in length, split into four groups of 8 bits for ease of reading. CIDR subnet notation is a mask of the specified number of bits, starting leftmost. For example, for a /24 subnet, this means the right-most 8 bits of the address are available in that subnet. Thus two addresses that are separated by at most 255, and have the same subnet mask, are in the same subnet. Note that valid CIDR have all the host-bits (the right hand side) unset (zeros).
xxxxxxxx xxxxxxxx xxxxxxxx 00000000
^---    subnet mask   ---^ ^-hosts-^

For another example, a /32 subnet specifies that all of the bits are the subnet mask, essentially meaning that only one host is allowed per /32.
xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
^---        subnet mask        ---^

Examples:
Using True for "in the subnet" and False for "not in the subnet" as output:
127.0.0.1
127.0.0.0/24
True

127.0.0.55
127.0.0.0/23
True

127.0.1.55
127.0.0.0/23
True

10.4.1.33
10.4.0.0/16
True

255.255.255.255
0.0.0.0/0
True

127.1.2.3
127.0.0.0/24
False

127.1.2.3
127.1.2.1/32
False

10.10.83.255
10.10.84.0/22
False

Rules and Clarifications

Since input parsing isn't the interesting point of this challenge, you're guaranteed to get valid IPv4 addresses and subnet masks.
Input and output can be given by any convenient method.
You can print the result to STDOUT or return it as a function result. Please state in your submission what values the output can take.
Either a full program or a function are acceptable.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Do we have to take input in the same format as your test cases?

@EmbodimentofIgnorance You don't have to take them as one-per-line as in the examples, but you do need to take them as a dotted-quad and dotted-subnet as in the examples. (e.g., see the JavaScript answer by Arnauld)

Is it ok to have them separated by a slash, e.g. 10.0.0.1/10.0.0.0”/16?

@NickKennedy (I'm presuming that the " is unintentional) Sure, separating by / is fine.

@AdmBorkBork yes typo. Thanks

I would argue that 1.255.1.1/8 is a valid CIDR subnet but it requires more work to get the netmask. I don't think that's restricted anywhere and most tooling with subnets will do this normalization for you. If that's something we're marking as "not needed for this challenge", that's fine.

@Poke I agree you are correct in that CIDR notation describes an IP address and a subnet size.  As in, 1.255.1.1/8 is a valid CIDR expression, representing the host 1.255.1.1 within the network 1.0.0.0 with a subnet mask of 255.0.0.0. However the challenge asks for the network number and subnet specifically in CIDR notation, which 1.255.1.1/8 is not a valid network number and subnet combination.

Now we also need an IPv6 version of this challenge

Your 2 separate values output requirement excludes 0 vs. non-zero.  Is that intentional?  In some languages, like C or asm, it's more convenient to return any non-zero integer as "truthy".  e.g. for this problem (host ^ mask) >> (32 - bits) to shift out the host part, leaving zero iff the host matches the network part of the mask.  (Modulo handling bits=0)

@PeterCordes Yes, that's intentional. People tend to complain a lot about truthy-vs-falsey challenges, so that's the best compromise I've come up with.

Ok, well for some languages it's the opposite of helpful, but that's fine as long as you're aware of the consequences.  Some real functions do have to booleanize their output to 0 or 1 instead of 0 / non-zero.

Python 3 (62 bytes)
Very straightforward:
from ipaddress import*
lambda i,m:ip_address(i)in ip_network(m)

Nice, but does python have a built-in for recognizing goats as well?

Of course Mathematica has a build-in for everything - even for exoplanets! Nothing can beat that... But as you could have seen, Python matches Mathematica's goat-formace

I wonder if does a ip_adress object and a ip_network object constitute any convenient method, possibly letting Python win, unless a python-based golfing language has these as its types?

You won't get it in the range of 20 bytes in normal Python. Only the import and lambda are already longer than the Stax answer. It's no surprise that golfing languages win from "normal" languages... :-(

@someone: I beat Python with 53 bytes of x86-64 machine code.  :) Not a traditional golfing language, and most of the code-size is parsing string->int manually.  (host^net)>>(32-mask) is only 10 bytes.  But it's half way in between for tasks not involving lists of lists, or mapping a function onto a list, because many scalar operations can be done with a 2 or 3 byte instruction, and loops can be constructed around things in a few bytes.

C# (Visual C# Compiler), 250+31=281 bytes
(a,b)=>{Func<string,string>h=g=>string.Join("",g.Split('.').Select(x=>{var e=Convert.ToString(int.Parse(x),2);while(e.Length<8)e='0'+e;return e;}));a=h(a);var c=b.Split('/');b=h(c[0]);var d=int.Parse(c[1]);return a.Substring(0,d)==b.Substring(0,d);};

Bytecount includes using System;using System.Linq;
Try it online!
I wrote this in JS as soon as the challenge was posted, but Arnauld beat me to the punch with a much better answer, so here it is in C# instead.
Definitely a lot of room for golfing.
Explanation:
The function consists of a sub-function called h:
h=g=>string.Join("",
    g.Split('.').Select(x => {
        var e = Convert.ToString(int.Parse(x), 2);
        while (e.Length < 8) e = '0' + e;
        return e;
    }
);

This sub-function splits the IP Address on ., converts each number to a binary string, left-pads each string with 0 to be 8 bits long, then concatenates the strings into one 32-bit binary string.
This is immediately done in-place with a=h(a); on the given IP Address.
We then split the Subnet mask into an IP Address and a mask number with c=b.Split('/');
The IP Address component is also passed through our sub-function: b=h(c[0]); and the mask number is parsed to an integer: var d=int.Parse(c[1]);
Finally we take the first d bits of both binary strings (where d is the mask number) and compare them: return a.Substring(0,d)==b.Substring(0,d);

Too tired to work this out so I just Golfed yours for you

Actually forgot about PadLeft in that too Try it online!

Lots of optimizations. I'm happy to inform you that your rPad is a built-in on strings. pastebin link to TIO link that is too long alone

@someone Small FYI: URL shorteners like https://tinyurl.com/ are allowed in comments on this SE, unlike most. :)

188 - https://tinyurl.com/y6xfkbxt - nice url shortening tips @KevinCruijssen

184 :) https://tinyurl.com/y6qnx2cc

Linux POSIX shell (with net-tools/iputils) (34 bytes non-terminating, 47 bytes terminating)
What is best suited to parse network masks and addresses than the network utilities themselves? :)
route add -net $2 reject;! ping $1

Warning: the script is potentially damaging to your Internet connectivity, please run with care.
Input: the script takes the tested IP address as first argument, and the tested subnet. as second argument.
Output: the script returns a truthy value (0) if the first argument of the script belongs to the subnet indicated in the second argument. Otherwise, it will never terminate.
Assumptions: the script must be run as a root user, in a clean environment (i.e., no other blackhole route has been set by the administrator, and if a previous instance of the script has been run, the blackhole route it created has been removed). The script also assumes a "working Internet connection" (i.e., a valid default route is present).

Explanation:
We create a blackhole route to the specified subnet. We then test connectivity to the provided IP address by using ping. If the address doesn't belong to the subnet (and since we assume a properly set Internet connection), ping will try to send packets to that address. Note that whether this address actually responds does not matter, as ping will keep trying forever. Conversely, if the address does belong to the subnet, ping will fail with ENETUNREACH and return 2, and since we negated the command, the script will succeed.

Example
Test whether 5.5.5.5 belongs to 8.8.8.0/24
$ sudo ./a.sh 5.5.5.5 8.8.8.0/24
PING 5.5.5.5 (5.5.5.5) 56(84) bytes of data.
[...runs forever...]

(Clean with sudo ip route del 8.8.8.0/24 after running the command).
Test whether 5.5.5.5 belongs to 5.5.5.0/24:
$ sudo ./a.sh 5.5.5.5 5.5.5.0/24
connect: Network is unreachable
$ echo $?
0

(Clean with sudo ip route del 5.5.5.0/24 after running the command).
Test whether 8.8.8.8 belongs to 5.5.5.0/24:
$ sudo ./a.sh 8.8.8.8 5.5.5.0/24
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=122 time=2.27 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=122 time=1.95 ms
[...runs forever...]

(Clean with sudo ip route del 5.5.5.0/24 after running the command).

47-byte version if we disallow non-terminating scripts
route add -net $2 reject;ping -c1 $1;[ $? = 2 ]

As per @Grimy's comment, here's the version which always terminates, and returns 0 (truthy) if the address is in the subnet, and 1 (falsy) otherwise. We make ping terminate with the -c1 flag which limits the number of sent packets to 1. If the address responded, ping will return 0, and if not, ping will return 1. Only if the address belongs to the blackholed subnet will ping return 2, which is thus what we test against in the last command.

While clever, this doesn't meet the requirement to output a distinct and consistent value if the address is not in the subnet (running forever doesn't count as an output, see also this).

@Grimy: But it doesn't silently run forever, so only your 2nd link applies, not the first.  Also I think ping would die from SIGPIPE if it was running with stdout+stderr piped into another program, and the reader closed the pipe.  And that is the most likely use-case because the exit status can be success either way (if we added a -c1 option to ping to set the count.)  But sure, reading its output with var=$(/a.sh) would fail; you'd need a reader that stopped after deciding, rather than reading the whole output and then looking at it.

@Grimy Fair point (although for the sake of the argument I could say that we have two consistent values here, since ping will terminate in less than, say, one second in case of a blackholed address). I added a terminating version for an extra 13 bytes! :)

JavaScript (ES6), 82 bytes
Takes input as (address)(subnet). Returns a Boolean value.
a=>s=>!([s,v]=s.split`/`,+v&&(g=s=>s.split`.`.map(k=v=>k=k<<8|v)|k>>32-v)(a)^g(s))

Try it online!

PHP, 101 92 88 bytes
-13 bytes from @gwaugh
function($i,$r){[$r,$n]=explode('/',$r);return(ip2long($i)&~(1<<32-$n)+1)==ip2long($r);}

Try it online!

Had some fun golfing it (Ty!): function($i,$r){return!((ip2long($i)^ip2long(strtok($r,'/')))>>32-strtok(_));}

@Christoph very nice! Never occurred to me that you could just use any token for the second call to strtok(). Yours is 4 bytes shorter than my very similar answer below. Props!

@Christoph You should post your solution as a separated answer since it is better than mine.

PowerPC/PPC64 C, 116 114 bytes
#include<stdio.h>
main(){unsigned u[4];char*p=u;for(;p<u+3;)scanf("%hhu%c",p++,u+3);return!((*u^u[1])>>32-p[-4]);}

(Tested on x86_64 Ubuntu 18.04 using powerpc64-linux-gnu-gcc -static and qemu-user.)
The program takes the two lines on standard input, and as its exit code it returns 1 if the address matches and 0 if it does not.  (So this does depend on the specification not requiring a truthy value for a match and a falsey value for a mismatch.)  Note that if you're running interactively, you will need to signal EOF (^D) three times after entering the second line.
This relies on PowerPC being big-endian, and also on that platform returning 0 for right-shifting a 32-bit unsigned value by 32.  It reads the octets into unsigned values one-by-one, along with the netmask length in another byte; then it takes the xor of the two unsigned 32-bit addresses and shifts out the irrelevant bits.  Finally, it applies ! to satisfy the requirement of returning only two distinct values.
Note: It might be possible to shave off two bytes by replacing u+3 with p and requiring compilation with -O0.  That's living more dangerously than I care to, though.
Thanks to Peter Cordes for the inspiration for this solution.

More portable C, 186 171 167 bytes
Here I'll preserve a more portable version which runs 167 bytes.
#include<stdio.h>
main(){unsigned a,b,c,d,e,f,g,h,n;scanf("%u.%u.%u.%u %u.%u.%u.%u/%u",&a,&b,&c,&d,&e,&f,&g,&h,&n);return!(n&&((((a^e)<<8|b^f)<<8|c^g)<<8|d^h)>>32-n);}

This program takes the two lines on standard input, and returns exit code 1 if the address is in the subnet, and 0 if it isn't.  (So this does rely on the specification not requiring a truthy value for matches and a falsey value for non matches.)
A breakdown of the core expression:

a^e, b^f, c^g, d^h calculates the xor of the address and the mask byte-by-byte.
(((a^e)<<8|b^f)<<8|c^g)<<8|d^h then combines them into a single unsigned 32-bit value by a Horner-like method.
...>>32-n then shifts off the bits of the xor difference that are not relevant to the subnet mask (keeping in mind that - has higher precedence in C than <<)
There is one gotcha, though: if n=0 then ~0U<<32 will give undefined behavior assuming unsigned is 32 bits (which it is on virtually all current platforms).  On the other hand, if n=0 then any address will match, so n&&... will give the correct result (taking advantage of the short-circuiting behavior of &&).
Finally, to meet the requirement that the output can only be one of two values, we apply ! to output 0 or 1.

-15 bytes due to comments by ceilingcat and AdmBorkBork
-4 bytes due to comment by Peter Cordes

Using exit codes to return values is one of the default I/O methods and is thus allowed.

@ceilingcat Of course, how silly of me to miss that.

@AdmBorkBork OK, thanks, I've changed it to use exit code.

idea: target a little-endian or big-endian C implementation (code-golf doesn't require portable code) and type-pun output pointers onto the bytes of an unsigned.  e.g. with char*p=&a then p++,p++,p++,... or p--,... as scanf args.  The format string would need to be "%hhu.%hhu..." though, so it's a significant tradeoff between that extra size vs. declaring fewer vars and being able to do (a^b)>>(32-count)

Can't you use xor_result >> 32-count to shift out the bits you don't want, instead of left-shifting a mask?  Heh, interesting n&&... trick to avoid UB by not evaluating an out-of-range shift count.  In practice, some platforms (like I think ARM) saturate the shift count (i.e. will shift out all the bits for count too large), but x86's scalar shift instructions mask the shift count with &31.  (Or &63 for 64-bit shifts)  See Best practices for circular shift (rotate) operations in C++ for details.

So anyway, you might get away with (...)>>32-count on a C implementation targeting ARM, without the n&& part.  Code Golf rules say that it has to work on some implementation, not all.  (Some people stretch that as far as leaving out the return keyword for gcc -O0, but that just isn't even C anymore.)

In my x86-64 machine-code answer, I used (host^net) >> (32-mask) using a 64-bit shift.  If you cast to long, it should work for free on C implementations where long is 64-bit.  Or use long long for portability.  All your numbers end up much narrower than 64-bit, so they're definitely positive and thus no UB or weirdness for signed right shifts, but you can't just change your variables to long because the format string is for unsigned int. :/

@PeterCordes Yup, the right shift works, thanks.

@PeterCordes With a loop of the type you were suggesting I did get an x86-64/x86 specific solution with 128 bytes.  (More specifically, it requires a little-endian platform which allows unaligned access to unsigned.)  It's significantly different, though, so I'm debating whether to post it as a separate answer or to completely replace the current one.

Oh good point, I might go separate answer if it's totally different.  Although separate sections of the same answer like you did here works, too.  Use a 2nd # header line for the portable version, though.  But unaligned access to unsigned?  I only see access to the bytes separately.  Every byte is always naturally aligned.

@PeterCordes Well, my solution at that point had an array of 9 characters and then read out characters 1-4 and 5-8 as the unsigned values and character 0 as the netmask length.  Since then, I found that switching to big-endian gave a yet shorter solution.

Ah neat, good idea little endian handling.  Hmm, that might be a win for my asm version, removing a level of loop nesting and doing 9 string->byte conversion!  But in C, you may be violating strict aliasing as well, unless you used a union. :)  Fun fact that you probably already know: safe/portable unaligned aliasing-safe loads can be done with memcpy(&my_unsigned, p, sizeof(unsigned)), so it is possible to write ungolfed code like that which compiles efficiently when unaligned loads are available.

Maybe you missed the late edit in a prev comment: I'd suggest using a 2nd #header line for the portable C version, to really present it as a separate solution in the same answer.

Stax, 22 bytes
é.○▄╗jF⌐§╥§I╓☻lw«ç┴║╫┼

Run and debug it
It takes the input parameters space-separated on standard input.
Unpacked, ungolfed, and commented, it looks like this.
'/:/~       split on slash and push the last group back to the input stack
j{          split on space; for each group, run this code block
  './       split on period
  {emVB|E   evaluate integers and decode integer as base-256
  ;e|<      peek from input stack and shift left
  Vu/       integer divide by 2^32
F           end of for-each
=           two values left on stack are equal?

Run this one

x86-64 machine code function, 53 48 bytes
changelog:

-2 jz over the shift instead of using a 64-bit shift to handle the >>(32-0) special case.
-3 return in ZF instead of AL, saving 3 bytes for a setnz al.

(See also Daniel Schepler's 32-bit machine code answer based on this, which then evolved to use some other ideas we had.  I'm including my latest version of that at the bottom of this answer.)

Returns ZF=0 for host not in subnet, ZF=1 for in subnet, so you can branch on the result with je host_matches_subnet
Callable with the x86-64 System V calling convention as
bool not_in_subnet(int dummy_rdi, const char *input_rsi); if you add in setnz al.
The input string contains both the host and network, separated by exactly 1 non-digit character.  The memory following the end of the CIDR width must contain at least 3 non-digit bytes before the end of a page.  (Shouldn't be a problem in most cases, like for a cmdline arg.)  Daniel's 32-bit version doesn't have this limitation.
We run the same dotted-quad parse loop 3 times, getting the two IPv4 addresses, and getting the /mask as an integer in the high byte of a dword.  (This is why there has to be readable memory after the /mask, but it doesn't matter if there are ASCII digits.)
We do (host ^ subnet) >> (32-mask) to shift out the host bits (the ones allowed to mismatch), leaving only the difference between the subnet and the host.  To solve the /0 special case where we need to shift by 32, we jump over the shift on count=0.  (neg cl sets ZF, which we can branch on and leave as the return value if we don't shift.)  Note that 32-mask mod 32 = -mask, and x86 scalar shifts mask their count by & 31 or & 63.
    line  addr   machine                NASM source.  (from nasm -felf64 -l/dev/stdout)
    num          code bytes

     1                             %use smartalign
     2
     3                                 ;10.4.1.33 10.4.0.0/23         true
     4                                 ;10.4.1.33 10.4.0.0/24         false
     5
     6                             ;; https://codegolf.stackexchange.com/questions/185005/im-in-your-subnets-golfing-your-code
     7                             %ifidn __OUTPUT_FORMAT__, elf64
     8                             in_subnet:
     9
    10 00000000 6A03                   push 3
    11 00000002 5F                     pop  rdi                    ; edi = 3 dotted-quads to parse, sort of.
    12                             .parseloop:
    13
    14                                 ;xor  ebx,ebx             ; doesn't need to be zeroed first; we end up shifting out the original contents
    15                                 ;lea  ecx, [rbx+4]
    16 00000003 6A04                   push   4
    17 00000005 59                     pop    rcx                  ; rcx = 4 integers in a dotted-quad
    18                             .quadloop:
    19
    20 00000006 31D2                   xor   edx,edx               ; standard edx=atoi(rdi) loop terminated by a non-digit char
    21 00000008 EB05                   jmp  .digit_entry
    22                              .digitloop:
    23 0000000A 6BD20A                 imul   edx, 10
    24 0000000D 00C2                   add    dl, al
    25                              .digit_entry:
    26 0000000F AC                     lodsb
    27 00000010 2C30                   sub    al, '0'
    28 00000012 3C09                   cmp    al, 9
    29 00000014 76F4                   jbe   .digitloop
    30                                 ; al=non-digit character - '0'
    31                                 ; RDI pointing to the next character.
    32                                 ; EDX = integer
    33
    34 00000016 C1E308                 shl    ebx, 8
    35 00000019 88D3                   mov    bl, dl               ; build a quad 1 byte at a time, ending with the lowest byte
    36 0000001B E2E9                   loop .quadloop
    37
    38 0000001D 53                     push   rbx          ; push result to be collected after parsing 3 times
    39 0000001E FFCF                   dec    edi
    40 00000020 75E1                   jnz   .parseloop
    41
    42 00000022 59                     pop    rcx   ; /mask  (at the top of a dword)
    43 00000023 5A                     pop    rdx   ; subnet
    44 00000024 58                     pop    rax   ; host
    45 00000025 0FC9                   bswap  ecx   ; cl=network bits  (reusing the quad parse loop left it in the high byte)

    49 00000027 F6D9                   neg    cl
    50 00000029 7404                   jz   .all_net     ; skip the count=32 special case
    51
    52 0000002B 31D0                   xor    eax, edx   ; host ^ subnet
    53 0000002D D3E8                   shr    eax, cl    ; shift out the host bits, keeping only the diff of subnet bits
    54
    55                             .all_net:
    56                                ; setnz  al         ; return ZF=1 match,  ZF=0 not in subnet
    57 0000002F C3                     ret
    58 00000030 30                 .size:      db $ - in_subnet

              0x30 = 48 bytes

(not updated with latest version)
Try it online!
including a _start that calls it on argv[1] and returns an exit status.
## on my desktop
$ ./ipv4-subnet "10.4.1.33 10.4.0.0/24"    && echo "$? : in subnet" || echo "$? : not in subnet"
not in subnet

$ ./ipv4-subnet "10.4.1.33 10.4.0.0/23"    && echo "$? : in subnet" || echo "$? : not in subnet"
in subnet

It works fine if you pass a command line arg containing a newline instead of a space.  But it has to be instead, not as well.

x86 32-bit machine code function, 38 bytes
Do 9 integer -> uint8_t parses and "push" them on the stack, where we pop them off as dwords or use the last one still in CL.  Avoids reading past the end of the string at all.
Also, dec is only 1 byte in 32-bit mode.
    72                             in_subnet:
    73 00000000 89E7                   mov   edi, esp
    74 00000002 51                     push  ecx
    75 00000003 51                     push  ecx                   ; sub esp,8
    76                             .byteloop:
    77
    78 00000004 31C9                   xor   ecx,ecx               ; standard ecx=atoi(rdi) loop terminated by a non-digit char
    79                                                             ; runs 9 times: 8 in two dotted-quads, 1 mask length
    80 00000006 EB05                   jmp  .digit_entry
    81                              .digitloop:
    82 00000008 6BC90A                 imul   ecx, 10
    83 0000000B 00C1                   add    cl, al
    84                              .digit_entry:
    85 0000000D AC                     lodsb
    86 0000000E 2C30                   sub    al, '0'
    87 00000010 3C09                   cmp    al, 9
    88 00000012 76F4                   jbe   .digitloop
    89                                 ; RDI pointing to the next character.
    90                                 ; EDX = integer
    91
    92 00000014 4F                     dec    edi
    93 00000015 880F                   mov    [edi], cl           ; /mask store goes below ESP but we don't reload it
    94 00000017 39E7                   cmp    edi, esp
    95 00000019 73E9                   jae   .byteloop
    96
    97                                 ;; CL = /mask still there from the last conversion
    98                                 ;; ESP pointing at subnet and host on the stack, EDI = ESP-1
    99
   100 0000001B 5A                     pop    edx   ; subnet
   101 0000001C 58                     pop    eax   ; host
   102
   103 0000001D 31D0                   xor    eax, edx             ; host ^ subnet
   104 0000001F F6D9                   neg    cl                   ; -mask = (32-mask) mod 32;  x86 shifts mask their count
   105 00000021 7402                   jz     .end                 ; 32-n = 32 special case
   106 00000023 D3E8                   shr    eax, cl
   107                             .end:
   108                                 ; setz  al                  ; just return in ZF
   109 00000025 C3                     ret

   110 00000026 26                 .size:      db $ - in_subnet
      0x26 = 38 bytes

Test caller
   113                             global _start
   114                             _start:
   115 00000027 8B742408               mov    esi, [esp+8]   ; argv[1]
   116 0000002B E8D0FFFFFF             call   in_subnet
   117 00000030 0F95C3                 setnz  bl
   118 00000033 B801000000             mov    eax, 1         ; _exit syscall
   119 00000038 CD80                   int    0x80

I'm curious how the 32-bit asm byte count would go if instead of the cmp/jcc that you mentioned you did something like xor edx,edx;neg cl;cmovz eax,edx;shr eax,cl - or maybe you already have a 0 value hanging around somewhere.  (And then you wouldn't need the sub cl,32 instruction.)

Yup, looks like edi should be 0 when the loop exits, so xor eax,edx;neg cl;cmovz eax,edi;shr eax,cl should work.

If I counted things right, cmove eax,edi has 3 bytes which is a wash over the removed sub cl,32 then shr cl,eax saves one byte over shr cl,rax and 32-bit dec edi saves one byte over 64-bit dec edi.  My assembly then gives .byte 0x33 (in GNU binutils syntax) = 51 for in_subnet.size.

Nice idea, thanks.  (In Intel syntax it's shr eax,cl, vs. shr %cl, %eax in AT&T syntax, your last comment reversed that.)  It's a bit of a chore to update machine-code answers (and port the _start caller and re-describe the calling convention for 32-bit mode...), so I might not get around to it.  Feeling lazy today. >.<

Oh right, forgot about the different calling convention.  If we wanted to keep it SysV ABI compliant then the additional mov esi,[esp+4] would wipe out the savings and then some.

@DanielSchepler: oh, I didn't mean in the code, I meant in the text of the answer.  Being callable from C is merely a bonus, this is an asm / machine-code answer.  I have no problem with a 32-bit function that happens to clobber all the registers except ESP, and takes an arg in ESI.  See my answer on Tips for golfing in x86/x64 machine code.  It would need a wrapper to be testable from C, but my _start caller would be easy to port.

I just tried implementing the comment you put on my answer about getting rid of the double loop and instead storing into stack variables - and even with the extra code to initialize the write pointer in edi, write the output, etc. it ended up saving 2 bytes in net.  (At least once I realized push ecx;push ecx;push ecx was shorter than sub esp,12; and it seemed to be a wash whether I predecremented edi and used std;stosb;cld or whether I just stored using dec edi;mov [edi],al.

@DanielSchepler: x86-64 SysV has a red-zone below RSP.  Maybe you can justify a 32-bit calling convention with a red-zone to avoid reserving.  But I guess you want to reload it with pop anyway.  sub esp,12 is a 3-byte instruction, same as 3x push, but maybe your saving came elsewhere?  Anyway, sounds like you could post that as a separate answer; I'd like to see it since you've already put in the work to sort out the details.

Hmm, I must have been miscounting or accidentally using 64-bit compilation (where of course the byte-by-byte storing won't work as well with pop if at all).  You're right, sub esp,12 is the same length.  And on top of that, now that I built it again in 32-bit mode I get a total of 47 bytes, making 5 bytes saved in addition to the 1 byte from the cmovz revision.  I haven't actually run the new code to test it, though.

@DanielSchepler: yeah, instead of pop in 64-bit mode I was thinking lodsb /xchg eax,ecx for the count, and lodsd / xchg eax,edx / lodsd (so 5 bytes total, not moving RSP).  32-bit pop is not encodeable in 64-bit mode, only 16 (operand-size prefix) or 64-bit (no prefix).  A REX.W=0 prefix doesn't actually reduce the operand-size to 32 for instructions where the default operand-size is 64.  But 32-bit mode to enable dword pop is probably even better.

(And BTW, after a 64-bit pop, your options include shld rdx, rax, 32, or for performance to avoid a false dependency, rorx rdx, rax, 32, or mov / shr.  But 64-bit mov r64,r64 is 3 bytes, while push/pop is only 2, so you might win by push rax/pop rdx/shr rdx,32.  Probably most golfy to just use lodsd instead of pop)

Posted my revised version: https://codegolf.stackexchange.com/questions/185005/im-in-your-subnets-golfing-your-code/185139#185139

@DanielSchepler: updated the 64-bit version, and included the 32-bit version I posted in a comment under your answer.

PHP, 75 73, 71 bytes
<?=strtok($argv[2],'/')==long2ip(ip2long($argv[1])&1+~1<<32-strtok(_));

A fork of @Luis felipe De jesus Munoz's answer, as a standalone taking input from command line args.  Outputs '1' for Truthy, '' (empty string) for Fasley.
$ php ipsn.php 127.0.0.1 127.0.0.0/24
1
$ php ipsn.php 127.1.2.3 127.0.0.0/24

Try it online!
-2 bytes borrowing @Christoph's little trick for strtok(). His answer is still shorter though!

Jelly, 23 bytes
ṣ”/ṣ€”.Vḅ⁹s2+Ø%BḊ€ḣ€ʋ/E

Try it online!
Monadic link that takes a the address and subnet separated by a slash and returns 1 for true and 0 for false.
Thanks to @gwaugh for pointing out a flaw in the original - it failed to ensure the binary list was 32 long.

Charcoal, 36 bytes
≔⪪Ｓ/θ≔Ｉ⊟θζ⊞θＳＵＭθ÷↨Ｉ⪪ι.²⁵⁶Ｘ²⁻³²ζ⁼⊟θ⊟θ

Try it online! Link is to verbose version of code. Takes the subnet as the first parameter and and outputs - only if the address lies within the subnet. Explanation:
≔⪪Ｓ/θ

Split the subnet on /.
≔Ｉ⊟θζ

Remove the mask and cast it to integer.
⊞θＳ

Push the address to the array.
ＵＭθ÷↨Ｉ⪪ι.²⁵⁶Ｘ²⁻³²ζ

Split both addresses on ., convert them to integers, interpret as base 256, and discard the masked bits.
⁼⊟θ⊟θ

Compare the two values.

Perl 5 -Mbigint -MSocket=:all -p, 72 bytes
sub c{unpack N,inet_aton pop}<>=~/(.*)\/(.*)/;$_=c($_)-&c($1)<2**(32-$2)

Try it online!

05AB1E, 21 bytes
'/¡`U‚ε'.¡b8jð0:JX£}Ë

Takes the subnet before the address.
Try it online or verify all test cases.
Explanation:
'/¡              '# Split the first subnet-input by "/"
   `              # Push both values separated to the stack
    U             # Pop and store the trailing number in variable `X`
    ‚             # Pair the subnet-IP with the second address-input
     ε            # Map both to:
      '.¡        '#  Split on "."
         b        #  Convert each integer to binary
          8j      #  Add leading spaces to make them size 8
          ð0:     #  And replace those spaces with "0"
             J    #  Join the four parts together to a single string
              X£  #  And only leave the first `X` binary digits as substring
     }Ë           # After the map: check if both mapped values are the same
                  # (which is output implicitly as result)

R     120 bytes
a function - I pasted ".32" to first term
w=function(a,b){f=function(x)as.double(el(strsplit(x,"[./]")));t=f(paste0(a,".32"))-f(b);sum(t[-5]*c(256^(3:0)))<2^t[5]}
and just for fun:
require("iptools");w=function(a,b)ips_in_cidrs(a,b)[[2]]
which is 56 bytes

Java 215 211 207 202 200 199 198 190 180 bytes
Long k,c;boolean a(String i,String s){return(b(i)^b(s))>>32-k.decode(s.split("/")[1])==0;}long b(String i){for(c=k=0l;c<4;k+=k.decode(i.split("[./]")[3+(int)-c])<<8*c++);return k;}

Outputs true for truthy and false for falsy.
Note: This uses long instead of int for the potential right shift of 32.
Try it online!
Saved 1 byte thanks to ceilingcat
Saved 10 bytes thanks to Peter Cordes

This doesn't output a "distinct and consistent value" for falsey.

I'd argue that it's distinctly and consistently non-zero but if that's not the spirit of the challenge, I can change it.

A 64-bit integer supports left-shifts by 32.  Also, you can right shift host ^ net to shift out the bits you want to remove, instead of actually creating a mask.  But I guess Java needs a compare in there to create a boolean from an integer.  Maybe a !, because it doesn't matter which of true or false you produce for which output.  (I asked the OP for clarification about whether they intended to exclude 0 / non-zero, and they said yes they were aware of the consequences of that wording:

@PeterCordes Converting everything to long does lose me some bytes but I make up for it by being able to remove the ternary and doing the XOR as you suggest. I'm checking what else I can golf before posting

x86 assembly function, 49 43 bytes
This is mostly posted to satisfy Peter Cordes's request for the revised version I created.  It can probably go away once/if he incorporates it into his answer.
This function expects esi to point to an input string, with the address and subnet parts separated either by a space or a newline character, and the return value is in the ZF flag (which by definition has only two possible values).
 1                                  %use smartalign
 2
 3                                      ;10.4.1.33 10.4.0.0/23         true
 4                                      ;10.4.1.33 10.4.0.0/24         false
 5
 6                                  ;; https://codegolf.stackexchange.com/questions/185005/im-in-your-subnets-golfing-your-code
 7                                  in_subnet:
 8
 9                                      ;xor  ebx,ebx             ; doesn't need to be zeroed first; we end up shifting out the original contents
10                                      ;lea  ecx, [rbx+4]
11 00000000 6A09                        push   9
12 00000002 59                          pop    ecx                  ; ecx = 9 integers (8 in two dotted-quads,
13                                                                  ; 1 mask length)
14
15 00000003 89E7                        mov   edi, esp
16 00000005 83EC0C                      sub   esp, 12
17                                  .quadloop:
18
19 00000008 31D2                        xor   edx,edx               ; standard edx=atoi(rdi) loop terminated by a non-digit char
20 0000000A EB05                        jmp  .digit_entry
21                                   .digitloop:
22 0000000C 6BD20A                      imul   edx, 10
23 0000000F 00C2                        add    dl, al
24                                   .digit_entry:
25 00000011 AC                          lodsb
26 00000012 2C30                        sub    al, '0'
27 00000014 3C09                        cmp    al, 9
28 00000016 76F4                        jbe   .digitloop
29                                      ; al=non-digit character - '0'
30                                      ; RDI pointing to the next character.
31                                      ; EDX = integer
32
33 00000018 4F                          dec    edi
34 00000019 8817                        mov    [edi], dl
35 0000001B E2EB                        loop .quadloop
36
37 0000001D 59                          pop    ecx   ; /mask  (at the top of a dword)
38 0000001E 5A                          pop    edx   ; subnet
39 0000001F 58                          pop    eax   ; host
40 00000020 0FC9                        bswap  ecx   ; cl=network bits  (reusing the quad parse loop left it in the high byte)
41
42                                  ;    xor    cl, -32    ; I think there's some trick like this for 32-n or 31-n, but maybe only if we're masking to &31?  Then neg or not work.
43
44 00000022 31D0                        xor    eax, edx   ; host ^ subnet
45                                  ;    xor    edx, edx   ; edx = 0
46 00000024 F6D9                        neg    cl
47 00000026 7402                        jz     .end
48 00000028 D3E8                        shr    eax, cl    ; count=32 special case isn't special for a 64-bit shift
49                                  .end:
50 0000002A C3                          ret
51 0000002B 2B                      .size:      db $ - in_subnet

And the x86 Linux wrapper part:
53                                  global _start
54                                  _start:
55 0000002C 8B742408                    mov    esi, [esp+8]   ; argv[1]
56 00000030 E8CBFFFFFF                  call   in_subnet
57 00000035 0F95C0                      setnz  al
58 00000038 0FB6D8                      movzx  ebx, al
59 0000003B B801000000                  mov    eax, 1         ; _exit syscall
60 00000040 CD80                        int    0x80

-6 bytes due to suggestion from Peter Cordes to return the value in ZF.

I guess I could save one byte by removing the last xor edx,edx and replacing cmovz eax,edx with jz .nonzero; xor eax,eax; .nonzero:.  cmovz still wins if we have calling convention ebx=0.

Can we just jz over the shr to the setz or the ret?  We can swap the setnz to setz and return 1 for a match if that helps.  Or even say that our return value is ZF.  I should have done that in my answer.  (But I don't think we can justify requiring the caller to create constants for us, like ebx=0.  My answer on Tips for golfing in x86/x64 machine code argues that would be stretching a custom calling convention too far.

BTW, I use cut to remove some columns from the NASM listing output because all my instructions are short:  nasm -felf foo.asm -l/dev/stdout | cut -b -34,$((34+6))-.  Also, I used mov instead of movzx in my _start caller because the exit status comes from the low byte of the arg to sys_exit().  The kernel ignores the higher bytes.

I guess that would work.  That takes the count down to 43 bytes and then I insert setnz al after call in_subnet in the wrapper.

Yup.  Easy to imagine the normal use case for this function would be call/je, rather than printing or further passing along the result.  Like I pointed out in the "tips", some system-call calling conventions already do this in real life (usually with CF=error).

I reworked your loop to use cmp edi, esp / jae instead of loop, leaving the last conversion in CL so we don't need to pop / bswap it, or even mov cl,dl.  And we drop the push 9 / pop ecx, and reduce sub esp,12 to 2x push ecx.  https://godbolt.org/z/j-brRj  38 bytes.  And I cleaned up the comments to fit this version.  Tested for 10.4.1.33 10.4.0.0/23 vs. /24.  I think I'll keep my answer with the 64-bit version, and this answer has evolved into its own strategy that's arguably different enough to stand alone, as well as being for a different x86 mode.

Japt, 26 bytes
Ëq'/
ËÎq. Ë°¤ù8Ã¬¯Ug1,1Ãr¶

Try it
-3 bytes thanks to @Shaggy!
Input is an array with 2 elements [address, subnet]. Transpiled JS below:
// U: implicit input array
// split elements in U on the / and
// save back to U using a map function
U = U.m(function(D, E, F) {
  return D.q("/")
});
// map the result of the previous operation
// through another function
U.m(function(D, E, F) {
  return D
    // get the address portion of the / split
    // value and split again on .
    .g().q(".")
    // map each octet through another function
    .m(function(D, E, F) {
      // convert the octet to a base 2 string
      // left padded to a length of 8
      return (D++).s(2).ù(8)
    })
    // join the base 2 octets
    .q()
    // take the left bits of the joined octets
    // determined by subnet size
    .s(0, U.g(1, 1))
})
  // at this point, the intermediate result
  // contains 2 masked values, reduce
  // using === to check for equality
  .r("===")

26 bytes

Interesting - I didn't realize you could coerce a string to a number with ++.

Yup, just like you can in JS. It's no use, though, if you need to resuse the original value later on, though, but it is handy on occasion.

The need for the comma in the g method is annoying me; can't figure out a way around it at all. At least not one that'll save you a byte.

C# (Visual C# Interactive Compiler), 187 bytes
a=>{var b=a.Select(x=>x.Split(".").SelectMany(g=>Convert.ToString(int.Parse(g.Split("/")[0]),2).PadLeft(8)).Take(int.Parse(a[1].Split("/")[1])));return b.First().SequenceEqual(b.Last());}

I can definitely golf this down more.
Try it online!

Ruby (48 bytes)
require 'ipaddr'
lambda{|a,m|IPAddr.new(m)===a}

You can remove the whitespace around ====

C# (Visual C# Interactive Compiler), 134 bytes
a=>a.Select(x=>x.Split('.','/').Take(4).Aggregate(0L,(y,z)=>y<<8|int.Parse(z))>>32-int.Parse(a[1].Split('/')[1])).Distinct().Count()<2

Try it online!
LINQ statement that takes a 2-element string array as input in [address, subnet] format.
Each dotted quad is converted into 32 bits of a long using bit manipulation. The bits are right shifted by the subnet size and elements are compared for equality.
There were a couple of C# answers at the time that this answer was posted, but none that used pure bit manipulation.
// a: input array containing address and subnet
a=>a
  // iterate over input elements
  .Select(x=>x
    // split element on . and /
    .Split('.','/')
    // the subnet will have 5 elements,
    // we only want the parts before the /
    .Take(4)
    // use an aggregate function to convert dotted quad to 32 bits
    .Aggregate(0L,(y,z)=>y<<8|int.Parse(z))
    // shift bits of aggregate to the right
    >>
    // shift amount determined by subnet size
    32-int.Parse(a[1].Split('/')[1])
  )
  // test for equality by checking if number
  // of unique values is equal to 1
  .Distinct()
  .Count()<2


text:
Shantae Dance Matching
In the original Shantae game, there are transformation dances that you have to input in time using the D-Pad, A, and B. If you complete a predefined sequence while dancing, you will transform into the corresponding form (or teleport or heal). Your task is to output the corresponding effect when given an input. The catch is that you may get extraneous dance moves in the input, both before and after, and there may not even be a dance in the input.
The Dances
Using UDLRAB for dance moves:

Monkey: DR
Elephant: DL
Spider: DA
Harpy: DB
Tinkerbat: DUU
Heal: DUA
Scuttle Town: DULR
Water Town: DURLAB
Oasis Town: DURRBA
Zombie Caravan: DULLBA
Bandit Town: DUBLBR

Coding
Input: a sequence of dance moves. This can contain Up, Down, Left, Right, B, A, and Wait values. Use any convenient encoding.
Output: a value corresponding to the first matching dance in the sequence or a distinct value if there is no match. You can encode this in any convenient way.
Examples
Using . for waiting:

DR → Monkey
UUU.DLUAB → Elephant
L.DDBALL → Harpy
LRLRDURURLAB → No match
DUBLBR → Bandit Town
DURLBA → No match
DDUDR → Monkey
RLAB → No match
.DUUBBB → Tinkerbat
DADRDL → Spider
.DURRBADR → Oasis Town
DURR.BA → No match

Other Rules/Notes

Standard rules on loopholes and IO methods apply
Describe your encoding for dance moves and matching dances.
There may be more than one dance in the input. If that is the case, match only the first one that appears in the input.
Waiting interrupts dances.

Related

Now testcase 4 ends in DURLAB, which is Water Town

@Skidsdev. Good catch. I meant to make that a no match test case there.

You can encode this in any convenient way: may we return the matching sequence, e.g. "DURRBA" for Oasis Town?

@Arnauld I guess that works.

Random: Longish ago, using only 'input' and 'wait' (ie timed coin entries)  the casinos (in a country that I won't mention and which you are unlikely to guess and which isn't my country)(connected to me only by "internet") had their slot machine software hacked at source such that a player could multiply their input pot by a largish number. They then played, won or lost and cashed out with far more than they had input. It was in due course discovered and fixed. I identified the method based on a general description of what was happening overall - supplied by a puzzled security investigator.

JavaScript (ES6),  92 88 61  59 bytes
Saved 2 bytes thanks to a suggestion from @tsh
Expects UdLRAB for the dance moves and . for waiting. Outputs either undefined if there's no match, or the sequence of the matching dance (e.g. dR for Monkey or dURLAB for Water Town).
s=>(/d([A-R]|U(U|A|LR|RLAB|RRBA|LLBA|BLBR))/.exec(s)||0)[0]

Try it online!
or Try it with enhanced output

R|L|A|B -> [RLAB]?

@tsh Actually, d([A-R]|U...) is apparently fine since any convenient encoding may be used for the input as well. Thanks!

JavaScript (Node.js), 179 164 153 148 137 115 bytes
d=>{for(;d;d=d.slice(1))for(z of "R.L.A.B.UU.UA.ULR.URLAB.URRBA.ULLBA.UBLBR".split`.`)if(!d.search('D'+z))return z}

Try it online!
-11 bytes thanks to Arnauld's answer making me realize output can be simplified
-8 bytes thanks to flawr in chat helping me golf array empty checks
-12 bytes thanks to Shaggy
Takes input as a string in same formatting as OP test cases.
Outputs the matched dance string minus the leading D for a match, or undefined for no match.
The integer corresponds to the match's index in this array (0-indexed):
0  - Monkey: DR
1  - Elephant: DL
2  - Spider: DA
3  - Harpy: DB
4  - Tinkerbat: DUU
5  - Heal: DUA
6  - Scuttle Town: DULR
7  - Water Town: DURLAB
8  - Oasis Town: DURRBA
9  - Zombie Caravan: DULLBA
10 - Bandit Town: DUBLBR

Probably room for golfing, especially in compressing the dance move set.
Explanation
General approach
Iterate through the input string, removing the first character each time and checking if the resulting string starts with a valid dance string.
The whole thing is just a for loop inside a for loop, I'll break it down into 3 parts:
 - Condition
 - Inner Loop
 - Outer Post
Condition
This is the termination condition for the outer loop, IE while this is true, keep looping.
Quite simple:
d

d is a string, in JS empty strings are falsey "d is not empty".
Inner Loop
This is the stuff that happens each loop:
for(z of "R.L.A.B.UU.UA.ULR.URLAB.URRBA.ULLBA.UBLBR".split`.`)

So first we define an array with:
"R.L.A.B.UU.UA.ULR.URLAB.URRBA.ULLBA.UBLBR".split`.`

This creates an array of all dance move strings, missing the D at the start of each of them (They all begin with D). We'll call this array x
There's probably significant golfing potential here.
We then iterate through each item in x (stored in z), and run the following:
if(!d.search('D'+z))return z

This uses d.search to return the index in the string of 'D'+z. If and only if d begins with 'D'+z, this will return 0, which is a falsey value in JS.
As such, !d.search will only be true when the string starts with 'D'+z.
Note: This is why we omit the Ds in x, as it saves us 10 bytes (1 per dance), and only costs us a single byte in this search
Then, if the search matches, we return z. This is the dance we've found, without the leading D.
If not, we keep looping.
Outer Post
This is stuff that happens at the end of each iteration of the outer loop:
d=d.slice(1)

Just remove the first character from d
No Match
If d becomes empty and no match has been found, the end of the function is reached. This implicitly returns undefined as per standard JavaScript behavior

@Shaggy I'd just made the substr -> slice change myself, and I keep forgetting that d is a string, not an array. Empty strings are falsey :P And good catch on the braces, I forgot about the whole 1 child statement thing

@Shaggy ah nice! I assume d.search will return 0 if the search string is at the start of d, which is of course a falsey value

Yep. It's kinda like indexOf but it supports RegEx, which is irrelevant here.

And of course it's also 1 byte shorter ;)

82 bytes

@Shaggy Your version will return R for DLDR

@Shaggy that version seems to find the dance in the input string that is first in the dance array, not first in the input.

@EmbodimentofIgnorance, ah, so it will. Try this instead. Can probably be golfed further.

Retina, 53 43 42 37 bytes
0L`;\w|;:(:|A|LR|RLAB|RRBA|LLBA|BLBR)

Try it online!
Slightly deviates from the standard input and output to make use of ;: as DU respectively. Inspiration from tsh, saving 5 bytes.
Matches the first dance and outputs it, after seeing Arnauld's answer. Saved 10 bytes thanks to Neil suggesting using the list stage L and limiting the output to the first match. Saved one byte thanks to tsh shortening the regex.
The header and footer just allow for multiple inputs and making the output readable, respectively.

43 bytes. Can be translated to Retina 0.8.2 by using 1! instead of 0L, but in that case the footer won't work (1M! will work even with the footer).

@Neil Thanks for the golf, I always forget about L.

Maybe R|L|A|B -> [RLAB]?

@tsh Thanks! That was a holdover from my previous approach and I never checked it.

One more step, what about D[RLAB]|DU(...) instead?

@tsh Good idea, but I noticed that abusing the input/output helps a bit more by letting me use \w instead.

Perl 5 -p, 47 bytes
/D([RLAB]|U(U|A|LR|LLBA|RLAB|RRBA|BLBR))/;$_=$&

Try it online!
Returns the dance's code (allowed as per @Arnauld's comment) or blank if no match.

Charcoal, 48 bytes
≔⌊Ｅ⁺D⪪”{➙∧⪫⁻Ｙ⟧¹⊟AOＰ9GＫπ⁸Ｐa↷VＢ”D⟦⌕⁺θιιＬι⟧η✂θ§η⁰Ση

Try it online! Link is to verbose version of code. Explanation:
⁺D⪪”{➙∧⪫⁻Ｙ⟧¹⊟AOＰ9GＫπ⁸Ｐa↷VＢ”D

Split the compressed string RDLDADBDUUDUADULRDURLABDURRBADULLBADUBLBR (which contains all of the dances except for the leading D) on D, and then prefix the D back to each entry.
Ｅ...⟦⌕⁺θιιＬι⟧

For each dance, concatenate it to the input and find the first position of the dance in the concatenation, plus also take the length of the dance. For dances that weren't found this means that the result will be the length of the input string instead of -1.
≔⌊...η

Take the minimum of those results, i.e. the position and length of the dance that appeared first.
✂θ§η⁰Ση

Extract that dance from the original string.

Jelly, 33 28 bytes
“¡ịḟ½NỵC\HỤĊȷṗ~’b6ṣ0;€0ɓUwⱮM

Try it online!
Takes as input a list of integers representing the moves:
0 D
1 U
2 R
3 B
4 L
5 A
6 .

Returns a wrapped integer for the answer, or a list of all these integers for no match:
1 Monkey
2 Harpy
3 Elephant
4 Spider
5 Tinkerbat
6 Heal
7 ScuttleTown
8 OasisTown
9 WaterTown
10 BanditTown
11 ZombieCaravan
1,2,3,4,5,6,7,8,9,10,11 NoMatch

TIO link includes code in the footer to translate these back to the strings in the question, but is not needed for the program to function using the integers specified here.

05AB1E, 104 bytes
'dð.•—Áå•«•¼L?D/8¢Am.Z¼ž•6BSèJ#«å.•g³ç¼…¬ÿ¬Õ‚YÙ•“ÆÚàæÉ¾ ÿ“#.•664Îè¡HĆ∍•¸«“scuttle„©Ê´ bandit“#ð“‰à“«««sÏ

Try it online!

I wrote this monstrosity without realizing I could use numbers for name moves...

sfk, 119 91 bytes
xex -i -firsthit
_DR_
_DL_
_DA_
_DB_
_DUU_
_DUA_
_DULR_
_DURLAB_
_DURRBA_
_DULLBA_
_DUBLBR_

Try it online!
Gives the first dance present as a sequence of moves.
(xex is just a stream editor, and in this case _<pattern>_ is search text)

05AB1E, 28 27 bytes
Saved 1 byte thanks to Grimy
Œ.Δ•1Λ*#$ß‘«∍@…9\÷•6B1¡1ìQZ

Try it online!
Outputs either the match (i.e. 10 for Monkey) or -1 for no match
1 = D
0 = R
2 = L
3 = A
4 = B
5 = U
6 = .

Explanation
Œ.Δ                           # Find the first substring of the input
                         Q    # that is equal to
                          Z   # any element in
   •1Λ*#$ß‘«∍@…9\÷•           # 29058694378496950170872579685936
                   6B         # converted to base-6
                     1¡       # split on 1's
                       1ì     # with a 1 prepended to each

The ¦ isn't needed if you pick the right number

@Grimy: Thanks! I had a previous (longer) version where I didn't need the ¦, but I didn't think of reordering after I changed the meaning of the numbers :)

26 with a different encoding

source: Stack Exchange

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

sort: votes


text:
Make some Prime Squares!
What is a Prime Square?
A Prime Square is a square where all four edges are different prime numbers.
But which ones?
And how do we construct them?
Here is an example of a 4x4 Prime Square
1009
0  0
3  0
1021

First we start from the upper left corner. We are working clockwise.
We pick the smallest prime number having 4 digits which is 1009.
Then we need the smallest prime number having 4 digits, which starts with a 9. This is 9001
The third (4-digits) prime number must have 1 as its last digit (because 9001 ends with 1)
and also be the smallest 4-digit prime with this property that has not been used before as an edge.
This prime number is 1021
The fourth prime number must have 4 digits, start with a 1 (because 1009 starts with a 1) and end with a 1 (because 1021 starts with a 1)
The smallest 4-digit prime number with this property that has not been used before as an edge is 1031
Your TASK
You will be given an integer n from 3 to 100
This number will be the dimensions of the n x n square
Then you must output this square exactly in the form of the following test cases
Test Cases
n=3
Output

101
3 0
113

n=5
Output

10007
0   0
0   0
9   0
10061

n=7
Output

1000003
0     0
0     0
0     0
0     0
8     1
1000037

n=10
Output

1000000007
0        0
0        0
0        0
0        0
0        0
0        0
1        0
8        0
1000000021

n=20
Output

10000000000000000051
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
0                  0
9                  8
10000000000000000097

Input and output can be given by any convenient method.
You can print it to STDOUT or return it as a function result.
Either a full program or a function are acceptable.
Any amount of extraneous whitespace is acceptable, so long as the numbers line up appropriately
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

EDIT
This is possible for all n
Here are the primes for n=100
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000289
9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000091
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000711
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002191

And for those of you that you don't think this is possible [here are ALL the test cases][1]

If n can go up to 100, it might be good to have some larger test cases than n = 10.

Is it provable that this is possible for all n :P? Not a problem with the challenge, just curious.

@MagicOctopusUrn It is definitely not possible for all n: for n=1, we cannot satisfy the constraint that the four edges are different primes, while for n=2, we are forced to choose 11,13,23, at which point the final edge is 12 which is composite. I don't have a proof that it is possible for all n>2, but would be shocked to learn otherwise: informally, the more digits there are, the more "wiggle room" there is to satisfy the constraints.

@DanielWagner Many upper bounds on the ratio between $p_{k+1}$ and $p_k$ have been proved over the years, improving Bertrand's postulate by a significant margin. The formula given here for $k\ge463$ should be enough to prove that this holds for $n\ge4$.

@MagicOctopusUrn There's some good reading at Wikipedia's "prime gap" page. In particular from that page we know that for sufficiently large n, the prime gap is less than a tenth the size of the primes themselves; this is enough to say that for sufficiently large n we can always choose the top and right edges. Haven't found anything to help prove we can always choose the bottom and left edges yet.

@Arnauld The ratio itself doesn't seem to help prove that there are primes of a given size ending in a given digit, though; so those bounds only help with the proof that we can choose the top and right edges as said in my previous comment.

@MagicOctopusUrn The prime number theorem for arithmetic progressions says something fairly strong about the density of primes ending in 1, 3, 7, and 9 (in the notation there, take n=10, a=1/3/7/9); for sufficiently large n there are at least two primes of length n starting with 1 and ending with each of those digits (hence we can choose a bottom edge) and there are at least three primes starting with 1 and ending with 1 (hence we can choose a left edge).

Is generating any square allowed, given that we can fix corners on [1,3,7,9] Solutions on n=3

@l4m2 You must always pick the smallest primes. So, these squares are unique.

Does the restricted input range [3..100] imply that the solutions must return something for all these values? Or do they just need to work in theory? (which AFAIK is the default rule)

@Arnauld ...in theory.

05AB1E, 64 63 56 53 48 46 bytes
°ÅPIùćÐ4FˆθUKD.ΔθyXÅ?yXÅ¿)¯gè}ÐNĀiR}¦}I¯JŽ9¦SΛ

-1 byte thanks to @Mr.Xcoder
-5 bytes thanks to @Grimy.
Try it online. (Times out for \$n>4\$. Here the slightly faster 53 bytes version which times out for \$n>7\$ instead.)
Explanation:
°                 # Raise the (implicit) input to the power 10
 ÅP               # Get a list of primes within the range [2, n^10]
   Iù             # Only keep those of a length equal to the input
ć                 # Extract the head; push the remainder-list and first prime separately
 Ð                # Triplicate this first prime
4F                # Loop 4 times:
  ˆ               #  Add the (modified) prime at the top of the stack to the global array
  θU              #  Pop and store the last digit of the prime in variable `X`
  K               #  Remove this prime from the prime-list
  D               #  Duplicate the prime-list
   .Δ             #  Find the first prime `y` in the prime list which is truthy for:
     θ            #   Get the last digit of prime `y`
     yXÅ?         #   Check if prime `y` starts with variable `X`
     yXÅ¿         #   Check if prime `y` ends with variable `X`
     )            #   Wrap the three results above into a list
      ¯g          #   Get the amount of items in the global array
        è         #   And use it to index into these three checks
                  #   (Note that only 1 is truthy for 05AB1E, so the `θ` basically checks
                  #    if the last digit of prime `y` is 1)
    }Ð            #  Triplicate the found prime
      NĀi }       #  If the loop index is 1, 2, or 3:
         R        #   Reverse the found prime
      ¦           #  And then remove the first digit of the (potentially reversed) prime
}                 # After the loop:
 I                # Push the input as length
 ¯J               # Push the global array joined together to a single string
 Ž9¦S             # Push compressed integer 2460 converted to a list of digits: [2,4,6,0]
 Λ                # Draw the joined string in the directions [2,4,6,0] (aka [→,↓,←,↑])
                  # of a length equal to the input
                  # (which is output immediately and implicitly as result)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ž9¦ is 2460. And see this 05AB1E tip of mine to understand how the square is output with the Λ Canvas builtin.
The relevant code for printing the Canvas in a square is: NĀiR}¦ and I¯JŽ9¦SΛ. Let's take n=4 as example. The primes it will find with the rest of the code are [1009,9001,1021,1031]. The first code-part mentioned in this paragraph will save them as this instead: [1009,"001","201","301"]. The second code part of this paragraph will then use the Canvas builtin Λ with options:
- \$a\$ (side-length) = I: the input
- \$b\$ (string to print) = ¯J: the global array joined together (so "1009001201301" for n=4)
- \$c\$ (direction) = Ž9¦S: the directions [2,4,6,0], which will be [→,↓,←,↑] respectively

50: 4F°ÅP¯KIù.Δ1sÐ®θÅ¿Š®θÅ?Šθ)¯gè}©ˆ}ð¯2ô`€R«€¦J«Ž9¦SΛ
49: °ÅPIùć4FÐN1›iR}¦ˆθUKD.ΔÐθsXÅ?‚sXÅ¿ª¯gè]Ið¯J«Ž9¦SΛ
48: °ÅPIùćÐ4FˆθUKD.ΔÐθsXÅ?‚sXÅ¿ª¯gè}ÐNĀiR}¦}I¯JŽ9¦SΛ

@Grimy Thanks! Very nice golfs. I've been able to save 2 more bytes based on your 48-byte version by changing ÐθsXÅ?‚sXÅ¿ª to θyXÅ?yXÅ¿). Not exactly sure why ) works within the scope of the loop though, since I would have expected it to wrap the prime-list also into its list in the first iteration. But even without that, the use of yy instead of Ðss still saves 1 byte. :)

05AB1E, 35 33 32 31 bytes
-1 byte thanks to Kevin Cruijssen
°ÅPIùΔÐXθÅ?Ïн©KX®¦«UNií]IXŽ9¦SΛ

Try it online!
Explanation:
°                 # 10 to the power of the input
 ÅP               # list of primes up to that
   Iù             # keep only those with the same length as the input

Δ                 # repeat until the list doesn't change
# This ends up doing a ton of unneeded work. 4F (to loop 4 times) would be
# enough, but Δ is shorter and the extra iterations don’t cause issues.
# At the start of each iteration, the stack only contains the list of primes,
# and the variable X contains the current list of digits we’ll want to print.
# Conveniently, X defaults to 1, which is our first digit.

 Ð    Ï           # push a filtered copy of the list, keeping only…
    Å?            # numbers that start with…
  Xθ              # the last character of X
       н          # get the first element: this is our next prime

 ©                # save this number to the register
  K               # remove it from the list of candidate primes
   X              # push X
    ®             # restore the number from the register
     ¦            # remove its first character
      «           # concatenate it to X
       U          # save the result to X

 Ni               # if N == 1 (second time through the loop)
   í              # reverse all elements in the list of candidate primes
    ]             # closes both this if and the main loop

      Λ           # Draw on a canvas…
I                 # using the input as length…
 X                # using X as the string to draw…
  Ž9¦S            # using [2,4,6,0] (aka [→,↓,←,↑]) as the directions to draw in

This is partially based on Kevin’s answer, but at this point it’s different enough that I felt it deserved its own answer rather than a comment.

I only now see this answer. Very nice! Apart from the general method (and therefore the first and last parts), determining the four primes and building the string is done so differently that I can understand the separated answer. +1 from me. Btw, you can save a byte removing the Θ at NΘ. Only 1 is truthy in 05AB1E, so if N and if N == 1 are the same.

@KevinCruijssen Thanks! Of course I knew that, but I forgot to use it. In retrospect, Θi is the 05AB1E equivalent of if (cond == true)...

Yep, that's right. :) Θ can still be useful if you want to convert everything except 1 to 0. But for the if-statement i, it's not really necessary just like your pseudocode with == true.

JavaScript (ES8),  205 ... 185 177  173 bytes
Times out on TIO for \$n>8\$ because of the very inefficient primality test.
n=>([a,b,c]=[0,-1,--n,0].map(p=o=i=>o[(g=n=>{for(k=n++;n%k--;);k|o[n]|p[i]-n%10?g(n):p=n+''})((~i?1:p%10)*10**n)|p]=p),[...p].map((d,i)=>i?i<n?d.padEnd(n)+b[i]:c:a).join`
`)

Try it online!
How?
Step #1: computing the 4 primes
[a, b, c] =               // save the 3 first primes into a, b and c
                          // (the 4th prime will be saved in p)
  [ 0, -1, --n, 0 ]       // decrement n and iterate over [ 0, -1, n, 0 ]
  .map(p =                // initialize p (previous prime) to a non-numeric value
       o =                // use o as a lookup table
  i =>                    // for each value i in the list defined above:
    o[                    //   update o:
      (g = n => {         //     g = recursive function taking n
        for(k = n++;      //       set k = n and increment n
            n % k--;);    //       decrement k until it's a divisor of n
                          //       (notice that k is decremented *after* the test)
        k |               //       if k is not equal to 0 (i.e. n is not prime)
        o[n] |            //       or n was already used
        p[i] - n % 10 ?   //       or the last digit of n does not match the connected
                          //       digit (if any) with the previous prime:
          g(n)            //         do a recursive call
        :                 //       else:
          p = n + ''      //         stop recursion and save n coerced to a string into p
      })(                 //     initial call to g with:
        (~i ? 1 : p % 10) //       either 10 ** n if i is not equal to -1
        * 10 ** n         //       or (p % 10) * 10 ** n if i = -1
      ) | p               //     yield p
    ] = p                 //   set o[p] = p
  )                       // end of map()

Step #2: formatting the output
[...p].map((d, i) =>      // for each digit d at position i in the last prime:
  i ?                     //   if this is not the first digit:
    i < n ?               //     if this is not the last digit:
      d.padEnd(n)         //       append d, followed by n - 1 spaces
      + b[i]              //       append the corresponding digit in the 2nd prime
    :                     //     else (last digit):
      c                   //       append the 3rd prime
  :                       //   else (first digit):
    a                     //     append the first prime
).join`\n`                // end of map(); join with carriage returns

Ignoring time, will it fail because of inaccurate float? This question require a 100 range

@l4m2 This will definitely fail on large integers. But the OP has confirmed that this is OK.

Jelly, 89 82 bytes
1ịÆn⁺f®$¿
’⁵*;Æn$©µDṪṪ×ḢÇ©;@©µ;Ç⁺;0ị®¤%⁵n/Ɗ¿$$©;Ç⁺%⁵’$¿$$µŒœṪDZUḊṖj€⁶x³¤ḊḊ¤;@Ḣ;2ị$

Try it online!
Could definitely be golfier, but works efficiently for big numbers.

Jelly, 59 bytes
DṪṪ=DZḢṪṪ3ƭƊ}Tịḟ@Ḣ
’;⁸⁵*æR/µḢ;ç¥⁺⁺µŒœṪDZUḊṖj€⁶x³¤ḊḊ¤;@Ḣ;2ị$

Try it online!
Shorter but much less efficient Jelly answer.

JavaScript, 484 bytes
i=a=>a?(l=a=>a[(L=a=>a.length-1)(a)])(a)==9?i(r(a))+0:(r=a=>a.substr(0,L(a)))(a)+(+l(a)+1)%10:"1";s=(a,b)=>b?a==b?"":s(l(a)<l(b)?s(r(a),1):r(a),r(b))+Math.abs(l(a)-l(b)):a;m=(a,b)=>!a||!((c=L(a)-L(b))<0||!c&&a<b)&&m(s(a,b),b);p=(a,b="2")=>a/2<b||!(m(a,b)||!p(a,i(b)));a=>{for(M=1+(R=a=>"0".repeat(b))(z=a-1);!p(M=i(M)););for(N=M[z]+R(z);!p(N=i(N)););for(O=1+R(x=a-2);!p(O+n[z]);O=i(O));for(P=R(x);!p(m[0]+P+O[0]);P=i(P));for(S="\n",j=0;j<x;)S+=P[i]+R(x)+N[++i]+"\n";return M+S+O+N[z]}

The last unnamed function returns the ASCII art.
Original code
function inc(a){
  if (!a) return "1";
  if (a[a.length-1]=="9") return inc(a.substr(0,a.length-1))+"0";
  return a.substr(0,a.length-1)+(+a[a.length-1]+1)%10;
}
function sub(a,b){
  if (!b) return a;
  if (a==b) return "";
  var v=a.substr(0,a.length-1);
  if (a[a.length-1]<b[b.length-1]) v=sub(v,1);
  return sub(v,b.substr(0,b.length-1))+Math.abs(a[a.length-1]-b[b.length-1])
}
function multof(a,b){
  if (!a) return true;
  if (a.length<b.length||a.length==b.length&&a<b) return false;
  return multof(sub(a,b),b);
}
function isprime(a){
  for (var i="2";a/2>i;i=inc(i)){
    if (multof(a,i)) return false;
  }
  return true;
}
function square(a){
  for (var m="1"+"0".repeat(a-1);!isprime(m);m=inc(m)){}
  for (var n=m[a-1]+"0".repeat(a-1);!isprime(n);n=inc(n)){}
  for (var o="1"+"0".repeat(a-2);!isprime(o+n[a-1]);o=inc(o)){}
  for (var p="0".repeat(a-2);!isprime(m[0]+p+o[0]);p=inc(p)){}
  var s="";
  for (var i=0;i<a-2;i++) s+=p[i]+"0".repeat(a-2)+n[i+1]+"\n";
  return m+"\n"+s+o+n[a-1];
}

Best and average time complexity: Ω(100nn) in Knuth's big-omega notation(n steps for subtracting n digit numbers, 10n substractions per divisibility check, 10n divisibility check for prime check, and Ω(1) prime checks done).
Worst time complexity: Ω(1000nn) in Knuth's big-omega notation(n steps for subtracting n digit numbers, 10n substractions per divisibility check, 10n divisibility check for prime check, and 10n prime checks done).
I suspect n=100 takes around 10203 calculations.

Sidenote: I validated syntax using UglifyJS 3, and it golfed it way better than I did, saving 47.13% more and earning 282 bytes. However, I decided not to make that my score since I feel like it is cheating.
i=(s=>s?9==(l=(l=>l[(L=(l=>l.length-1))(l)]))(s)?i(r(s))+0:(r=(l=>l.substr(0,L(l))))(s)+(+l(s)+1)%10:"1"),s=((L,i)=>i?L==i?"":s(l(L)<l(i)?s(r(L),1):r(L),r(i))+Math.abs(l(L)-l(i)):L),m=((l,r)=>!l||!((c=L(l)-L(r))<0||!c&&l<r)&&m(s(l,r),r)),p=((l,s="2")=>l/2<s||!(m(l,s)||!p(l,i(s))));

It just deleted the last function since they are never used. It actually became worse if it was assigned and not deleted, imcluding the additional code I added.

This seems incomplete? And not golfed?

Yes. Completed/golfed.

JavaScript (Node.js), 222 bytes
n=>(g=(m,d=1n)=>((Q=(n,k)=>k?Q(n*n%m,k/2n)*n**(k%2n)%m:1n)(2n,m)==2)>(m in g)?(g[m]=m):g(m+d,d),c=10n**~-n,A=g(c),B=g(A%10n*c),C=g(c+B%10n,10n),[...g(-~c,10n)+''].map((c,i)=>i?i+1<n?c.padEnd(~-n+'')+(''+B)[i]:C:A).join`
`)

Try it online!
Reasonable time for large \$n\$, only check if \$2^n≡2\$ as prime test

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


text:
Words Everywhere
Given a list of words, output a square grid of characters, so that all the words can be read from the grid, by moving horizontally, vertically, or diagonally between characters, without reusing characters in the same word. The grid must be the smallest possible which allows all words to be read.
Example
B A D
R E T
E Y E

The above grid contains the words BAD, BAR, BARE, TAB, TEAR, EYE, EAR, TEE, TEED, BEAR, BEAD, BEET, DARE and YEAR (plus more, and duplicates of these in some cases). It could therefore be a valid output for the input list YEAR, BEET, DARE - the grid must be at least 3x3, since at least 8 characters are required (7 distinct characters, and 2 Es), which wouldn't fit in a 2x2 grid.
Y D R
B E A
T E E

The above grid would be another valid output for the input YEAR, BEET, DARE, but would not be valid if EYE was added to the input list, despite containing the same letters as the previous grid, since there is no way to reach the Y from two distinct Es.
There is no assumption that "words" in this challenge are English words, or even formed of letters - they are simply any string of at least 3 characters.
For input ☃, ☃❄,
☃
❄  ☃
  ❄

would be a valid output. In this case, all the "words" can be read in straight lines, which wasn't possible with the previous example (no way to fit a 4 letter word into a 3x3 grid without a turn)
Rules

Standard loopholes are forbidden.
You can take input in any acceptable format (see Input/Output methods meta post)
You can output in any acceptable format, as long as it is trivial to check that it is a square manually. For example, outputting BADRETEYE is not trivial to check - you need to count the characters, and take the square root of this, which is far too much effort for larger grids. Outputting BAD RET EYE is trivial to check - you count how many groups, and the length of any group, and if they are the same, the grid is square.
You can fill in any gaps in the grid with any characters from the input
Letters can only be used once in each word
The grid should be as small as possible - the lower bound will be the square number above number of distinct characters required (e.g. 8 distinct characters would require 9 characters of output at minimum, but may require more characters if positioning means that they can't be read simultaneously)
Languages without Unicode support (e.g. C64 BASIC, things that only run on calculators) may ignore the Unicode test case
It's code-golf, so shortest answer in bytes wins!

Test Data

ANT - should give a 2x2 grid, with one letter repeated
ANT, TAN, NAT - may well give same grid as previous
ANT, MAN - 2x2 grid, with each of A, N, T, and M included once
YEAR, BEET, DARE - 3x3 grid
YEAR, BEET, DARE, EYE - 3x3 grid
BAD, BAR, BARE, TAB, TEAR, EYE, EAR, TEE, TEED, BEAR, BEAD, BEET, DARE, YEAR - 3x3 grid
ANTMAN, BATMAN, BANANA - 3x3 grid
CHAOS, ORDER - 3x3 grid, no spare spaces
SUPERMAN, SHAZAM - 4x4 grid
123, 1337, 911, 999, 112 - non-letters, 3x3
SUPERGIRL, FLASH, ARROW, GOTHAM, BLACKLIGHTNING, KRYPTON, TITANS, DOOMPATROL - no idea, but at least 6x6
ABSENTMINDEDNESS, MINT, DINED, TABS, STAND, SEATED - no idea, but might be a 4x4, since only 16 required letters
☃, ☃❄,  - Unicode characters, 3x3
AUCTIONED, CAUTIONED, EDUCATION - 3x3
COUNTRIES, CRETINOUS, NEUROTICS - at least 4x4 - both R and E need to be next to 6 distinct letters, which isn't possible on 3x3 grid

Notes

Inspired by the game "Words Everywhere" in the Word Games Pro app from LittleBigPlay, available on Google Play
Solving Is This a Boggle Pad? in the unrestricted NxN case might be useful to determine the minimum required size, but is unlikely to help with actually generating the output
There is a kind of inverse of this challenge at Is This Word on the Boggle Pad

Python 3, 444 bytes
def p(g,v=[]):
	l=len(g);r=[*range(l)];k=[[(x,y)]for x in r for y in r if(x,y)not in v]
	if len(k)<2:return[k[0]]
	return[n+N for n in k for N in p(g,v+n)if max(abs(N[0][0]-n[0][0]),abs(N[0][1]-n[0][1]))<2]
from itertools import*
def f(a):
	i=2;w=set("".join(a))
	while 1:
		for f in product(*[w]*i*i):
			g=[f[k*i:][:i]for k in range(i)];P=["".join(g[x][y]for x,y in l)for l in p(g)]
			if all(any(c in n for n in P)for c in a):return g
		i+=1

Try it online!
Horribly inefficient. The function f takes a list of words and returns a grid of characters as a list of tuples. The footer is just for formatting to take input and pretty-print output.
(Also when I golf this I get to make a crossed-out-44 meme :D)

Will have to try this one out on an actual computer - the tio link times out with most of the test cases!

@Matthew Yep, which is pretty annoying, because I don't know if this actually works! I can't actually test it on things beyond 2x2 lol.

Maybe I should have put in a requirement that the code runs in the period allowed by Try it online... I'm running one of the simple test cases on my laptop at the moment (32Gb RAM i7) and it's been going 15 mins so far!

431 by using itertools.product in p and not assigning the length of g to a variable.

Python3, 853 bytes:
R=range
def O(n,b,w,c,x,y,p):
 if''==w:yield b,c;return
 F=0;q=[]
 for X,Y in[(1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)]:
  if n>(j:=x+X)>=0 and n>(k:=y+Y)>=0:
   if 0==b[j][k]:q+=[(j,k)]
   if b[j][k]==w[0]and(j,k)not in p:yield from O(n,b,w[1:],c,j,k,p+[(j,k)]);F=1
 if F==0:
  for x,y in q:B=eval(str(b));B[x][y]=w[0];C=eval(str(c));C[w[0]]={*c.get(w[0],[]),(x,y)};yield from O(n,B,w[1:],C,x,y,p+[(x,y)])
def f(w):
 l=len(set(''.join(w)))
 n=min(i for i in R(l)if i**2>l)
 q,s=[([[0for _ in R(n)]for _ in R(n)],{},w)],[]
 while q:
  b,c,W=q.pop(0)
  if[]==W:return[[j or w[0][0]for j in i]for i in b]
  for x,y in(c.get(W[0][0],[])or[(x,y)for x in R(n)for y in R(n)if 0==b[x][y]]):
   P=eval(str(b));P[x][y]=W[0][0];K=eval(str(c));K[W[0][0]]={*c.get(W[0][0],[]),(x,y)}
   for B,C in O(n,P,W[0][1:],K,x,y,[(x,y)]):q+=[(B,C,W[1:])]
   break

This solution is longer than the other Python answer, but significantly faster on the test cases.
Try it online!

"This solution is longer than the other Python answer, but significantly faster on the test cases."  Can you add an explanation of the approach?


text:
Intercommunication between threads
So glad I found this cool site. Wanted to try sharing a coding challenge a friend gave me, an interview question. Usually it is written in java, but you can use whatever language you want, just have fun!
Challenge: write efficiently and securely a program that creates an array of n threads that communicate with each other, where each thread, for simplicity, represents a number between 1,...,100. Oh, and it has to be randomly initialized.
Here comes the fun part: each thread looks at its neighbours(i-1,i+1) and:

If its number is smaller than the number of both of his neighbours(i-1,i+1), it increments itself.
If its number is larger than the numbers of both of his neighbours, it decrements itself.
If its number is equal or between the numbers of its neighbours, it keeps the number the same.

So far not fun, right? So let's also make it a circular array! (the first element in the array and the last element in the array are neighbours) the tricky parts are: each thread should not change its number before its neighbors finished checking it.
The program performs m rounds of checks.
Input: For program logic, you can take the input from the user, or define it, doesn't matter.
Output: first line should print the starting state of the array. Second line should print all of the numbers in the array after each thread did one check. Third line should print the numbers in all of the array after each thread did a second test(second round) and so on.
Might be quite tricky in the beginning, but have fun with it!
The winner will be the one who can write the shortest code, and in case of a tie, cool algorithmic tricks or functional utilization of the java language will be awarded extra points!

First post here, will try to post more cool stuff for you to enjoy!
Really like this site.
I posted it a while ago, but forgot my credentials while being abroad so I couldn't log in to the site and fix the previous post. Hoping that this one is according to the standards of the site and more than that, I really hope you'll enjoy this cool coding gamexercise.
Good luck to all and most importantly - enjoy!
As kevin well-said: 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.

Although a good challenge, I have the feeling this can be done without threads? All integers in the array check their neighbors, and increment/decrements/stay the same based on that, and continue doing so for m iterations. So if I understand correctly we get an input n (array-size) and m (amount of iterations)?

it can be done without threads @KevinCruijssen, but using threads is more fun :)

@Puzzle Well, not all languages have threads, hence the question. Also, if this is code-golf, doing it without threads would be shorter in Java as well. But after making an answer in 05AB1E I will try to make an answer in Java both with an without threads. :)

As for the random number, is it including or excluding 1 and 100? So is the range [1 ... 100], [2 ... 100], [1 ... 99], or [2 ... 99]? It states in between, which would mean [2, 99]. Or alternatively, are all four options allowed (and perhaps [0 ... 99] / [0 ... 100] as well? Just trying to save some bytes here, haha ;p

Please define efficiently and securely.

Is it just me, or does this read like a homework problem, especially with the arbitrary addition of threads to the mix?

@Adám: for instance, when you compare threads, you need to allow the thread check with its neighbors before going to the next random number and so on, you need to be aware not causing data inconsistency

i am not sure i understood @KevinCruijssen it is a cyclic, meaning the first and the last elements are neighbors. if you meant regarding the ranges, then it is including 1 and 100

@Puzzle Yes, I indeed meant the ranges we get random values from. Ok, so [1 ... 100]. Will update my Java answer at the same time that I'll add the multi-threading program.

So this is a challenge about iteratively updating a list of numbers? I'm confused what at all this has to do with threads.

@xnor If it was originally a job interview question, it probably would have been using threads to show the interviewee's experience.

note: to all dear people who participate in this coding golf: the challenge will be ended in sunday. some bad things happened unexepectedly so i will not be able to fully monitor this. i will check this thread twice a day until sunday and then the winner will be decided. if you want to edit my post to implement leaderboard or cool features - feel free to do so and thank you very much for all of your support. it is always fun to see different approaches to a challenge and learn from them

@Puzzle I've updated my Java answer and added a program with threads. As I suspected, without threads is quite a bit shorter.. xD

05AB1E, 35 bytes
FтLΩˆ}>µ¯©=´vy®N<N>‚èy.SDPiн+ë\}ˆ}¼

Takes n as first input, and m as second. Doesn't use any threads, since 05AB1E has none.
Try it online.
Explanation:
F    }               # Loop the (implicit) input `n` amount of times:
 тL                  #  Push a list in the range [1,100]
   Ω                 #  Pop and push a random value from this list
    ˆ                #  Pop and add it to the global array
>                    # Increase the second (implicit) input `m` by 1
 µ                   # Loop until the counter_variable is equal to that:
  ¯                  #  Push the global array
   ©                 #  Store it in the register (without popping)
    =                #  Print it with trailing newline (without popping)
     ´               #  And clear the global array
   v                 #  Loop over each item of the array that is still on the stack:
      N<             #   Get the index-1
        N>           #   And the index+1
          ‚          #   Pair them together
     ®     è         #   Index both into the previous array we stored in the register
                     #   (NOTE: 05AB1E has automatic wrap-around when indexing)
            y.S      #   Compare both of them to the current integer `y`
                     #   (-1 if `y` is larger; 1 if `y` is smaller; 0 if equal)
               D     #   Duplicate this pair
                Pi   #   If the product is 1 (only true for [1,1] and [-1,-1]):
                  н  #    Only leave the first element of the duplicated pair
    y              + #    And add it to the current integer `y`
                 ë   #   Else:
                  \  #    Discard the duplicated pair, so `y` is at the top of the stack
                 }ˆ  #   After the if-else: add it to the global array
   }¼                #  After the inner loop: increase the counter_variable by 1

it's like cheating hehehe. is it okay if i limit it only to java or typical programming languages to give all people fair chance?

@Puzzle Usually challenges are open to all language. Also, define 'typical'. :) But I'll probably get outgolfed anyway by someone programming in Jelly. ;p When I create challenges I usually also add the sentence: "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." It's never really about winning/losing a challenge, only about having fun doing the challenges. PS: I'm working on the Java multi-threading one, but I suck with threading, so will take a bit longer..

adding your sentence to my post!

Java 8, 229 bytes (lambda without threads)
n->m->{int a[]=new int[n],b[],i=n,t;for(;i-->0;)a[i]=(int)(Math.random()*100)+1;for(;m-->=0;a=b)for(System.out.println(java.util.Arrays.toString(a)),b=a.clone(),i=n;i-->0;)b[i]+=(t=a[(n+~i)%n]-a[i])*(a[-~i%n]-a[i])>0?t<0?-1:1:0;}

Try it online.
Java 8, 299 bytes (full program without threads)
interface Main{static void main(String[]A){int n=new Short(A[0]),m=new Short(A[1]),a[]=new int[n],b[],i=n,t;for(;i-->0;)a[i]=(int)(Math.random()*100)+1;for(;m-->=0;a=b)for(System.out.println(java.util.Arrays.toString(a)),b=a.clone(),i=n;i-->0;)b[i]+=(t=a[(n+~i)%n]-a[i])*(a[-~i%n]-a[i])>0?t<0?-1:1:0;}}

Try it online.
Explanation:
n->m->{              // Method with two integer parameters and no return-type
  int a[]=new int[n],//  Create an array of size `n`
      b[],           //  Temp array, uninitialized
      i=n,           //  Index-integer, starting at `n`
      t;             //  Temp integer, uninitialized
  for(;i-->0;)       //  Loop `i` in the range (`n`, 0]:
    a[i]=(int)(Math.random()*100)+1;
                     //   Fill the `i`'th item in the array with a random integer in
                     //   the range [1, 100]
  for(;m-->=0;       //  Loop `m` times:
      a=b)           //    After every iteration: replace array `a` with `b`
    for(System.out.println(java.util.Arrays.toString(a)),
                     //   Print array `a` with trailing newline
        b=a.clone(), //   Create a copy of array `a` in `b`
        i=n;i-->0;)  //   Inner loop `i` in the range (`n`, 0]:
      b[i]+=         //    Increase the `i`'th item in array `b` by:
        (t=a[(n+~i)%n]-a[i])
                     //     Calculate a[i-1] minus a[i] (temporarily stored in `t`)
        *(a[-~i%n]-a[i])
                     //     Multiply it by a[i+1] minus a[i]
         >0?         //     If this is positive:
            t<0?     //      If `t` is negative:
             -1      //       Decrease b[i] by 1
            :        //      Else (`t` is positive):
             1       //       Increase b[i] by 1
        :            //     Else (a[i-1]-a[i] and a[i+1]-a[i] are pos/neg or neg/pos,
                     //           or one of the two is 0)
         0;}         //      Leave b[i] the same by adding 0

Java 10, 569 537 bytes (full program with threads)
import java.util.concurrent.*;class M{C[]c;CyclicBarrier b;int n,m,i;public static void main(String[]a){new M().t(a);}void t(String[]a){m=new Short(a[1]);c=new C[n=new Short(a[0])];for(;i<n;)c[i]=new C(i++);b=new CyclicBarrier(n,()->{System.out.println(java.util.Arrays.toString(c));});for(var x:c)new Thread(x).start();}class C implements Runnable{int v=100,i,q,L,R,t;C(int I){i=I;v*=Math.random();v++;}public void run(){try{for(;q++<=m;R=c[-~i%n].v,t=v<L&v<R?1:v>L&v>R?-1:0,b.await(),v+=t)L=c[(n+~i)%n].v;}catch(Exception ex){}}public String toString(){return""+v;}}}

As mentioned earlier in a comment, without threads is much shorter..
Try it online (with class M is replaced with class Main, since it won't work on TIO if the class isn't called exactly Main..)
Explanation:
import java.util.concurrent.*; // Required import for CyclicBarrier
class M{                       // Class:
  C[]c;                        //  Array of our Runnable cells on class-level
  CyclicBarrier b;             //  A CyclicBarrier
  int n,                       //  Size of the array
      m,                       //  Amount of cycles
      i;                       //  Index, implicitly starting at 0
  public static void main(String[]a){
                               //  Mandatory main method:
    new M()                    //   Create an instance of this class
        .t(a);}                //   And call the non-static method below:
  void t(String[]a){           //  Non-static method for the actual program:
    m=new Short(a[1]);         //   Fill the amount of cycles `m` with the second argument
    c=new C[n=new Short(a[0])  //   Fill the size `n` with the first argument
             ];                //   Create the array of that size
    for(;i<n;)                 //   Loop over all cells in the array:
      c[i]=new C(i++);         //    And create a new instance for each cell
    b=new CyclicBarrier(n,     //   Create the CyclicBarrier of size `n`
       ()->{                   //    Which will do the following before every cycle:
          var p="";            //     Create a String to print, starting empty
          for(var x:c)         //     Loop over the cells
            p+=x.v+" ";        //      Append the cell's value and a space to the String
          System.out.println(p);});
                               //     Print the String with trailing newline
    for(var x:c)               //   Loop over the cells again:
      new Thread(x)            //    Create a new thread for this Runnable cell
        .start();}             //    And start the thread
  class C                      //  Inner class for the cells
      implements Runnable{     //  which implements the Runnable interface
    int v=100,                 //   The value of this cell, starting at 100
        i,                     //   The index of this cell
        q,                     //   A counter for the cycles
        L,R,                   //   Values of the left and right neighbors
        t;                     //   Incremental integer
    C(int I){                  //  In the constructor of the cell:
      i=I;                     //   Set the index `i` on the given index
      v*=Math.random();v++;}   //   And set `v` to a random integer in the range [1,100]
    public void run(){         //  Override the Runnable run method:
      try{                     //   Mandatory try-catch for InterruptedException
        for(;q++<=m;           //    Loop `m+1` times using the cycle-counter `q`
            ;                  //      After every iteration:
             R=c[-~i%n].v,     //       Get the value in the right-neighboring cell
             t=v<L&v<R?        //       If this cell's value is smaller than both neighbors:
                1              //        Set the incremental to 1
               :v>L&v>R?       //       Else-if this cell's value is larger than both neighbors:
                -1             //        Set the incremental to -1
               :               //       Else (value is smaller than or equal to one neighboring cell
                               //             and larger than or equal to the other neighboring cell):
                0,             //        Set the incremental to 0
             b.await(),        //       Wait until all cells in this BarrierCycle are done
             v+=t)             //       And only then increase/decrease the value with the incremental
          L=c[(n+~i)%n].v;     //     Get the value in the left-neighboring cell
      }catch(Exception ex){}}}}//   Mandatory try-catch for InterruptedException

Here's a pastebin for my half-assed thread attempt lol. I haven't done much with synchronous threading-- only async (this isn't a functional solution). I'm really interested to see this done for synchronous threads using the actual Runnable interface.

@MagicOctopusUrn Isn't your TIO missing something? You initialize boolean m=false;, but you never make it true? Also, although you're using threads, it isn't really async nor waiting on one-another. You're  using the Threads only as a wrapper-class for the value and index and have a Thread.sleep.. :S As for your last sentence, I was working on something with a Runnable interface, but got stuck. Will try again today based on the two answers given.

@MagicOctopusUrn Added an async program with multi-threading, utilizing BarrierCycle in combination with a Runnable class and Thread.

Never seen a CyclicBarrier before, that's awesome. As for the sleep statements, I was just seeing if crap even worked; it wasn't intended to be a solution haha. Mostly brain vomit.

@MagicOctopusUrn I've also never seen CyclicBarrier before, but I came across this SO question which has a boolean matrix and wants to insert Jogn Conway's life simulator with multi-threading, where the cells also wait until everyone is done before actually updating, just like this challenge. And the accepted answer used the CyclicBarrier. I still had to get  some help when I was stuck, since I'm a noob when it comes to multithreading, but it works. :)

Javascript, 209 bytes
for(a=[],l=n=prompt();n;)a[--n]=(M=Math).floor(M.random()*100+1);for(console.log(a),m=prompt();--m;)b=a.slice(),b.forEach((e,i)=>b[i]+=e<M.min(x=b[(i-1+l)%l],y=b[(i+1)%l])?1:e>M.min(x,y)?-1:0),console.log(a=b)

This program, upon running, will prompt the user twice. First for n(number of threads, but instead made with arrays), second for m(number of checks).

C# (Visual C# Interactive Compiler), 198 bytes
n=>m=>{int[]z=new int[n],g;int i=n,a;for(var k=new Random();i>0;z[--i]=k.Next(1,101));for(;m-->0;z=g){g=z.ToArray();i=0;for(Print(z);i<n;g[i]+=(a=z[(n+~i)%n]-z[i])*(z[-~i%n]-z[i++])>0?a<0?-1:1:0);}}

Try it online!

If you actually wanted to use threads you could have used the following: Parallel.For(0,n,j=>{g[j]+=(a=z[(n+~j)%n]-z[j])*(z[-~j%n]-z[j])>0?a<0?-1:1:0;});