text:
Make your code error, but only sometimes!
Your task is to create a program or function which randomly errors. Specifically, there must be a nonzero probability of erroring, but also a nonzero probability of running without error.
An error is anything that causes a program to terminate abnormally, such as dividing by zero or using an uninitialized variable. This also includes runtime errors, syntax errors and errors while compiling. Statements which manually throw an error, such as JavaScript's throw are allowed.
This program doesn't need to do anything if it doesn't error, other than exiting gracefully.
This is code-golf, so shortest answer per language wins.
Note: For this challenge, "randomly" follows the current consensus (so no using undefined behavior or uninitialized memory for randomness), and the program must be capable of producing both outputs if run or compiled multiple times (so a random number with the same seed is not valid)

Related, though not about randomness

Does the error need to happen or not happen due to randomness, as opposed to something like varying state of memory or the current time or similar?

@xnor Randomness

@newbie Following the community consensus for "random"

I think it's a boring challenge. A lot of the answers are doing basically the same thing and there's little room for golfing. Note that downvotes don't necessarily indicate a challenge is ill-specified -- there's close votes for that.

Separately, I'm not so sure it's clear, since two of the upvoted answers rely on the state of memory when the program starts, despite the question in my earlier comment.

I don't really think the current definition of random, although settled, is really clear. For example, the python answer and the brainfuck answer below uses some degree of undefined behavior. The c answer, although fits that definition, won't really crash because of the lack of srand. So, I don't really like challenges based on such loose definitions (and when such definition matters a lot). I would change it to upvote if the question is updated, say, to, the program may or may not crash after a rerun/recompile.

@newbie Fixed. I suppose it was rather dumb on my part to assume answers would follow the established consensus without it being mentioned in the question.

It seems like so many users are posting 1/(random integer) here...

@xnor: agreed, this turns out to be somewhat interesting in some assembly languages, but most high level languages make unpredictable behaviour intentionally difficult other than integer division, or a few other things where 0 is special.

What is "undefined behavior" specified as?

@S.S.Anne I'm just using "undefined behavior" to mean things that aren't random, but still vary or aren't defined in a specification (so, for example, you can't use uninitialized memory or the output of some operation with an output that varies by compiler as a source of randomness)

Some solutions fall into infloop sometimes, is it allowed given doesn't need to do anything if it doesn't error, other than exiting gracefully.?

@l4m2 That's a good question. I'd say it's fine, as I'm pretty sure my original intent was just "you're not allowed to error in the not-erroring case" (also I originally read that as "fall into floop" and wondered what the heck a floop was :p)

I want to attempt something like this for Arduino, but to quote an answer from the Arduino stack exchange: "There are no runtime exceptions. There is only undefined behaviour." (https://arduino.stackexchange.com/questions/189/what-happens-if-there-is-a-runtime-error)

Does this answer your question? Russian Roulette

@user I love how it auto-generated that comment even after I already VTCed it myself :p

@BrowncatPrograms so software. wow

Baby Language, 0 bytes

Try it online!
I knew this could be fun with a non-deterministic tarpit! I looked through the category on the Esolang wiki and found this language...
From the page:

A Baby Language interpreter ignores the input program and does something random. (Likewise, a Baby Language compiler generates a random executable.) As such, whatever you wanted your program to do, there's an (admittedly small) chance that it will actually do it.
The intended use case for the language is to run your program repeatedly until it does what you want. Just like trying to reason with a real baby, this may take quite a while.

So the blank program, and every program for that matter, executes a random program which will therefore randomly error!

Details on TIO link
I used Esolang user Enoua5's source code which generates and executes a random brainfuck program. It's linked on the Esolang page:

An interpreter created in Python 3 by User:Enoua5: View Source

So the TIO link above takes you to Python 3 interpreter is implemented in the header and the actual (blank) code is in the (blank) code slot, which is ignored anyway!
The above interpreter is simply copied and pasted into the header; a multiline comment starting/ending in the header/footer nullifies the actual code.

I was shocked when I realized that such a boring language was created by Ais523...

ais523 is one of the more well-known esolang and code golf folks. I don't know if he's the most well-known, but I can't think of another one who's more well-known.

I'd say Dennis is more well known

I keep trying to run it, but all the random program does is factor RSA primes in polynomial time.

Best comment ever! And we'll never now what it's running...

@Lyxal And Martin Ender, and James, and Mego

Charcoal, 2 bytes
‽‽

Try it online! Link is to verbose version of code. Explanation:
 ‽  Random value (defaults to 0 or 1)
‽   Random element from implicit range

If the first random value is 1, then the implicit range is simply [0], so the random element is just 0, which does nothing (it's implicitly printed, but printing 0 has no effect).
If the first random value is 0 however, then the implicit range is []. This is an illegal input to randrange which therefore throws a ValueError.

Bash + Unix utilities, 12 11 8 bytes
m$RANDOM

Try it online!
If $RANDOM happens to have the value 4, this will run the macro processor m4 (which exits right away on TIO because stdin is empty). If $RANDOM has any other value, you'll get an error because there's no program available via $PATH with the indicated name.

If you want pure bash, with no external utilities, then the shortest I’ve found is my first version (which is 12 bytes long):
((1/RANDOM))

Hooray, an interesting one. :)

Python 3, 15 14 11 bytes
-3 bytes thanks to @newbie!
1/(id(0)%3)

Try it online!
Also 11 bytes:
id(0)%3or a

Try it online!
How: The id of an object varies across different runs. Thus id(0)%3 can be 0, which causes ZeroDivisionError and NameError in the programs above respectively.

-3byte: 1/(id(0)%3)

is it possible for an id to be 0?

@CommandMaster This is very iffy here since id is implementation dependent. In CPython, id is the address of an object in memory, so it's probably can't be zero. I've read somewhere that most Python implementations randomize the starting address of the stack/data to prevent some sort of attack, which is the behavior being used here. But can't find any documentation on this at the moment.

@SurculoseSputum: Python itself doesn't have to randomize addresses; OSes do ASLR of at least the stack, and often also static code/data if possible. (e.g. on GNU/Linux that requires a PIE (Position Independent Executable) which is why distros now configure gcc with that as the default.)  e.g. if you wrote a C program that did printf("%p\n", main) to print the address of main when you run it, you'd see a different address each run.  Unless you compile with gcc -fno-pie -no-pie.  related: 32-bit absolute addresses no longer allowed in x86-64 Linux?

ASLR = https://en.wikipedia.org/wiki/Address_space_layout_randomization.  It's a security feature so exploits like buffer overflows don't know a fixed address to overwrite a return value with.  Unless they can get the target of the attack to "leak" a pointer somehow first.  (Non-executable stacks defeat code injection via returning to the address of the stack, but other attacks like "returning" to the address of system() in libc with a pointer to "/bin/sh" in the right register would still work if an attacker knew that address.)

Techniques like that are the basis of so-called ROP attacks - return-oriented programming.  Finding little snippets of machine code ("gadgets") at fixed addresses can let you chain together a sequence of return values to eventually make something happen.  All of this is much harder to actually exploit if addresses are randomized, instead of identical on every server running the same version of some software.  Ok, that should be enough for anyone to google more if they're curious :P

@PeterCordes good read, thanks!

Can an id be 1? If so, then you could do "a"[id(1)] and shave one byte.

@ChaseRoberts I don't think so, id generally is a big number. If id can be 1, 1/~-id(1) would also work.

Also 11: 0>>id(0)%-3

includes 3 different answers, smallest first
x86-64 machine code "function", 4 bytes
("works" in all 3 modes: 16-bit, 32-bit, and 64-bit.  In other modes, FE 00 is a jmp to eax or ax.)
0000000000401000 <timejump>:
  401000:       0f 31           rdtsc           # EDX:EAX = timestamp counter
  401002:       ff e0           jmp    rax      # "return" with jmp to register

This function can be called with jmp instead of call; it doesn't need you to pass it a return address on the stack.   It uses the low 32 bits of the time counter as a jump target, which might or might not be the correct return address (or somewhere else useful).
The crash possibility is code-fetch from an unmapped or non-executable page, or jumping to instructions that fault (e.g. 00 00  add [rax],al), or to an illegal instruction, like a 1F or other byte somewhere in 64-bit mode, or a multi-byte illegal sequence in 16 or 32-bit mode, that will raise #UD.
RDTSC sets EDX:EAX = the number of reference cycles since power-on (i.e. the TSC = TimeStamp Counter, SO canonical Q&A about it.  Note that it doesn't count core clock cycles on modern x86).  The reference frequency is normally close to the CPU's sticker frequency (e.g. 4008MHz on a nominally 4GHz i7-6700k) so the low 32 bits wraps around in just over 1 second, which is close enough to random for interactive use.  Or every few seconds on chips with lower "base" frequencies.
Assuming a valid return address or other jump target exists in the low 32 bits of virtual address space, we have a 1 in 2^32-1 chance of reaching it.  Or higher if there are multiple useful targets to dispatch to.  (Assuming TSC is uniformly distributed, and fine-grained enough that every 32-bit low half is actually possible.  I think this is the case.)
In 32 and 16-bit mode, every possible address (in the same code segment) is reachable, but 64-bit mode unfortunately still splits the TSC between EDX and EAX so most of the 64-bit (or 48-bit) address space is unreachable.
On systems like MacOS where 64-bit processes normally have all their code outside the low 4GiB of address space, use 32-bit mode.  Linux non-PIE executables are mapped in the low 2GiB of virtual address space so any non-library code will be reachable.

x86 32-bit machine code function, 5 bytes
0000000000401000 <inctime>:
 8049000:       0f 31                   rdtsc           # EDX:EAX = timestamp counter
 8049002:       40                      inc    eax      # EAX++
 8049003:       ce                      into            # trap if OF==1
 8049004:       c3                      ret

On most x86 CPUs, the TSC is fine-grained and really can be any value in the low half, including 231-1.  So incrementing it can produce signed integer overflow, setting OF.
Also works in 16-bit mode (incrementing only AX with this machine code), but not 64-bit mode where into isn't a valid opcode.
x86-64 machine code function, 6 bytes
(same machine code works in all 3 modes, using the default operand size for the mode; 16, 32, and 32.)
divides 64-bit user input by a random number: can overflow or divide by 0.
0000000000401000 <divrandom>:                          # input in EDX and EAX
  401000:       0f c7 f1                rdrand ecx
  401003:       f7 f1                   div    ecx       # return EDX:EAX / ECX
  401005:       c3                      ret

Yup, x86 has a true RNG built in (Intel since IvyBridge, and AMD since at least Zen).
x86 division of 64-bit EDX:EAX / 32-bit ECX => 32-bit quotient and remainder faults (with a #DE exception -> SIGFPE or other OS signal) if the quotient doesn't fit in 32-bit EAX.  With a small dividend, this can only happen on divisor = 0, 1 chance in 2^32.
With function input in EDX:EAX above 2^32-1, small divisors could leave a quotient larger than 2^32-1.  So the chance of faulting depends on the input value.  Specifically, division runs without faulting if ECX > EDX, where ECX is the random divisor and EDX is the high half of the 64-bit input.

rdrand always sets OF to 0 so we can't use 1-byte into conditionally trap on overflow.  (It only sets CF = success, 0 means HW RNG temporarily exhausted).

I can't think of any "unpredictable / undefined behaviour" situation that could actually give different results on different runs, other than meltdown-style timing that depends on microarchitectural conditions.
Some old ARM and MIPS CPUs have unpredictable behaviour that depends on timing if you for example use a multiply where the destination is one of the inputs, or on MIPS I read the result of a load in the next instruction (in the load delay slot).  So for example on MIPS lw $ra, ($a0) ; jr $ra (4 bytes each) might use the original return address in $ra (the link register) if the load hits in cache, otherwise it stalls and we'd return to wherever the load points.

That's cool but I think only the last one is valid. The rest rely on "undefined behavior", so to speak.

@S.S.Anne: I don't see anything "undefined" in the C UB sense of the word.  My source of run-dependent behaviour is a well-defined fast fine-grained counter.  I'm not getting "random" data from reading uninitialized memory or something that Intel's manual say is an "undefined" result (like bsf reg,reg with reg=0) but which is actually the same every time on real hardware.  That's what the question wording is excluding, I think.  I'm fairly confident that on at least some implementations, the TSC can have a low half of 0x7FFFFFFF, or that it can be whatever return address the caller wanted.

@S.S.Anne, sampling a high-frequency counter at an arbitrary time is a perfectly valid source of randomness -- a number of hardware random number generators do exactly that.

So it turns out if you read the result register in the load delay slot it's actually well defined. It reads the previous value. The reason this is unpredictable is the CPU doesn't unwind on interrupt so unless you turned interrupts off the value is trashed. So yeah, outside of an interrupt handler it doesn't work.

@Joshua: Oh, so a cache-miss load on R2000 doesn't stall until after running the load-delay instruction?  Hmm, what about an I-cache miss after the load, before the delay slot?  (Maybe I was mis-remembering or mis-interpreting something I'd read about cache misses, if the source I got this from was correct at all).  You're saying it's well-defined and guaranteed to still let the next instruction read the old value, even with I-cache or D-cache misses, as long as there's no interrupt?  Do you have a link I can add to this and/or other answers if/when I fix this claim I've repeated?

@PeterCordes: Sorry wrong delay. Turns out I was talking about the delay after MUL instruction.

JavaScript (V8), 15 13 bytes
idea and -2 bytes from @apsillers
Uses new Date instead of Math.random, has a \$\frac{1}{9}\$ chance of not erroring:
new Date%9&&a

Try it online!
JavaScript (V8), 17 16 bytes
-1 thanks to @newbie
Math.random()&&a

Try it online!
This has a \$\frac{1}{2^{1074}}\$ chance of not erroring, as Math.random() can occasionally be 0.

Remove the ! to -1 byte.

stretching the definition of "non-zero probability"

It would be interesting to see V8's implementation of Math.random and a demonstration that it really is possible for the result to be 0.0.

@TannerSwett If it was impossible for it to be 0.0, it wouldn't be following the spec, which says the result should be in the range of [0, 1)

@RedwolfPrograms The spec says that the result should be greater than or equal to 0, but it never specifies that it must return 0.  An implementation that never returns 0 is returning values that are greater than or equal to 0, and is compliant with the spec.  I think modern V8 uses xorshift128+, which should have more than enough state/period to sometimes return exactly 0, but I don't know for sure.

"occasionally" :p

@GrandOpener - Incorrect. It very much specifies that. It specifies that all values along that range (which includes 0) must have roughly equal probability of being output. So yes...it must be capable of returning 0.

new Date%9&&a is shorter by three characters (Date can be called as a no-parens constructor and Date objects are generally math'ed as numeric timestamps) and meets the community consensus that single-use modulo-time is generally acceptable as a random number source

@JimboJonny What spec are you looking at?  At https://www.ecma-international.org/ecma-262/10.0/index.html#sec-math.random it says "approximately uniform distribution over that range."  Omitting a single floating point value at the edge is most definitely "approximately uniform distribution."  I don't see any comments about "all values along that range."
In fact the implementation of Math.random in V8 prior to them switching ot xorshift128+ omitted many values from the range of possible floats, but it still had approximately uniform distribution across the whole range.

@GrandOpener - It is a fundamental requirement of having a range of "0 to <1" that it includes a possibility of 0, otherwise you have not met the requirement of using the range specified. A range of ">0 to <1" is not the same thing as a range of "0 to <1". Use the wrong range, and you haven't met the requirement. Period.

@JimboJonny  Your last comment is incorrect.  Is the set of numbers (0.2, 0.3, 0.9) in the range [0, 1)?  Are they greater than or equal to zero and less than one?  Of course they are.  There is no "fundamental requirement" that a set of numbers in a range cover the entire range.  Covering the entire range is a separate requirement from being inside the range, and to my knowledge the spec has never made any coverage requirements.  It requires being inside the range and having "approximately" uniform distribution.  A function that never returns 0 can meet both of those requirements.

@GrandOpener Regardless of whether it's implemented in such a manner, if the JavaScript spec says it can be in the range of [0, 1), I believe it would be valid to assume 0 is possible.

@RedwolfPrograms Agreed.  Code should definitely assume that 0 is possible and be prepared for it.

@GrandOpener -  If 0.2-0.9 is the maximum range, then you are not expressing a range of 0 to <1. The spec clearly states that you are to express the full range when it tells you that all possible values within the range must be approximately equally represented.

@GrandOpener - Also, please read more carefully. I never said that any randomly selected set from 0 to <1 would include 0. I said a range of 0 to <1 includes the possibility of 0. If you create a function that cannot return zero, then "gives a range of 0 to <1" is not an accurate description of that function, as it overstates its possible range. Even without the next statement in the spec about all values in that range being roughly uniformly distributed your argument would still be poor. With it, it's completely untenable.

><>, 3 bytes
x,;

Try it online!
My first submission in ><>, very simple

J, 6 byte function
z^:?@2

Try it online!
If y is the argument, z^:v conditionally returns the result z y if v y returns 1.  Otherwise it returns y unchanged.
? 2 will return 0 half the time and 1 half the time.
No matter what argument we pass to this function, it will be converted into the constant 2 and then passed to z^:?.
So half time the result will be 2, and half the time it will error when trying to execute the non-existent verb z.
alternative full programs
Though these may look like snippets they should count as full programs in the context of this challenge.
4 bytes thanks to Bubbler:
q:?2

5 bytes thanks to Adam:
0^.?2

Wouldn't 0^.?2 work?

My first instinct was that that was a snippet, but on 2nd thought it probably counts as a valid program.

q:?2 also works (q:0 is a domain error).

Python <= 3.7, 25 24 bytes
lambda x:id(x.__dir__)
Included for its weirdness rather than its brevity. This will cause a segmentation fault in obscure cases involving deep recursion. A fix is being applied, but only to python versions >=3.8.
The crash only occurs on cleanup when exiting the interpreter, but an example of how to call this function (and reproduce the segfault) can be found here: Try it online!

Welcome to Code Golf, and nice first answer! The question doesn't involve taking any input, so I'm not sure how to call your function? Could you include a Try it online! link to demonstrate?

Thank you, have edited my answer — please let me know if there are any other community guidelines I'm missing!

Lost -A, 9 bytes (Probability 1/2)
\\\\
%1-@

Try it online! Verification1
As an introduction to Lost for anyone unfamiliar, Lost is a 2-D programming language in which the start location and direction are selected at random at the beginning of the program.  This source of randomness is what we use in this challenge.
We want some start locations that will cause an error and some that will not.
The program will error if it starts on the character % going right (or down).  In this case it will encounter the ops %1-@ before termination.  This pushes -1 and exits.  Since -1 is not a valid character code this causes an error in character mode.
The program will terminate safely if it starts on the character % going left (or up).  In this case it will encounter the ops %@ before termination.  This does nothing and exits.
Since we have a path that errors and one that does not, all that remains is to know that every path terminates, which is guarenteed by the \\\\.  So this program is valid.
We could shorten this significantly if there was not a termination requirement.  The program :
%1-@

Try it online!
Either errors, terminates cleanly or loops forever, and it selects which at random with the following probabilities:

1/2 Non-terminating
1/4 Errors
1/4 Terminates cleanly

1: For verification we turn off character mode.  All outputs containing negative numbers are the ones that will error in character mode.

Could this be golfed by erroring through running out of memory?

@emanresuA I mean %1@ should eventually run out of memory.  (Probably, I ran it for like 10 minutes and it didn't crash, it should be allocating new memory but it would take a very long time to crash anyway)  However I don't think this is allowed.

My interpretation of that rule is that you can't simultaneously assume unlimited memory and assume finite memory (or similar) however since this program doesn't have to handle any input it's perfectly fine to have it push 1s until it runs out.

INTERCAL, 10 bytes
DO%9GIVEUP

The only way to terminate an INTERCAL program without an error is to execute a GIVE UP statement -- running off the end of the source code is a runtime error.  This program uses INTERCAL's probabilistic execution feature to have a 9% chance of successfully exiting; the rest of the time, it errors out:
ICL129I PROGRAM HAS GOTTEN LOST
        ON THE WAY TO WHO KNOWS WHERE
        CORRECT SOURCE AND RESUBNIT

Is this a serious programming language? How old is it?

@S.S.Anne, INTERCAL was one of the first, if not the first, esoteric programming languages, having been created in 1972 as a parody of various programming languages in use at the time.

C (gcc), 17 16 bytes
Random across function calls.
Saved a byte thanks to newbie!!!
f(i){i/=rand();}

Try it online!
Has a \$\frac1{\text{RAND_MAX} + 1}\$ chance of failing with Floating point exception.
Random across runs.
C (gcc), 19 bytes
f(i){i/=(int)&i%3;}

Try it online!

i;f() => f(i)

@newbie Nice one - thanks! :-)

Why is it necessary do i/= rather than i/? Does the compiler optimize away the expression as useless otherwise?

@xnor Yup, the compiler simply chucks the code away as dead-code.

"so a random number with the same seed is not valid"

@S.S.Anne: I think we can justify this because it's a function not a program.  If called multiple times, it will generate new random numbers and update the seed, not reusing the same seed for every call.  p.s. I posted an x86 machine code answer to this which you might find interesting.  My first idea was div by rdrand, but came up with some less boring stuff.

@S.S.Anne No more rand().

rand() was better in some ways.  On normal implementations, if this was called in a loop the address of i will be the same every time.  But yes, across different invocations of the same program, stack ASLR randomizes the high bits so mod 3 will work.  (On my x86-64 Arch Linux desktop, printf("%s\n", &i); shows the address of a local across runs is randomized as much as possible, only the low 4 bit being constant (because the ABI requires 16-byte stack alignmnent).  Unlike file-mapped and BSS segments where ALSR has page granularity.  (Although %3 would still work, I was just curious)

@PeterCordes Interesting! :-)

You have to use rand(), following the definition for randomly: "Use your language's built-in random number generator,
Use /dev/random, or
Create a RNG that is equivalent to a standard RNG (such as the Mersenne Twister)."

@Noodle9: You might want to include both answers: one for random across program invocations (address mod 3), one for random across calls (rand()).  Neither are universal.  Using time() instead of rand() could sort of work, but unless you pass time(0) to avoid just returning -1 from EFAULT it's not really valid.  And it only faults if run with the system clock set to 1970-01-01 00:00:00 +0000 (UTC).

@PeterCordes Good idea - thanks! :-)

18 bytes f(i){i/=(i=&i)%3;}

><>, 5 bytes
v
x+;

Try it online!
Explanation
The pointer will be represented by a hashtag symbol. It will replace in bewteen these spaces:
v
x + ;

Ok, explanation start.
The instruction pointer goes down.
v*
x + ;

The step is randomized.
v
x*+ ;

Case 1: Error
v
x +*;

It tries to pop two items, but there is nothing on the stack. Cue error.
Case 2: Exit gracefully
v
x + ;*

It loops to the right side, and ends on the semicolon.

Why not just x+; for 3 bytes?

I think it only goes perpendicular.

I’m not sure what you mean by that, but it appears another ><> answer in this thread has done that 3 byter (well, something tantamount to it).

APL (Dyalog Unicode), 3 bytes
÷?2

Try it online!
(Requires IO←0)
Inverse of random boolean (any range including 0 would work). I expect this'll be a common technique...
÷    ⍝ Inverse
 ?2  ⍝ Random number in [0,1]

PowerShell, 10 bytes
1/(random)

Try it online!
get-random returns an int between 0 and 0x7FFFFFFF so it'll eventually divide by 0. Maybe...

Google Sheets, 8 bytes
=0/RAND(

Google will a closing parentheses automatically to give =0/RAND().
Since RAND() produces a uniformly random between 0 inclusive and 1 exclusive and to 15 decimal points of accuracy, is has a 0.0000000000001% chance of returning exactly 0 and causing the #DIV/0! error.

Metatape, 4 3 bytes
x?(

-1 byte thanks to Hactar, the language creator, on Discord
Initially, the tape head is within a tape and pointing to a null cell. The command x exits the current cell, creating a new tape and putting the initial tape within it. Now the tape head is within a tape and pointing at a tape.
The ? command then generates a random bit, setting the current cell of the tape to null if it is 0 and doing nothing if it is 1. Then the ( command jumps to the next | or ) characters in the code if and only if the current cell is null, and does nothing otherwise. Thus, if the bit generated by ? is 0, the interpreter will throw an error, as there is no | or ) to jump to. On the other hand, Metatape does not implicitly check for every ( matching with a ), so if the bit generated by ? is 1, no error will be thrown.
EDIT: After further clarification with the language's creator, I found that the last sentence I wrote may not apply to all interpreters, and thus this answer might not work for all interpreters. Oops.

Z80 machine code, 6 5 bytes
I finally managed to reduce it to 5 bytes and also make it more well-behaved at the same time:
ED 5F B7 C0 76

Explanation:
ED 5F   LD A, R  ; get non-deterministic value (00-7F) from memory refresh register
B7      OR A, A  ; set Z flag if A is zero
C0      RET NZ   ; return normally, unless we were unlucky and got zero
76      HALT     ; halt the CPU

Alternatively to the HALT instruction RST could be used to call an error handler.
Other approaches that use 6 bytes and fail in a less well-behaved way:

ED 5F 17 32 06 00

Explanation:
ED 5F      LD A, R       ; get random value (00-7F) from refresh count register
17         RLA           ; rotate left one
32 06 00   LD (0006), A  ; write the byte immediately following this instruction.

There is a chance that this results in one of the conditional RET instructions to be written after the code, which returns normally if the condition happens to be met, which is the case for RET NZ (C0), RET NC (D0), RET PE (E8) and RET M (F8). Otherwise, a random instruction is executed and the program counter runs into whatever is in RAM after that, failing horribly. If bit 8 of the R register was somehow set (which doesn't normally happen), or any instruction with an opcode up to 7F would somehow end the program normally, this could be reduced to 5 bytes. The address operand in the last instruction must be set relative to where the code is actually located.

ED 5F B7 28 FE C9

Explanation:
ED 5F   LD A, R  ; get non-deterministic value (00-7F) from memory refresh register
B7      OR A, A  ; set Z flag if A is zero
28 FE   JR Z, -2 ; infinite loop if Z-flag is set
C9      RET      ; return

An infinite loop might not really count as an 'error' though. An alternative solution (same length), inspired by Peter Cordes' x86 solution, is to mess with the return address:

E5 ED 5F AC 67 E9

Explanation:
E5      POP HL   ; get return address from stack
ED 5F   LD A, R  ; get non-deterministic value (00-7F) from memory refresh register
AC      XOR A, H ; this will only leave H intact
67      LD H, A  ;       if R was zero by chance
E9      JP HL    ; jump to (probably broken) return address

Welcome to the site.  Could you include a copy of the code without comments or extraneous elements?

sure, like this?

Yeah that's good.  Normally a user won't get a message unless you put an @ before their name in your comment btw.

@AdHocGarfHunter good to know! Thanks for helping me along :)

Zsh, 8 7 bytes, \$ \approx \frac{1}{10}\$ chance of success
>$$
<*4
Attempt This Online!
Determines whether the process ID ends in 4.

Jelly, 5 bytes
I haven't used Jelly for a long time, it's time for me to pick it up again.
2X’İX

Try it online!
Explanation
2X    Pick random from [    1,  2]
  ’   Decrement:       [    0,  1]
   İ  Reciprocal:      [  inf,  1]
    X randrange 1      [Error,  1]

Octave / MATLAB, 13 bytes
det(0:rand*2)

Try it online!
How it works
rand produces a random number with uniform distribution between 0 and 1. So the range 0:rand*2 may be 0 (1×1 matrix) or [0 1] (1×2 matrix). det tries to compute the determinant, which is only defined for square matrices.

Try nan(rand) or inf(rand) in MATLAB for nine bytes which works only for rand values zero and one. In Octave, we can do better with 0(rand) for seven bytes.

@AravindhKrishnamoorthy Thanks for the suggestion, but rand draws numbers from the open interval (0,1) (both in Matlab and in Octave), so it wouldn't work, would it?

Oh indeed! Then we've to use randn and waste a byte :(

@AravindhKrishnamoorthy That works, but it relies on the fact that the ideally continuous random variable is actually discrete, and thus it has some non-zero probability of producing an integer. I say "but" because it's a "dirty" trick, but then golfing is all about that kind of tricks. Anyway, it's a totally different approach, you should post that yourself (and will get my upvote)

05AB1E, 4 bytes
Î)ΩE

Try it online!
Î        Push 0 and input, ie. [0, ""] b/c input blank
 )       Wrap total stack to an array
  Ω      Push random element of a, ie. [0, ""]
   E     For-loop in [1 .. a]

  where a is the top of the stack
Errors when "" is randomly selected & for loop is attempted on it.
Proceeds when 0 is randomly selected & for loop is attempted on it.

Is there any single character function that errors with 0 and works with 1? Because then you could replace Î) with T

I didn't find one @CommandMaster

3 bytes: ®ΩE. ® pushes -1 by default, and then the Ω choses either - or 1

SQL (Oracle), 3733 Bytes
SELECT 1/INSTR(UID,3) FROM DUAL;

Fails if the User Session doesn't have a 3 in it.
Edit: Was using SYSDATE, but UID is shorter.  Although I'm kinda sad.  I liked having a function that worked in March, but not February.

Although this answer is interesting, the requirements state it must be random. I'm not very good with SQL, but wouldn't SELECT 1/RAND() work (errors if RAND() is 0, which has a very, very small chance of happening)?

@RedwolfPrograms RAND isn't a valid function in Oracle.

I have not used oracle for ages. But would the work instead ? x int:=1/INSTR(UID,3)

R, 15 14 bytes
if(rexp(1)>1)a

Try it online!
R doesn't throw errors often. In particular, dividing by 0 doesn't lead to an error (1/0=Inf); nor does attempting to access an out-of-bounds entry in a vector (outputs NA with a warning). Two easy ways to get an error are: 1. an if statement gives an error if it is not fed a TRUE/FALSE value; 2. trying to access a non-existing object.
Here, if the random variate is >1, we try to access a which doesn't exist, so R throws Error: object 'a' not found. If the random variate is <1, nothing happens.

Previous version:
R, 15 bytes
if(T[rexp(1)])1

Try it online!
Here, rexp(1) generates a realization of the exponential distribution, i.e. a random value \$x\in\mathbb R_+\$.

if \$x<1\$ then T[x] is an empty logical vector and R throws an Error: argument is of length zero
if \$1\leq x<2\$ then T[x] is TRUE and R outputs 1 without error
if \$2\leq x\$ then T[x] is NA and R throws an Error: missing value where TRUE/FALSE needed

An error is thrown with probability \$1-e^{-1}+e^{-2}\approx 0.767\$.

Compiled Stax, 28 27 25 bytes
Requires 116 TB RAM, and ulimit -s set to 116TB.
8000000000000{1-cy{}?}Y!

At present time, obvious ways to golf this fail to compile due to the compiler not supporting the requisite language feature.
This program attempts a recursive block invocation with a depth of 8000000000000, which in turn tries to create 8000000000000 16 byte stack frames on the runtime stack. This either succeeds or fails with probability of about .5 depending on how far apart the program and the top of the stack are in address space are.
I am using the environment's RNG that is actually documented to be random to make this fault or not fault.
And recursive said there's no such thing as nondetermistic stax.

@RedwolfPrograms: But it is random. The top-of-the-stack address is documented to be randomized.

Oh, sorry. I'm just used to people not reading the spec and posting answers that abuse undefined behavior. Nice answer!

Taxi, 209 bytes
Go to Heisenberg's:w 1 r 3 r 1 l.Pickup a passenger going to Magic Eight.Pickup a passenger going to Magic Eight.Go to Magic Eight:s 1 r 1 l 3 r.Pickup a passenger going to Cyclone.Go to Taxi Garage:e 2 l 2 r.

Try it online!
Ungolfed and commented:
[ Heisenberg's produces random integers ]
Go to Heisenberg's:w 1 r 3 r 1 l.
[ Pickup two random integers ]
Pickup a passenger going to Magic Eight.
Pickup a passenger going to Magic Eight.
[ Magic Eight compares two numeric passengers ]
[ It returns the first passenger if it is less than the second and no one if it is not ]
Go to Magic Eight:s 1 r 1 l 3 r.
[ Try to pickup a passenger, which will error if there isn't anyone waiting ]
Pickup a passenger going to Cyclone.
[ Return to the garage to avoid getting the "you're fired" error ]
Go to Taxi Garage:e 2 l 2 r.

Try the ungolfed and commented version online!

Knight, 3 bytes
/1R

Try it online!
Has a roughly \$\frac{1}{65536}\$ chance of dividing by zero.
The classic 1/rand() trick. Assumes that dividing by zero throws an error, of course.
Uncommenting the line at the top of the header code will srand with a seed that will cause glibc's rand() to return 0xe7d0000, which when masked by 0xFFFF, results in 0.

><>, 4 bytes
The ! skips the next instruction, even if it would give an error.
The x set the pointer's direction to a random direction. It can make it go up or down but if the pointer reaches the edge then it wraps around.
The ; ends the program.
The { can be replaced with any character as long as it's not a valid command in ><>.
!{x;

https://tio.run/##S8sszvj/X7G6wvr/fwA
Try it online!

Welcome to the site! x;{ does the same thing using the wrapping.

what language is this? brainf?

C (clang), 24 bytes
main(i){i/=(time(0)%3);}

Try it online!
C, 20 bytes
main(i){i/=time(0);};

Will crash once every +/- 68 years.
https://en.wikipedia.org/wiki/Year_2038_problem

Aussie++, 78 bytes
G'DAY MATE!
IMPOHT ME FUNC ChuckSomeDice;
ChuckSomeDice(0,ChuckSomeDice(0,2));

Tested in commit 9522366.
ChuckSomeDice is the only way to get a random number, but it behaves a bit interestingly:

If either argument is a finite non-integer, it's truncated to an integer.
Inputs are capped to be no greater than 9223372036854775296.
NaN is treated as 0.
If both arguments (let's call them x and y) are integers, and y is greater than x, it gets a random integer in [x, y).
If x is less than y, it prints OI MATE, CAN YA FUCKIN' COUNT?? START MUST BE LESS THAN END!! to STDERR, but continues execution.
If x is equal to y, it panics. See this Github issue.

The result is stored as a double, so calling e.g. ChuckSomeDice(9223372036854775295, 1/0) only ever produces either 9223372036854775000 or 9223372036854776000.
TL;DR: The arguments can't be equal, and behind the scenes it's likely casting between i64 and f64.
So, I get either 0 or 1 randomly, and then get a random number between 0 and the result. If that was also 0, it panics. If that was 1, it returns 0.

Wolfram Language (Mathematica), 17 bytes
1/RandomInteger[]

Try it online!

Pyth, 3 bytes
-1 thanks to FryAmTheEggman.
lO2

Try it online!

Using l is shorter than /1, though there still might be something better.

Erlang (escript), 22 bytes
Just like the other answers...
f()->1/rand:uniform().

Try it online!

Keg, 3 bytes
~~/

Try it online!
This works by pushing two random numbers onto the stack ane dividing them. If the second number is 0, then it errors out.
There is indeed a chance for the second number to be 0, but it is highly unlikely that it will be, as the random range used is quite large. But highly unlikely != zero.
If I were to estimate the odds of erroring out, I'd say it'd be something like 1 in ((int("9"*3234) ** 2) + 21) * 2.

Hey, look, it worked: TypeError: integer argument expected, got float

With a higher chance of erroring... ~:/

@petStorm that's still the same chance.

Is "highly unlikely != non-zero" intended to be "highly unlikely != zero"?

Ruby, 9 bytes
1/rand(2)

Try it online!

C (gcc), 28 bytes
f(i){srand(&i);i/=rand()&1;}

Crashes approximately every other time it's run. Abuses ASLR.
Try it online!

Since we ultimately rely on &i for randomness, why not get rid of the rand stuff? f(i){i/=(int)&i<0;} works.

@SurculoseSputum Because then it would violate the rules for "randomly".

I just reread the specification - apparently this challenge is much different than I thought...

@SurculoseSputum: I think that's a constant, but such an expression should exist.

-1 byte: f(i){i/=rand(srand(&i))&1;}

Bash, 1/32767 chance of success, 12 bytes
exit $RANDOM

PowerShell Windows, 10 bytes
ps(random)

get-random returns an int between 0 and 0x7FFFFFFF so it'll eventually match some PID and ps will get the process that are running on the local computer. Maybe...

PowerShell Linux, 11 bytes
gps(random)

TIO  does not work because System.UnauthorizedAccessException. Please use your own Powershell. :)

Batch, 11 bytes
%random:1=%

Has a probability of 1/65536 Corrected by @Neil, 5/32768 (~0.0015%) to not generate an error.
Edit: Alternatively,
%random:~1%

5/32768, I think? (1, 11, 111, 1111 and 11111 won't error, and %random% only goes from 0 to 32767.)

@Neil you're right, will fix that

Red - 24 bytes
x: now/time 1 / x/minute

Welcome to the site, I've tried to correct the code formatting in your answer.  You can revise it if I have something wrong.  Let me know if you are having trouble with the formatting.

05AB1E, 3 bytes
®ΩF

Try it online! Has a \$\frac12\$ chance of erroring.
®ΩF  # full program
  F  # for N in (0, ...
 Ω   # random element from...
®    # register_c (starts at -1)...
     # (implicit) split into separate characters...
  F  # ... - 1)...
     # (implicit) do nothing
     # (implicit) end loop

-1 split into separate characters is ["-", "1"], so it picks a random element from there. Either it picks 1 and does nothing once, or it picks -, tries to loop - times, and crashes. Unlike ï, the built-in integer conversion function, it doesn't handle errors (if it can't be converted to an integer). So, it throws an error.

Ahead, 4 bytes
50/50 chance of a divide by zero error. X causes the head to go in a random cardinal direction, / is obviously division, and @ ends the program. Because of edge bouncing, the head traveling up or left is the same as it traveling down or right since it's in a corner.
X/
@

Try it online!

Ruby, 10 bytes
1.div rand

Can't do 1/rand, since 1/0.0 in Ruby is Infinity, not an error.
Try it online!

Vyxal, 3 bytes
∆Ṙl

Try it Online!
I  think this has a \$\frac{1}{2^{19937}}\$ chance of not erroring, but I'm not sure - Vyxal is written in Python, so it's whatever chance python's PRNG has of returning 0.

Minim, 6 Bytes
[R*S].

Accesses memory at index RandomNumber times MemorySize.
R is between 0 and 1 inclusive, and S is the memory scope size in elements. If R = 1, then the index will be out of bounds, and throws an error.
GitHub Repository

JavaScript (Node.js), 17 15 14 bytes
new Date%2?a:0

Errors if current millisecond is odd
new Date returns current epoch time
%2 modulo 2, returns 1 if odd, 0 if even
if it's a truthy value (1), a will throw as it's an undefined variable
Try it online!

new Date should work instead of Date.now(), saving 2 bytes. You could also replace the throw 1 with something like a (which causes a ReferenceError).

i never knew new doesn't require (), i completely forgot about reference error lol

You can save a byte with new Date%2?a:0

ah yes, ternary, the thing i overuse the most in js

@Ectogen Or another with new Date%2&&a, but then it's identical to mine

haha yeah, i saw that, && only does the next thing if the first thing is truthy

Japt, 3 bytes
Feck it, may as well post this. Similar in concept to but derived independently from Etheryte's solution. Predicated on the fact that JavaScript's toString method can only handle bases 2-36 so it, therefotre, has a 20% chance of throwing a RangeError (toString() radix argument must be between 2 and 36) - change the A to alter the odds of an error occurring.
sAö

Test it (errors are displayed below the output field)
sAö     :Implicit input of integer U, defaulting to 0
s       :Convert to string in base
 A      :  10
  ö     :  Random integer from range [0,A)

Trilangle, 5 bytes
Contains invalid UTF-8, so I can't post it here. Instead, have a hexdump reversible with xxd -r:
00000000: 2437 40f7 2e                             $7@..

When reading the file, the interpreter starts by loading it as UTF-8 and converting it to a list of 24-bit integers (effectively UTF-32 on many machines due to struct padding). If it encounters an invalid UTF-8 sequence, it doesn't immediately error; rather, it takes that character as U+FFFD and keeps going. Once it's done, it makes the program length be a triangular number by appending . (U+002E) as necessary.
Currently, the interpreter stops with an error when it attempts to execute a character that isn't a valid opcode, but this behavior isn't specified. Any invalid opcode I choose could be added in the future, invalidating my answer.
Any character, that is, except for U+FFFD. When the interpreter attempts to execute 0xfffd, it writes an error message to STDERR and exits with code 1:
Unicode replacement character (U+FFFD) detected in source. Please check encoding.

The sequence f72e is invalid UTF-8, so when the program is loaded in it looks like this:
  $
 7 @
� . .

The $ instruction pushes a random integer to the stack, uniformly distributed in the range [-8 388 608, 8 388 607]. Then, 7 is a branch instruction based on the sign of the value on top of the stack. If the value is positive, the IP reaches the @, terminating the program gracefully. If the value is negative, the IP reaches the invalid character, triggering the encoding error.

Pip, 4 bytes
VRCk

Attempt This Online!
Explanation
k is a preinitialized variable containing the string , . RC chooses one of its characters at random, and V attempts to evaluate it as Pip code. If the space was chosen, the evaluation is successful and returns nil. If the comma was chosen, the interpreter crashes:
Fatal error during execution: Parsing error while evaluating ",": Hit end of tokens while parsing expression
Program terminated.

A bit boring, but /r works if you add -w

@emanresuA That's a warning, not an error--the difference being that it doesn't cause the program to terminate abnormally, as specified in the challenge.

brainfuck, 2 bytes
Sometimes segfaults, sometimes doesn't.
<.

Try it online!

Isn't this implementation based, not random?

sometimes malloc allocates a bigger page so you can read something before the tape, and sometimes malloc allocates smaller page so reading something before the tape segfaults

personally after mashing the run button for a while, I've seen two segfaults so far

That's just because you're mashing the run button too fast. Also, this uses neither options 1, 2, nor 3 from the meta consensus.

+[<[-]+] doesn't segfault on TIO, so I don't think this is valid. In fact, if the [-] is removed, it halts, so the tape is seemingly looped.

Windows Batch, 1715 bytes
set/a1/%random%

I don't think you need the x=.

indeed, -2 bytes thanks to @Neil

VBA, 46 42 35 25 13 bytes
Thanks to @Taylor Scott
?1/Int(9*Rnd)

This code only works inside the Immediate Window.

If you make this an immediate window function, you can get it down to ?1/Int(9*rnd)

@Taylor Scott, I didn't know you can do that. Thanks, mate.

Befunge-98 (FBBI), 4 bytes
?@
=

Executing = is of the only ways I can get Befunge to actually error (a / won't work there because 0/0 evaulates to 0 in Befunge-98 and asks the user in Befunge-93).
Try it online!
The ? turns the IP in a random direction. If it goes horizontally (1/2 chance), it hits the @ and terminates successfully. If it goes vertically, it hits the = and uses the empty stack (interpreted as the empty string) as the argument. This throws a segfault in FBBI (which implements = as a C system() call).

Jelly, 4 bytes
9XRy

Try it online!
Errors roughly 55% of the time
How it works
9XRy - Main link. Takes no arguments
9X   - Generate a random number from 1 to 9
  R  - Get the range from 1 to that number
   y - Translate, by pairs

y splits a flat array [a, b, c, d, ..., y, z] into pairs, [[a, b], [c, d], ..., [y, z]], then replaces a with b, c with d etc in the right argument. However, if there are an odd number of elements in the array, it attempts to pop from an empty list when doing the substitution, which errors.

Japt, 3 bytes
Throws if seconds in a new date object are less than 2 or more than 36 since values outside of that range are not valid for base conversion in Japt.
sKb
s   // Try to convert the input to a string in base
 K  // new Date()
  b // get seconds.

Try it here.

Nice! I had something similar in sAö.

Java (JDK), 18 bytes
a->1/Math.random()

Try it online!
Well yeah, essentially the answer everyone gave but I didn't see Java yet. For the completeness.

Perl 5, 10 bytes
1/(time%2)

Try it online!

Pyt, 2 bytes
ɽ⅟

Try it online!
ɽ         gets a random 32-bit integer
 ⅟        takes the multiplicative inverse; implicit print

Errors on division by 0

GolfScript, 12 11 bytes
2rand{/}1if

Try it online!

Fortran (GFortran), 16 bytes
j=1/mod(i,2)
end

Try it online!

Volatile, 3 bytes
~~/

~ pushes a random number onto the stack (which may include zero), and / pops two numbers and divides them. If the first ~ pushes a zero, then the program errors.

(plain) pdfTeX, 34 bytes
\ifcase\pdfuniformdeviate9}\fi\bye

Perl 5, 8 bytes
1/($$%2)

Here $$ is current PID.
Try it online!

The current PID is not considered random for this challenge.

Commodore BASIC (Commodore C64/128, VIC-20, C16/+4, PET, Ultimate64, THEC64 etc)
0 on6*rnd(.)goto10,20,30,40,50:goto
10 print"working":goto
20 print"working":goto
30 print"working":goto
40 print"working":goto

I've put a prompt in just to show that it does work sometimes too. Essentially, it breaks when the random number generated is rounded to 5 (it generates floating point numbers, but the BASIC interpreter ignores the decimal places).

C (gcc), 30 bytes
main(){int*x=0x12345678;*x=1;}

Try it online!
Will segfault most of the time, but in the case that the program memory gets allocated to that address, it will NOT segfault.

This isn't considered random for this challenge, similarly to uninitialized memory or your program's PID


text:
Check if hand from card game "Rooster" is valid for the second stage
Here in Russia, we have a little-known card game with the name, when translated directly, means Rooster.
The cards used are two full 54-card decks of playing cards from 2 through aces, with jokers. The game for each player divides into two stages. In the first stage, each player has 14 cards dealt, and with those cards has to get 51 or more points with card combinations.
Rules:
1.Each combination has to be at least three cards long, with no cards repeating, and can be either:

A combination of cards of the same value (not points), for example:

        Ace of spades, ace of hearts, ace of clubs
        Six of hearts, six of clubs, six of diamonds, six of spades

A combination of cards that are in a row, like a straight in poker, examples:

        Jack of clubs, queen of clubs, king of spades, ace of hearts
        Seven of spades, eight of diamonds, nine of clubs
        Ace of diamonds, two of clubs, three of hearts, four of diamonds, five of spades

Your hand score is calculated by the sum of points in every card combination according to the chart below:

2-10: according to the cards face value for each card (For example, Three of spades is 3 points)
Jack,Queen,King: 10 points for each card
Ace: 1 point if used before a Two, otherwise 11 points for each card
Joker: 0 points

Jokers can substitute any card in a combination, but cannot be used more than once in each combination. The cards they substitute cannot be used again in the same combination.
Cards cannot be used twice. If you used a card, you can't then use it in a different combination
But remember, since the deck is two 54-card decks, duplicates of one card are possible, and, if duplicates are in a hand, using one card will not forbid you from using the other duplicate.

The task:
Taking a hand of 14 cards, output one of the possible things:

A truthy value if the cards given can form combinations in such a way that your hand score is more or equal than 51
A falsy value if your hand does not reach the score of 51

Input:
Each card is given in a format VS, where:

V is the face value. Possible values: [2,3,4,5,6,7,8,9,T,J,Q,K,A]
S is the suit of a card. Possible values: [S,H,D,C,J]
A joker will be represented as JJ

Your input may be in any form you wish, as long as each card values are not separated. For example:

A list of cards. (['TS','3H','JJ','9C',etc...])
Cards separated from each other with a whitespace. (TS 3H JJ 9C etc...)

Output:
Either:

A Truthy/Falsy
A 1/0

This is codegolf, so lowest bytecount for each language wins! I hope the rules are clear, and good luck!
edit 1: got mixed up in terminology

That looks like a nice challenge, but it would be great to add some test cases.

@Arnauld, currently working on them)

May a Joker be used as, say, a 5th Ace?

@Arnauld No, will clarify that substituted joker cards are still counted and can't be used in one combination

Instead of like a street in poker you meant like a straight in poker, and instead of Rooster you meant.. oh never mind! T_T

@Noodle9 XD had the same issue while translating, will change street to straight

FWIW, this seems similar to Rami in French, or Rummy in English.

Aside: a street in poker is very different to a straight. It's not even about the ranking of a hand. It's about the different stages of the game when cards are dealt by the dealer.

Ruby, 415 376 bytes
->a{s=[*2..9]+[10]*4+[11,1]
g=->d,j{x=0
65.times{|r|v=r/5;r%=5
p=w=0
c=d*1
y=[r,c[v]/5,c[v]%5].min
z=v+1+r
r<3?z<13?(v-1).upto(z){|n|p+=s[n];c[n]>4?c[n]-=5:w+=1}:w=2:r>y+1?w=2:(p+=s[v]*r;c[v]-=y*5;w=r-y)
w>1||w>j||(x=[p+g[c,j-w],x].max)}
x}
b=(0..12).map{[]}
a.map{|i|b["23456789TJQKA".index i[0]]<<i[1]}
h=b[9].size-(b[9]-=[?J]).size
b.map!{|i|i.size*5+(i&i).size}
g[b,h]>50}

Try it online!
Revised version, using recursive search tree instead of brute force search. This version runs to completion on TIO.
The TIO generates random test cases. It is interesting to modify the x>50 to simply x to see the raw scores achieved. Sometimes the way to achieve the best score is not obvious and it can take a moment's scribbling to work out manually how the computer got as high a score as it did.
Explanation
Cards are taken as an unsorted array a and the suit letters are parsed into 13-element array b, one element for each card value. After jokers have been removed and counted separately, the total number of cards and number of distinct suits are stored as a single number 5*total + distinct suits. Distinct suits are only important when dealing with n of a kind type groups: the number of available cards is max(total cards, distinct suits) plus jokers.
Searching is done recursively by "nested" function g. There are 5 different types of groups of cards to search for, as below. Note that the best use of 34567 would be a 5 straight but if a second 5 is available the best use would be two separate 3 straights 345 and 567, so greedily assigning to the largest possible group is not always the best strategy. Instead we look for groups separately. Straights of 6 and over will be found as a combination of shorter straights.
Type          corresponding value of r%5
3 straight    0
4 straight    1
5 straight    2
3 of a kind   3
4 of a kind   4

There are 13 possible starting values for each type, so the total number of distinct possible groups to search for is 13*5=65 (some straights are not possible with the highest starting values.)
When function g finds a group, it passes the remaining cards on recursively to a new instance of itself, then compares the score of the group it found (plus any additional groups found by recursion) with the highest score found so far in variable x, and updates x if necessary.
Return value of recursive function g is the highest score found. Return value of outer function f is true or false from g>50.
Commented code
->a{s=[*2..9]+[10]*4+[11,1]             #14-element array of card scores. Final element is ace low, accessed as s[-1]
g=->d,j{                                #function g takes an array of card data, and a joker count as input
  x=0                                     #largest score found so far is 0
  65.times{|r|v=r/5;r%=5                  #iterate through 13 possible card values and 5 possible group types
  p=w=0                                   #p=points for this iteration;w=wildcards required
  c=d*1                                   #make a copy of d for this iteration
  y=[r,c[v]/5,c[v]%5].min                 #y=number of cards removed by successful n of a kind. [cards required,cards available,distinct suits].min
  z=v+1+r                                 #z=top value of straight
  r<3?                                    #if r<3 consider a straight
     z<13?(v-1).upto(z){|n|               #if z is in range (no more than ace high) iterate through cards
       p+=s[n];c[n]>4?c[n]-=5:w+=1}:      #add score to p. If card available, remove from c, else increment wildcards required
     w=2:                                 #if z out of range set wildcards to 2 to indicate failure
     r>y+1?w=2:                           #if r>2 consider a straight. If insufficient cards for r with 1 joker, set w to 2 to indicate failure.
     (p+=s[v]*r;c[v]-=y*5;w=r-y)          #add score to p, remove cards from c, set wildcards required
  w>1||w>j||(x=[p+g[c,j-w],x].max)}       #if wildcards required no more than 1 or jokers available, take the score, sum with results of further recursion and compare with x
  x}                                      #return x, the highest score of all 65 iterations
b=(0..12).map{[]}                       #make a 13 element array to store totals of cards
a.map{|i|b["23456789TJQKA".index i[0]]<<i[1]}   #add the suit letter for each card to b
h=b[9].size-(b[9]-=[?J]).size           #any "jacks" of suit J are actually jokers. count jokers into h and remove from b.
b.map!{|i|i.size*5+(i&i).size}          #collate the suit letters into a single number: total cards*5 + number of distinct suits
g[b,h]>50}                              #call g to find highest score. return truthy if over 50, else falsy.

source: Stack Exchange

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

sort: votes


text:
Let's start with a brainy quote
The challenge today is to write a program that outputs a known proverb, Where there is a will, there is a way., that means if someone is determined to do something, he will find a way to accomplish it regardless of obstacles.
Output
It has to be exactly the same, including the space bar and punctuation and excluding the newline at the end.
Where there is a will, there is a way.

You may not use Where there is a will or way anywhere in the source.
This is code-golf, shortest answer per language wins.

Looks like specific question titles can cause CAPTCHA popups.

@Deusovi Should I use the rosetta-stone tag?

Welcome to Code Golf! Let's put aside for a moment the fact that this is probably a dupe. Can you confirm that there must be no "a" at all in the source code, since this is a single-character forbidden string?

We've had a lot of challenges before about printing strings without using them or parts of them, and I think the methods for doing this have been pretty thoroughly mined out. Not something I'd expect a new poster to know, of course.

I edited the last line, so it's more in line with the usual wording. Feel free to change it back if you want.

Welcome to Code Golf! Awesome challenge nonetheless!

Several of the entries seem to be printing a newline at the end (I'm looking at the TIO output).  Is that permitted or not?  (The challenge does say: "Excluding the newline at the end.")

I've rephrased the challenge so it's simpler to understand and shows more effort put into making it.

@KrzysztofSzewczyk  I've removed the added phrase "in any case", since the rules of the challenge should not change after answers have been posted.

Possibly I may have overlooked that, good catch.

05AB1E, 23 bytes
-2 thanks to @Kevin Cruijssen
…€Ç€ˆ€…“‚Ã ÿ€§, ÿƒƒ.“.ª

Try it online!
Older version, 24 bytes
“‚Ã€Ç€ˆ€…€§,€Ç€ˆ€…ƒƒ.“.ª

-1 thanks to @petStorm
Try it online!

You posted exactly when I finished my own 05AB1E solution... it's shorter anyway.

Sentence capitalization is a built-in.

I tried it, I wonder why it didn't work...

Here's mine.

Do you have any idea why this doesn't capitalize correctly?

@CommandMaster Yes, you're using the 05AB1E (legacy) version instead of new 05AB1E version. In the legacy version, that builtin didn't exist yet. Your program works just fine in the Elixir rewrite version.

23 bytes

JavaScript (ES6), 50 bytes
_=>`W\here${s=' t\here i\s \x61 w'}ill,${s}\x61y.`

Try it online!

Retina 0.8.2, 38 bytes

Wht8ll,t0y.
t
 th 8s 0 w
h
here
T`d`l

Try it online! Explanation:

Wht8ll,t0y.

Insert Wht1ll,t0y..
t
 th 8s 0 w

Expand to Wh th 8s 0 w8ll, th 8s 0 w0y..
h
here

Expand to Where there 8s 0 w8ll, there 8s 0 w0y..
T`d`l

Transliterate the digits to letters, so as to avoid having the words is or a in the code.

@Leo's Retina Kolmogorov golfer came up with a similar solution that is also 38 bytes.

C (gcc), 87 78 75 ... 59 bytes
-9 bytes thanks to @my pronoun is monicareinstate!
-3 bytes thanks to @Arnauld!
+1 byte for forgetting the period
-3 bytes thanks to @petStorm!
-3 bytes thanks to @ceilingcat!
f(){printf("W\here%sill,%1$s\x61y."," t\here i\s \x61 w");}

Try it online!

77 and valid: Try it online!

74 bytes

You can abuse some undefined escape codes (stolen from Arnauld's answer). 64 bytes

APL (Dyalog Unicode), 102 bytes
x←⎕UCS 97
⎕←('⎕'⎕R'')'Wher⎕e ther⎕e i⎕s ',x,' w⎕ill, t⎕here i⎕s ',x,' w⎕ay.'

Try it online!
Explanation:
x←⎕UCS 97

Define x and store ASCII (⎕UCS) 97
⎕←

Print (not be confused with define ⎕)
('⎕'⎕R'')

⎕Replace '⎕' to empty string
'Wher⎕e ther⎕e i⎕s ',x,' w⎕ill, t⎕here i⎕s ',x,' w⎕ay.'

will be
'Where there is ',x,' will, there is ',x,' way.'

And
...',x,'...

Means Followed by "a" followed by other string
Or if you want everything in one code then
x←⎕UCS 97     x = "a"
⎕←('⎕'⎕R'')'Wher⎕e ther⎕e i⎕s ',x,' w⎕ill, t⎕here i⎕s ',x,' w⎕ay.'
⎕←                                                                        Print
                                                                 ' w⎕ay.' The string 'w⎕ay.'
                                                                ,          Join
                                                               x           "a"
                                                              ,            Join
                                      ' w⎕ill, t⎕here i⎕s '              The string ' w⎕ill, t⎕here i⎕s '
                                   ,x,                                     Join, "a", Join
            'Wher⎕e ther⎕e i⎕s '                                         The string 'Wher⎕e ther⎕e i⎕s '
  ('⎕'⎕R'')                                                               Replace '⎕' to Empty String

44 bytes: ⍞←'W',⎕C'_'⎕R' THERE IS A W'⊢'HERE_ILL,_AY.'

Bash + Core utilities, 54 52 51 50 bytes
echo WHERE "THERE IS A w"{ILL\,,Ay}|tr ?-V\\n _-v.

Try it online!

If we're allowed to print a newline at the end, as several other entries appear to be doing, then:
Bash + Core utilities, 47 bytes
echo WHERE "THERE IS A w"{ILL\,,Ay.}|tr ?-V _-v

Try it online!

Brain-Flak, 1170 bytes (by hand)
I wrote this one by averaging the ascii value of every character in the saying. I then pushed the value (87) to the stack. Then on stack 2 I pushed the ascii value of the next character - 87 then added 87. The numbers were all coded by this program
((((((()()()){}()){}){}())){}{})<>([(((()()()()()){}){}){}()])((((()()()()){}){}()){}<>({})<>)((()()()()()){}<>({})<>)((((()()()()){}){}){}<>({})<>)([((()()()()()){}){({}[()])}{}]<>({})<>)((()()()()()){}<>({})<>)([((()()()()()){}){({}[()])}{}]<>({})<>)((((()()()){}()){}){}<>({})<>)((((()()()){})){}{}<>({})<>)([((()()()()()){}){({}[()])}{}]<>({})<>)(((()()()){}()){}<>({})<>)(((((()()())){}{})){}{}<>({})<>)(((()()()){}()){}<>({})<>)(((()()()()){}){}()<>({})<>)((((()()()){}()){}){}()<>({})<>)([((()()()()()){}){({}[()])}{}]<>({})<>)([((((()()()){}()){})){}{}()]<>({})<>)((((()()()){}())){}{}<>({})<>)((((()()()){}())){}{}<>({})<>)((((()()()){})){}{}<>({})<>)((((()()()()){}){}){}<>({})<>)([((()()()()()){}){({}[()])}{}]<>({})<>)((()()()()()){}<>({})<>)([((()()()()()){}){({}[()])}{}]<>({})<>)((((()()()){}()){}){}<>({})<>)((((()()()){})){}{}<>({})<>)([((()()()()()){}){({}[()])}{}]<>({})<>)(((()()()){}()){}<>({})<>)(((((()()())){}{})){}{}<>({})<>)(((()()()){}()){}<>({})<>)(((()()()()){}){}()<>({})<>)((((()()()){}()){}){}()<>({})<>)([((()()()()()){}){({}[()])}{}]<>({})<>)((((()()()){}())()){}{}<>({})<>)(((()()()){}()){}<>({})<>)(((()()()()){}){}()<>({})<>)(<>{}<>)

Try it online!
Brain-Flak, 640 bytes (using text generator found here)
This was produced using an answer to a challenge I maded a while back.
(((((<(((<(<((<<((((<(<((((((((<(<(((((()(()(()()()()()){}){}){})(()(((()()[]){}){}){})({}){})[(((()[]){}){}){}])(()(()()[]){}){})>(((([]){}){}){})()((()([])({}){}){}){})>(((()()[]){}){})()(()((()()()[]){}){}){})[()()[]])[()((([]){}){}){}])(()(()[]){})({}){})()()[])[()[]])()()())((()()()){}){})>((()[]){})((()()()){}){})>(((()[])({}){}){}))[()()()])(()(()()()){}){})[()(()([]){}){}])>(()((()()[]){}){})>(()()()()()()()()()[])()()(()()()[])({}){})[(()()()()()){}])>(()()()()()()[])()(()()()()()()()[]){})>((()([]){}){})[()((()()()){}){}])()()())((()()()){}){})>([])()(()[]){})()((()()()){}){})[()((()()()){}){}])()()())[()((()()()()){}){}])

Try it online!

Python 3, 95 60 59 bytes
exit("W""here%sill,%s\x61y."%((" t""here i""s \x61 w",)*2))

Try it online!
-35 bytes thanks to newbie and petStorm. -1 byte thanks to newbie and petStorm.
I completely forgot that % did string formatting.

porting my C answer, 60 bytes

Python has string formatting as well. Same length, 60 bytes

On Python 3.8 you can save a single byte using the walrus operator. 59 bytes

Aww, I completely forgot % did formatting

No need for walrus operator tho. 59 bytes, python 2

Works in Python 3 as well.

57 bytes using f-strings Try it online!

brainfuck, 241 bytes
++++++++++[>+++++++++>++++++++++>++++++++++>+++++++++++>++++>+++<<<<<<-]>---.>++++.>+.>++++.<.>>>++.<<++.<<.>.>--.<.>>>.<<<<+.>>+.>>.<<<----.>>>.<<++++.<<.+++..>>>++++.>.<<---.<<----.>++++.>--.<.>>>.<<<<+.>>+.>>.<<<----.>>>.<<++++.<.>++.>++.

Try it online!
Could use some golfing but it's getting late.

Erlang (escript), 65 bytes
z()->"W\here"++[" t\here i\x73 \x61 w"++X||X<-["ill,","\x61y."]].

Try it online!
Erlang (escript), 65 bytes
This simply employs the almighty hard-coding.
z()->"W\here t\here i\x73 \x61 w\ill, t\here i\x73 \x61 w\x61y.".

Try it online!

V (vim), 44 bytes
iWh t wi²l, t w97y.Ót/&h i115 97
Óh/here

Try it online!
Hexdump:
00000000: 6957 6820 7420 7769 b26c 2c20 7420 7716  iWh t wi.l, t w.
00000010: 3937 792e 1bd3 742f 2668 2069 1631 3135  97y...t/&h i.115
00000020: 2016 3937 0dd3 682f 6865 7265             .97..h/here

I suspect this can be shorter, but I'm a bit rusty with V.

Yes it can be shorter!
V (vim), 42 bytes
i.yaw 97 si ereht ,lliw 97 si e erehWæ

Try it online!
Hexdump:
00000000: 692e 7961 7720 1639 3720 7369 2065 7265  i.yaw .97 si ere
00000010: 6874 202c 6c6c 6977 2016 3937 2073 6920  ht ,lliw .97 si
00000020: 650e 2065 7265 6857 1be6                 e. erehW..

V or vim, either one, 38 bytes
iwHERE THERES A WILL, THERES A WAY.V~

Try it online!

Deadfish~, 341 bytes
{{i}d}dddc{i}{i}dddcdddc{i}iiic{d}dddc{{d}iii}ic{{i}dd}iiiic{d}ddcdddc{i}iiic{d}dddc{{d}iii}ic{{i}ddd}iiic{i}c{{d}ii}dddc{{i}dddd}iiiiic{{d}iiii}dddddc{{i}d}dddc{d}ddddciiicc{{d}iiii}ddddc{d}ddc{{i}dd}iiiic{d}ddcdddc{i}iiic{d}dddc{{d}iii}ic{{i}ddd}iiic{i}c{{d}ii}dddc{{i}dddd}iiiiic{{d}iiii}dddddc{{i}d}dddc{d}{d}ddc{i}{i}iiiic{{d}iii}dddddc

Try it online!
Not as bad as usual!

Japt -S, 26 bytes
`ï,ÀnØi,ÌÀÎsn°y.`qn

Test it

Jelly, 25 bytes
“ḅṫ!Ḃḃ0ʋŀɼYẆḊỵ2Ƭqɦ⁷-&Y£z»

Try it online!

Stax, 13 bytes
üx♦r i0c@9lc¡

Run and debug it

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


text:
Chase the Easter Bunny™, be the Easter Bunny™

Chat room: https://chat.stackexchange.com/rooms/106513/easter-bunny-challenge
Git repo: https://github.com/ajfaraday/easter_bunny_hunt

The garden is a 2-dimensional grid with 49 rows and 49 columns.
The Easter Bunny™ is in the center of the garden, minding his own business, holding on to 100 Easter eggs.
Unfortunately, there's a team of 4 children who aren't content to collect chocolate eggs, they want to capture the Easter Bunny™.
The game starts with 4 kids, one in each corner of the garden.
The kids can take 1 step each turn, in one of the 4 cardinal directions (North, South, East or West). When they've each taken a step (or decided not to), the bunny will take a move.
The kids can only see the Easter Bunny or its eggs when they are 5 steps away or nearer.
Kids visibility (yellow) and movement options (green):

The bunny can hop up to 2 spaces away on both axes (describing a 5 x 5 square he can hop to).
The Easter Bunny™ can only see the kids when they are 5 steps away or nearer.
Bunny's visibility (yellow) and movement options (green)

Neither kids nor the Easter Bunny™ can leave the garden.
The game ends when:

The Easter Bunny™ drops his last egg, or
The kids catch the bunny, or
The game reaches turn 1000.

The Goals:

The Easter Bunny™ wants to give the children as many Easter Eggs as possible while evading capture.
The kids want to collect as many eggs as possible, AND catch the Easter Bunny™.

This means that:

The Easter Bunny™ will ONLY score points if it evades capture by dropping it's last egg, or by finishing the time limit.
The team of kids will ONLY score points if they capture the Easter Bunny™.
In either case the points scored is the number of eggs the kids have picked up.

The challenge is to write behaviour for the Easter Bunny™ or for the team of kids. Your code will be run against all of the
other kind of entry.
Config
You can edit conig.js to change two things about the run:

match_limit will allow you to end the game when you decide (competition will use 1,000 turns)
turn_time (ms) will set the interval when the game is rendering.

As the kids:
(See instructions for the bunny below)
Your goal is to collect as many eggs as you can, and then catch the Easter Bunny™.
Your code will take the form of an array of 4 JS functions, which will each control a kid starting in these positions (in this order):

North West (0, 0)
North East (0, 48)
South East (48, 48)
South West (48, 0)

If you're watching a match, these are represented by the numbers 1 to 4.
The functions should each have this fingerprint:
function(api) {
}

api is your function's interface to the game (see below).
The Kid API
The api object presents these four movement functions:

api.north()
api.east()
api.south()
api.west()

If any of these are called during your function, the kid will take one step in that direction (or the last called of these four directions).
If none of these are called during your function, the kid will stand still.
It also provides information about the state of the game with these methods:

api.my_storage() - an object you can use to store data and functions for just this kid.

api.shared_storage() - an object you can use to store data and functions for the whole team.

api.turn() - Returns a number of turns taken in this game so far.

api.bunny() - Returns an object of bunny-related info if the bunny can be seen
{
x: 24,
y: 24,
eggs_left: 100
}

api.kids() tells you where all the kids are
[
{x: 0, y: 0, me: true}.
...
]

api.eggs() tells you where the eggs are that your child can currently see:
{
x: 25,
y: 25,
age: 10
}

Age is the number of turns since the bunny dropped the egg.
Kid Template
Teams.push(
  {
    name: 'template',
    shared_storage: {},
    functions: [
      function(api) {
        // NW kid
      },
      function(api) {
        // NE kid
      },
      function(api) {
        // SE kid
      },
      function(api) {
        // SW kid
      }
    ]
  }
);

name must be a single-word identifier, if you want to run just a single entry.
shared_storage sets the initial state of api.shared_storage, it can be used to set data and functions for your team.
The array functions is the behaviour of the 4 kids chasing the bunny.

How to participate
You will need nodejs installed.
Change my_entry to your own team name.

git clone https://github.com/AJFaraday/easter_bunny_hunt.git
npm install terser -g
cd easter_bunny_hunt
cp team_template.js teams/my_entry.js
(Write your team code)
script/run.sh my_entry basic to watch a game. The first entry is the name of your team, the second is the name of an entry in bunnies/.
script/run.sh to run all matches and see all results (if you import more entries)

When you're happy with the result, copy it in to an answer like so:

    # Team: my_entry - 10 points

    Any description you want to add goes here

        Teams.push(
          {
            name: 'template',
            shared_storage: {},
            functions: [
              function(api) {
                // NW kid
              },
              function(api) {
                // NE kid
              },
              function(api) {
                // SE kid
              },
              function(api) {
                // SW kid
              }
            ]
          }
        );

Then have a try at writing an entry for the Easter Bunny™.
As the Bunny
Your goal is to give away as many Easter eggs as you can and, crucially, to evade capture.
The bunny starts at the centre of the garden, at coordinates 24, 24.
Your code takes the form of a function with this finger print which runs once a turn, after the children have moved.
function(api) {
}

The Bunny API
The api object provides this method to tell the bunny how to move:

api.hop(x, y)

The two arguments tell the bunny where to hop to relative to it's current position:

They can have values from -2 through to 2.
If x is positive, it will hop east, negative, it'll hop west.
If y is positive, it will hop south, negative, it'll hop north.
If the values provided are out of range, it will force it to 2 or -2.
Each time the bunny hops, it leaves behind an Easter egg.

It also provides this functions to give you storage between turns:

api.storage() - Returns an object you can use to store variables.

And these functions to give you information about the game:

api.turn() - Returns the turn number the game is currently at.

api.eggs() - Returns the positions of all Easter eggs in the garden.
{
x: 25,
y: 25,
age: 10
}

api.bunny() - Provides information on the current state of the bunny
{
x: 24,
y: 24,
eggs_left: 100
}

api.kids() - Provides information on all the kids the bunny can currently see.
{
x: 0,
y: 0
}

Bunny Template
Bunnies.push(
  {
    name: 'template',
    storage: {},
    function: function(api) {

    }
  }
);

name is the name of your bunny behaviour. Keep it to 1 word (underscores allowed).
storage is the current state of your storage object, available via the api.
function is the function which will be run every turn to control the bunny.

How to participate
You will need nodejs installed.
Change my_entry to your own bunny name.

git clone https://github.com/AJFaraday/easter_bunny_hunt.git
npm install terser -g
cd easter_bunny_hunt
cp bunny_template.js bunnies/my_entry.js
(Write your team code)
script/run.sh get_egg my_entry to watch a game. The first argument is the name of a team in teams/, the second is the name your bunny.
script/run.sh to run all matches and see all results (if you import more entries)

When you're happy with the result, copy it in to an answer like so:
    # Bunny: my_entry - 10 points

    Any description you want to add goes here

    Bunnies.push(
      {
        name: 'template',
        storage: {},
        function: function(api) {

        }
      }
    );

Then have a try at writing an entry for a team of kids.

Was this posted in the sandbox? (I didn't see it there, but I might have simply not looked into it for too long) Proof that 4 children can't catch a bunny: a bunny has 24 target cells, and even impossibly well-placed children only cover 20 (unless I missed a rule)

It was not, but it is an adaptation of a challenge I posted a couple of days ago

oops: I noticed that my proof is wrong because the kids might be able to force the bunny to go to a corner, where it has less than 24 target cells...

There should be separate posts for kids and bunnies.

@mypronounismonicareinstate ahh, yes. The edge of the garden is key.

Where's the all_matches.js file though?

@mypronounismonicareinstate Sorry, overconfidence on copying in instructions. it's script/run.sh, same arguments. Editted

Your current command line renderer draw eggs the last, above the bunny and the kids. That doesn't seem intentional to me.

@mypronounismonicareinstate I don’t have the time to fix it now, but I’d accept a pull request

@AJFaraday I am too bad with Git to create a pull request, but it's just rearranging several lines of code in models/renderer.js in render()

Interesting! Would participate in Pythong or C++. I'm not fluent enough in javascript to participate and would have issue installing random package on my machine, but I'll comment on answers, below, I guess.

@Jeffrey this challenge basically fell flat, anyway. It appears I stacked things too far in favour of the bunny. You could always set up a challenge in C++ or python...g?

If enough people had tried, there would still be the possibility for some kids to catch non-optimal bunnies. (just like there are rock-paper-scissor computer tournaments)

Bunny: smartish (2 points, but, of course, as of posting)
Hops to the middle when it doesn't see anybody, and tries to escape the kids (using an algorithm I probably implemented incorrectly).
Bunnies.push(
{
    name: 'smartish',
    storage: {},
    function: function(api)
    {
        let x = api.bunny().x;
        let y = api.bunny().y;
        if(api.kids().length == 0)
        {
            //hop towards middle
            let dx = 24 - x;
            let dy = 24 - y;
            api.hop(dx, dy);
            return;
        }
        //else build an array of safe cells
        safe = [[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1]];
        for(let i in api.kids())
        {
            let kid = api.kids()[i];
            let dx = x - kid.x;
            let dy = y - kid.y;
            if(dx >= -2 && dx <= 2 && dy >= -2 && dy <= 2)
                safe[dx+2][dy+2] = false;
            dx++;
            if(dx >= -2 && dx <= 2 && dy >= -2 && dy <= 2)
                safe[dx+2][dy+2] = false;
            dx -= 2;
            if(dx >= -2 && dx <= 2 && dy >= -2 && dy <= 2)
                safe[dx+2][dy+2] = false;
            dx++; dy++;
            if(dx >= -2 && dx <= 2 && dy >= -2 && dy <= 2)
                safe[dx+2][dy+2] = false;
            dy -= 2;
            if(dx >= -2 && dx <= 2 && dy >= -2 && dy <= 2)
                safe[dx+2][dy+2] = false;
            dy++;
        }
        //find the farthest safe cell and hop there
        let bestx = 0, besty = 0, bestd = 0;
        for(let dx = -2; dx <= 2; dx++)
        for(let dy = -2; dy <= 2; dy++)
        {
            if(!safe[dx+2][dy+2]) continue;
            let d = 9999;
            for(let kid of api.kids())
                d = Math.min(d, (kid.x-x)*(kid.x-x) + (kid.y-y)*(kid.y-y));
            if(d > bestd)
                bestd = d, bestx = dx, besty = dy;
        }
        api.hop(bestx, besty);
    }
}
);

I think the kids could push you in a corner, once they find you, by always staying between the center and you, forming a blockade. But if, instead, you hopped towards a random point in an area avoiding a 10-wide area around the border, you'd be uncatchable


text:
Counting Queen's paths on a rectangular chessboard
Task
Given two positive integers \$m,n\$, imagine a chessboard of size \$m \times n\$. A chess queen is on the upper-left corner. In how many ways can it reach the lower-right corner, by moving only right, down, or diagonally right-down (possibly moving many steps at once, because it's a queen)?
The resulting 2D sequence is A132439.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
m n result
1 1      1
1 2      1
1 3      2
1 4      4
1 5      8
2 2      3
2 3      7
2 4     17
2 5     40
3 3     22
3 4     60
3 5    158
4 4    188
4 5    543
5 5   1712

Haskell, 94 91 64 54 bytes
1!1=1;m!n=sum[m!(n-x)+(m-x)!n+(m-x)!(n-x)|x<-[1..m+n]]

Try it online!
Initially a boring port of the comment on OEIS
-27 from some tricks off dingledooper's answer
-10 from Christian Sievers

I think you can replace max m n with m+n

@ChristianSievers seems like it, and with that the m*n>0 check was also unnecessary, ty!

Python 2, 75 bytes
@xnor's idea which is 2 bytes smaller than the one below. Returns True for 1 1.
f=lambda m,n:sum(f(m-i,n)+f(m,n-i)+f(m-i,n-i)for i in range(1,n|m))or m>0<n

Try it online!

Python 2, 79 77 bytes
f=lambda m,n:(m==n==1)+sum(f(m-i,n)+f(m,n-i)+f(m-i,n-i)for i in range(1,n+m))

Try it online!

I think the 77-byter is surely correct. The correctness is clear and it will end in finite time because n+m is decreasing.

Yes, you're definitely right. It probably just takes longer for larger inputs.

Here's a way to shave two bytes off the base case for the first one, with True for 1: Try it online!

@xnor Clever idea; thanks for the improvement!

K (ngn/k), 36 bytes
{(x~1 1)+/o'x-/:{|/'~x,'-/'x}#1_+!x}

Try it online!
!x odometer
+ transpose
1_ drop the first
{ }# filter
|/'~x,'-/'x either element or their difference is 0
x-/: subtract each right
o' recur each
+/ sum
(x~1 1) does x match 1 1? use as initial value for the sum

Erlang (escript), 92 bytes
Boring port of the Haskell answer.
f(1,1)->1;f(M,N)->lists:sum([f(M,N-X)+f(M-X,N)+f(M-X,N-X)||X<-lists:seq(1,max(M,N)),M*N>0]).

Try it online!

Charcoal, 40 bytes
ＮθＦＮＦθ⊞υ∨¬υΣΦυ∨∨⁼ι÷μθ⁼κ﹪μθ⁼⁻ικ⁻÷μθ﹪μθＩ⊟υ

Try it online! Link is to verbose version of code. Explanation:
Ｎθ

Input the number of columns.
ＦＮ

Loop over the rows.
Ｆθ

Loop over each column.
⊞υ∨¬υ

The first result is always 1...
ΣΦυ∨∨⁼ι÷μθ⁼κ﹪μθ⁼⁻ικ⁻÷μθ﹪μθ

... otherwise find the existing results that are a Queen's move away, take the total, and push that to the list of results. The list therefore simulates a matrix, requiring its index to be divided or taken modulo the number of columns as appropriate to compare with the loop variables.
Ｉ⊟υ

Output the last result calculated.

J, 60 50 bytes
_2{(],1#.]#~(#:#)(0=*/*-/)@:-"1(#:i.@#))^:(*/@[)&1

Try it online!


text:
Program that compiles into itself
We've had lots of questions about quines, programs where the source code and output are identical. For compiled languages, there are other combinations: we've already had a question about writing a program where the executable and output are identical. But there's one combination left.
The task
Using a compiled language (i.e. a language which has a compiler that converts source code to executables, which are then executed), write a program which, when compiled, will produce an executable which is bit-for-bit identical to the source code.
Clarifications

As with all quine challenges that do not state otherwise, you must obey the site's proper quine rules. In particular, this excludes zero-byte programs, and programs where all the commands compile into themselves.
At least for this challenge, it doesn't matter what the resulting executable does when run; this is purely a compile-time challenge. (If it turns out to be easy, I'm sure that someone will end up posting a "write a program where the source code, executable and output when executed are all the same" challenge, but you don't need to go to that level of complexity for this challenge.)
Your program will, in effect, be a polyglot between the source language, and the language it compiles into. This means that you will need to pick a source language, and executable format, for which such a combination is possible.
Multistep compiling (e.g. compiling an esoteric language into C, which then compiles into an executable) is a legal way to answer the problem. However, this is limited to the use of three compilation steps at most (in order to avoid answers that encode the desired output in the sequence of compilers used rather than in the source code).
Don't use unusual compiler flags to loophole the question via abusing the -D option of a C compiler to hide code (or similar techniques that move code from the program into the compiler flags). You might well need to use unusual compiler flags to produce the executable in the right format, but these should be flags that would generally be useful for compiling programs, not flags specific to the program you've written (and that embed information about it); remember that on this site, the language you're using is defined by the interpreter and compiler flags that you're using.
Likewise, it's possible that your solution will require a specific filename for the source code; in order to prevent you using this to store code, any specific filename should consist of one character, possibly followed by a standard file extension for the language you are using.
Please state the exact compiler and version you're using to compile your program, together with the compiler flags you need to build it, because your answer may be hard to reproduce / verify for correctness otherwise; solutions to this question are likely to inherently be somewhat compiler-specific.
This problem is mostly aimed at compilation into executable formats used by operating systems, but if you have a language that compiles into something else (e.g. bytecode), feel free to submit an answer for that setup, too, even if it won't be quite as impressive. We aren't in the business of unnecessarily restricting what languages you can use here.

Victory condition
This is effectively a code-golf (minimize size of the source) and sizecoding (minimize size of the executable) challenge at the same time (because the two are the same): in this challenge, a program is considered to score better than another if it has a shorter length in bytes. So once you've figured out how to solve this problem at all, you can see if you can do better by fitting the program into fewer bytes.

@petStorm: I don't like to gain reputation permanently because I think it gives the wrong incentives. Unlike with answers, there's no way to avoid gaining rep for questions, so I'm using a temporary account for question-asking and receiving bounties. The most recent version of "ais523" is still alive, though (a few older versions were deleted and recreated to reset their reputation).

"a language that compiles into something else (e.g. bytecode)..." Does something else include higher-level languages (e.g. Javascript)?

@Bubbler: That's still a compile, and I had that sort of setup in mind when writing the list of clarifications; it wouldn't be correct to arbitrarily disallow languages which could be able to compete. I don't think it's really in the spirit of the question, but we don't normally care about the spirit of the question here at CGCC :-D

@petStorm: I linked that question while writing this one (it's already mentioned in the introduction); it is about writing a program whose executable equals its output. This is about writing a program whose source equals its executable. The two are normally different because a program's source code and output are usually not the same, and in particular a program that answers both questions at once will not be competitive on either.

I tried this compiler, but didn't find a way to copy string constants, and I'm not bothered to read the code in details for now. Someone may also try aspx.

What does "programs where all the commands compile into themselves" mean?

Are environment variables for the compiler allowed? If what I'm trying works out I'll need either that or to control the second that the code compiles.

Does Vyxal, which is transpiled into Python, count as valid? Because of the way it's transpiled, there is no trivial solution.

CoffeeScript to JavaScript, 2 bytes
a;

Try it

a is compiled into a;. You may try it here.
; is compiled into nothing. You may try it here.

Without ban "programs where all the commands compile into themselves", js2js would be a much better choice, IMO.

Thanks for the reminder that CoffeeScript exists

Is Javascript considered an executable?

@mypronounismonicareinstate It is allowed according to OP's clarification.

also works on typescript. try it here.

This is a transpilation, not a compilation ;)

@AlgoRythm Transpilation is compilation. It compiles into a higher-level language.

Is JS higher-level than Coffee? I would think they are at least on the same level or Coffee is higher. And I don't think there's an incredibly official definition for the difference between transpilation and compilation but as far as I can find, compilation goes closer to the metal whereas transpilation goes upwards or nowhere.

I mean, CoffeeScript isn't executable by Node, while JS is.

Oh, I think @Memberfor3months meant "higher than Assembly code". In that sense, it's a "higher level language".

Are you sure that a; doesn't just encode itself too? Any way we can check to make sure that the parser actually is looking at a and ; separately?

@Calculuswhiz I had included two more links under it. a becomes a;, while ; becomes ``. So I believe it fit the requirement. I think it is enough to show the behavior of separated a, and ;. As we only consider a compiler is black box without assuming the logic behind it.