text:
Bit floating sequence
A bit floats from the LSB to the MSB moving one position each time until it floats to the top of the container:
0000
0001
0010
0100
1000

Once one bit floats to the top, another bit begins its journey and it stops when it meets other bit:
1001
1010
1100

This happens until the container is filled with bits:
1101
1110
1111

Challenge
Given an integer number, output the "Bit floating sequence" for a container of that number of bits.

Each term of the sequence can be separated by any separator of your choice.
Edit: Sequence must be shown as decimal integer numbers, starting by the first therm: 0.
The container size sould be greater than zero and up to the number of bits of the bigest integer suported by the language of your choice. You can assume that the input always match this requirement.

Examples
Only the numeric sequence is required, binary representation is shown as example:

For 1: 0 1
0 -> 0
1 -> 1

For 3: 0 1 2 4 5 6 7
000 -> 0
001 -> 1
010 -> 2
100 -> 4
101 -> 5
110 -> 6
111 -> 7

For 4: 0 1 2 4 8 9 10 12 13 14 15
0000 -> 0
0001 -> 1
0010 -> 2
0100 -> 4
1000 -> 8
1001 -> 9
1010 -> 10
1100 -> 12
1101 -> 13
1110 -> 14
1111 -> 15

For 8: 0 1 2 4 8 16 32 64 128 129 130 132 136 144 160 192 193 194 196 200 208 224 225 226 228 232 240 241 242 244 248 249 250 252 253 254 255
00000000 -> 0
00000001 -> 1
00000010 -> 2
00000100 -> 4
00001000 -> 8
…
…
…
11111000 -> 248
11111001 -> 249
11111010 -> 250
11111100 -> 252
11111101 -> 253
11111110 -> 254
11111111 -> 255

May we output the sequence in any order (i.e. reversed), or do they have to be sorted from lowest to highest?

May we output as floats? E.g. [0.0, 1.0]

May we output using the binary representation?

May we output the zero-indexed sequence? i.e. 0 -> [0, 1]

05AB1E, 10 bytes
LRL˜Íoî.¥ï

Try it online!
L                 # range [1..input]
 R                # reversed
  L               # convert each to a range: [[1..input], [1..input-1], ..., [1]]
   ˜              # flatten
    Í             # subtract 2 from each
     o            # 2**each
      î           # round up (returns a float)
       ï          # convert to integer
        .¥        # undelta

I think there is a meta-post somewhere allowing floats with .0 by default for integers, but not sure. I personally usually put the ï in the footer to pretty-print and don't include it in the byte-count.

Python 2, 45 bytes
y=n=2**input()
while y:print n-y;y=y&y-1or~-y

Try it online!
It turns out shorter to generate 2**n minus each term in the sequence for input n. If we look at their binary expansion, below for n=5, we see a nice pattern of triangles of 1's in the binary expansions.
100000  32
011111  31
011110  30
011100  28
011000  24
010000  16
001111  15
001110  14
001100  12
001000  8
000111  7
000110  6
000100  4
000011  3
000010  2
000001  1

Each number is obtained from the previous one by removing the rightmost one in the binary expansion, except if that would make the number 0, we subtract 1 instead, creating a new block of 1's that starts a new smaller triangle. This is implemented as y=y&y-1or~-y, where y&y-1 is a bit trick to remove the rightmost 1, and or~-y gives y-1 instead if that value was 0.
Python 2, 49 bytes
def f(n,x=0):1%n;print x;f(n-x%2,x+(x%2**n or 1))

Try it online!
A function that prints, terminating with error. The more nice program below turned out longer.
51 bytes
n=input()
x=0
while n:n-=x%2;print x;x+=x%2**n or 1

Try it online!

Jelly, 11 10 bytes
RUḶ’F2*ĊÄŻ

Port of @Grimy's 05AB1E answer, so make sure to upvote him!
-1 byte thanks to @Grimy.
Try it online.
Explanation:
R           # Create a list in the range [1, (implicit) argument]
 U          # Reverse it to [argument, 1]
  Ḷ         # Create an inner list in the range [0, N) for each value N in this list
   ’        # Decrease each by 1
    F       # Flatten the list of lists
     2*     # Take 2 to the power each
       Ċ    # Ceil
        Ä   # Undelta (cumulative sum) the list
         Ż  # And add a leading 0
            # (after which the result is output implicitly)

R_2 -> Ḷ’ for -1. Ḷ is the only sensible range, I really wish 05AB1E had a single-byter for it.

@Grimy Ah, how did I miss that one. I searched for range and must have skipped passed it somehow.. >.> Thanks!

Perl 5 (-n), 41 40 bytes
-1 byte thanls to Xcali
map{/01.*1/||say oct}glob"0b"."{0,1}"x$_

TIO

"{0,1}"x$_ : the string "{0,1}" repeated n times
"0b". : concatenate to "0b"
glob : glob expansion (cartesian product)
map{...} : for each element
/01.*1/|| : to skip when 01 followed by something then 1
say oct : to convert to decimal and say

40

JavaScript (ES6), 43 bytes
When in doubt, use xnor's method.
n=>(g=x=>x?[n-x,...g(x&--x||x)]:[])(n=1<<n)

Try it online!

JavaScript (ES6),  59 57 55  52 bytes
f=(n,x=0)=>x>>n?[]:[x,...f(n,x+=x+(x&=-x)>>n|!x||x)]

Try it online!
How?
We define \$p(x)\$ as the highest power of \$2\$ dividing \$x\$, with \$p(0)=0\$ by convention.
This function can be implemented with a simple bitwise AND of \$x\$ and \$-x\$ to isolate the lowest bit set to \$1\$ in \$x\$. For instance:
$$p(52)=52 \operatorname{AND}-52=4$$
Using \$p\$, the sequence \$a_n\$ can be defined as \$a_n(0)=0\$ and:
$$a_n(k+1)=\cases{
a_n(k)+p(a_n(k)), & \text{if $p(a_n(k))\neq0$ and $a_n(k)+p(a_n(k))<2^n$}\\
a_n(k)+1,      & \text{otherwise}
}$$
Commented
f = (                   // f is a recursive function taking:
  n,                    //   n = input
  x = 0                 //   x = current term of the sequence
) =>                    //
  x >> n ?              // if x is greater than or equal to 2**n:
    []                  //   stop recursion
  :                     // else:
    [                   //   update the sequence:
      x,                //     append the current term to the sequence
      ...f(             //     do a recursive call:
        n,              //       pass n unchanged
        x +=            //       update x:
          x + (x &= -x) //         given x' = lowest bit of x set to 1:
          >> n          //         if x + x' is greater than or equal to 2**n
          | !x          //         or x' is equal to 0: add 1 to x
          || x          //         otherwise, add x' to x
      )                 //     end of recursive call
    ]                   //   end of sequence update

Python 2, 95 76 bytes
n=input()
a=0
print 0
while n:
 for j in range(n):print a+2**j
 n-=1;a+=2**n

Try it online!

Python 2, 67 bytes
n=0
i=2**input()-1
while n<=i:print n;d=n&(~-n^i)or 1;n+=n+d>i or d

Try it online!

Perl 6, 43 bytes
{0 x$_,{say :2($_);S/(0)1|0$/1$0/}...1 x$_}

Try it online!
Anonymous code block that takes a number and outputs the sequence separated by newlines. This works by starting with 0 repeated n times then replacing either 01 with 10 or the last 0 with a 1 until the number is just ones.
Or 40 bytes, using Nahuel Fouilleul's approach
{grep /010*1/|{say :2($_)},[X~] ^2 xx$_}

Try it online!

"then replacing either 01 with 10 or the last 0 with a 1 until the number is just ones" That's a genius move!

Python 2, 60 bytes
f=lambda i,n=0,b=1:[n][i:]or[n]+f(i-1/b,n^b+b/2,b>>i or 2*b)

Try it online!

Python 3, 76 bytes
f=lambda n:[0][n:]or[0]+[2**i for i in range(n-1)]+[x|1<<n-1for x in f(n-1)]

Try it online!

Python 3, 62 bytes
def f(n,c=0):
 while c<2**n:yield c;r=c&-c;c+=c+r>>n or r or 1

Try it online!
The idea is more or less the same as @Arnauld's solution.
Another 65-byte solution:

lambda n:g(2**n-1)
g=lambda c:[0][c:]or g(c-((c&-c)//2 or 1))+[c]

Try it online!

05AB1E, 13 12 bytes
Tsãʒ1ÛSO2‹}C{

-1 byte thanks to @Grimy (also take a look at his shorter approach here).
Try it online or verify all test cases.
Explanation:
T             # Push 10
 sã           # Swap to get the (implicit) input, and get the cartesian product with "10"
   ʒ          # Filter it by:
    1Û        #  Remove leading 1s
      SO      #  Get the sum of the remaining digits
        !     #  Check that the sum is either 0 or 1 by taking the factorial
              #  (NOTE: Only 1 is truthy in 05AB1E)
         }C   # After the filter: convert all remaining strings from binary to integer
           {  # And sort (reverse) them
              # (after which the result is output implicitly)

Alternate 13: oL<ʒbIj1Û1¢2‹. Doesn't look like I can get it lower.

@Grimy I just had oL<ʒbIj1ÛSO2‹ and was trying to see where my error was. :) But I'm glad to see you aren't able to find a shorter version for one of my answers for a change. ;p (inb4 you find a shorter one after all xD)

@Grimy I have the feeling SO2‹ can be 3 bytes somehow perhaps, but I'm not seeing it and also not entirely sure.. There are some alternatives, like SO1~ or SÆ>d, but I'm unable to find a 3-byter.

10 with a completely different approach

@Grimy Why am I not surprised, haha XD Nice approach btw!

Your feeling was right, I just found a 3-byter: SO!. Pretty sure I have some old answers using 2‹ that could benefit from this as well.

@Grimy Oh, nice! I certainly have some 2‹ in previous answers as well. I will also add it to the small tip answer as reminder. Thanks!

Jelly, 12 bytes
⁼þ‘ṚÄUo€ƊẎQḄ

Try it online!

Retina, 26 bytes
.+
*0
L$w`.(.*)
$.`*1$'1$1

Try it online! Outputs in binary. If that's not acceptable, then for 39 bytes:
.+
*0
L$w`.(.*)
$.`*1$'1$1
+`10
011
%`1

Try it online! Explanation:
.+
*0

Convert the input into a string of n zeros.
L$w`.(.*)

Match all possible non-empty substrings.
$.`*1$'1$1

For each substring, output: the prefix with 0s changed to 1s; the suffix; the match with the initial 0 changed to 1.
+`10
011
%`1

Convert from binary to decimal.

Brachylog, 27 bytes
1;0|⟦₅;2z^₍ᵐLtT&-₁↰+ᵐ↙T,L,0

Try it online!
Outputs out of order and with duplicates. If that's not okay, tack do onto the end.

Charcoal, 19 bytes
Ｉ⮌Ｅ⊕θＥι⁺⁻Ｘ²ＩθＸ²ιＸ²λ

Try it online! Link is to verbose version of code. Explanation:
    θ               Input
   ⊕                Incremented
  Ｅ                 Map over implicit range
      ι             Outer index
     Ｅ              Map over implicit range
           Ｉθ       Input cast to integer
               ι    Outer index
                  λ Inner index
         Ｘ²  Ｘ² Ｘ²  Power of 2
       ⁺⁻           Subtract and add
 ⮌                  Reverse outer list
Ｉ                   Cast to string
                    Implicitly print

Perl 5, 40 bytes
map{say$-;$-+=2**$_}0,0..$_-2;$_--&&redo

Try it online!

Retina, 24 bytes
.+
*0
/0/+<0`(0)1|0$
1$1

Outputs in binary. Input should have a trailing newline.
Attempt at explanation:
.+              #match the entire input
*0              #replace it with that many zeroes
/0/+<0`(0)1|0$  #while the string has a 0, substitute the first match and output
1$1             #if 01 is present in the string, replace it with 10, else replace the last character with $

I tried to avoid the 3 bytes long /0/ regex option by rearranging the options, but couldn't.
Try it online!

I don't think outputting in binary is allowed. There's a comment asking if it is allowed, but it's better to assume that you can't until the asker replies

C (clang), 73 bytes
o,j,y;f(x){for(o=j=0;printf("%d ",o),x;o+=y+!y,y+=y+!y)j=!j?y=0,--x:--j;}

Try it online!
for(o=j=0;printf("%d ",o),x;  o+=y+!y, y+=y+!y)
// adds 1, 1+1=>2 , 2+2=> 4 .... sequence

 j=!j?y=0,--x:--j;
// uses ternary instead of nested loop to decrement 'x' when 'j' go to 0

k4,  28 24 bytes
0,+\"j"$2 xexp,/-1+|,\!:

@Grimy's approach ported to k4
edit: -4 thanks to ngn!

!:'1+|!: -> |,\!:

you can remove the space after xexp

@ngn, agh |,\!: seems so obvious now that i see it!


text:
I multiply the source, you (probably) multiply the output!
Task
The task is to write a program that outputs a consistent but otherwise arbitrary positive integer \$x\$ (so strictly greater than 0). Here's the catch: when the source is repeated \$N\$ times (the code is appended/concatenated \$N-1\$ to itself), the program should have a \$\dfrac{1}{N}\$ probability of outputting \$N\cdot x\$ and the remaining probability of \$\dfrac{N-1}{N}\$ of outputting \$x\$ unchanged.
Example
Let's assume that your initial source is XYZ and produces the integer 3. Then:

For \$N=2\$: XYZXYZ should output \$3\$ with a probability of \$\frac{1}{2}\$ (50% of the time) and \$2\cdot 3=6\$ with a probability of \$\frac{1}{2}\$ as well (50% of the time).
For \$N=3\$: XYZXYZXYZ should output \$3\$ with a probability of \$\frac{2}{3}\$ (66.666% of the time) and \$3\cdot 3=9\$ with a probability of \$\frac{1}{3}\$ (33.333%  of the time)
For \$N=4\$: XYZXYZXYZXYZ should output \$3\$ with a probability of \$\frac{3}{4}\$ (75% of the time) and \$4\cdot 3=12\$  with a probability of \$\frac{1}{4}\$ (25% of the time)

and so on....
Rules

You must build a full program. The output has to be printed to STDOUT.
Your program, should, in theory, output each possible value with the probabilities stated above, but a slight deviation from this due to the implementation of random is fine (provided that the implementation is not of a different distribution - you can't use a normal distribution to save bytes).
The program should (again, in theory) work for an arbitrarily big value of \$N\$, but technical limitations due to precision are fine for large \$N\$.
The output must be in base 10 (outputting in any other base or with scientific notation is forbidden). Trailing / leading spaces and leading zeroes are allowed.
The initial source must (of course) be at least 1 byte long. You may not assume a newline between copies of your source. The program should not take input (or have an unused, empty input).
This is code-golf, so an answer's score is the length of the (original) source in bytes, with a lower score being better.

Note: This challenge is a (much) harder version of this one.

Can the program read its source code?

@someone Yes, it is allowed.

R, 66 35 bytes
-29 bytes thanks to digEmAll.
-2 bytes thanks to Giuseppe.
+0->A
x=!0:F
F=F+1
sample(F*x+!x,1)

Try it online!
Check the distribution for N=4.
The key is the rightwards assignment ->. When the code is multiplied \$N\$ times, the first \$N-1\$ calls to sample will be assigned to A, and only the last call will be printed.
Original, more convoluted solution:
R, 66 bytes
T->TT
F=F+1
TT=0
`?`=function(x)if(x)sample(c(1,F),1,,c(1,F-1))
?T

Try it online!
Try it online (repeated 3 times)!
Uses two tricks: 1) call the main function of interest ?, so that we can call it without ending the program with a bracket, and 2) use variables T and TT, with code which starts with T and ends with ?T.
F is the iteration counter. ? is redefined as a function which takes a boolean argument: if the input of ? is TRUE (or T), it does the required random sampling; if the input is FALSE (or 0), it does nothing. The value of TT is defined as 0, so that ?T does the sampling but ?TT does nothing.
When the source is repeated, it looks like this:
T->TT
F=F+1
TT=0
`?`=function(x)if(x)sample(c(1,F),1,,c(1,F-1))
?TT->TT
F=F+1
TT=0
`?`=function(x)if(x)sample(c(1,F),1,,c(1,F-1))
?T

so the middle call ?TT outputs nothing but the final call ?T outputs the random result.

I don't think I've ever seen -> used in code golf in a situation where <- couldn't be; this is so cool!!

PS I'm gonna give this a bounty at some point.

Absolutely awesome!

This should work as well I think (borrowing +0 idea from python)

@digEmAll Much neater, thanks!

35 bytes originally inspired by these 36 bytes.

and verification that it works for N = 4

@Giuseppe Good find, thanks!

Bash, 31 bytes
trap echo\ $[RANDOM%++n?1:n] 0;

Try it online!
trap ... 0 will run the code contained on exit. Repeated traps will overwrite old ones. The unquoted $[arithmetic expansion] gets run every time a new trap is set.

Zsh can save one byte with <<<:
trap "<<<$[RANDOM%++n?1:n]" 0;

Python 3, 81 79 bytes
+0if[]else 1
from random import*
try:n+=1
except:n=1
print([1,n][random()*n<1])

Try it online!
-1 byte thanks to @Nishioka
This is one Python 3 solution that does not access the program source directly. Doing this in Python 3 is more challenging than Python 2 because normal printing statements end with a closing parenthesis so there aren't many choices to change its behavior in the next block of initial source. It would be interesting to see more creative solutions in Python 3.

-1 byte: +0 if[]else 1

@Nishioka Thanks. Updated.

Jelly, 7 bytes
‘ɼḷXỊ®*

Try it online!

05AB1E, 7 bytes
¾Å1¼¾ªΩ

Try it online!

Python 3, 78 76 75 bytes
Using the same trick as in the link that was posted, here is a Python one (with x=1).
from random import*;n=len(*open(__file__))//75;print(1+~-n*(random()<1/n))#

Try it online!
-2 bytes thanks to Mr. Xcoder for his (n-1) formula with ~-n which has higher precedence than *
 -1 byte thanks to Nishioka

Looks good to me! import random;n=len(*open(__file__))//76;print(1+~-n*(random.random()<1/n))# should work for -2 bytes

I'd never seen this way of doing n-1 ! I like it, thanks :)

-1 byte: https://tio.run/##K6gsycjPM/7/P60oP1ehKDEvBUhl5hbkF5VoWefZ5qTmaWjlFwDJ@Pi0zJzU@HhNTX19c1PrgqLMvBINQ@063TwtDYg2DU0bQ/08TU3l//8B

Another -1 byte but with a bit different approach: https://tio.run/##K6gsycjPM/7/P60oP1ehKDEvBUhl5hbkF5VoWefZ5qTmaWjlFwDJ@Pi0zJzU@HhNTX19cxPrgqLMvBKN5Iz8zORUjWjDWK063Tzt6LxYTU3l//8B

yes I do because of the random()<1/n ;-)

Dyalog APL, 25 24 23 22 21 bytes
0{×⍺:1+⍵⋄⎕←1⌈⍵×1=?⍵}1

Try it online!

Perl 5, 28 26 bytes
-2 bytes thanks to @Grimy
1 if!++$x;say 1<rand$x||$x

TIO

26: 1 if!++$x;say 1<rand$x||$x

thanks, nice variation

Gaia, 17 15 14 13 bytes
Øgl13÷:(1w&+ṛ

Try it online!
I randomly noticed the behavior of Øg yesterday when looking through the docs, which helped immensely.

Ruby, 40 bytes
1
n||=@x=0
n+=1
puts 1>rand(n)?n:1 if @x

Try it online!
Try it online (copied 3 times)!
A ruby port of this Python answer.
Ruby, 38 bytes
2 bytes saved by reading the file:
n=File.size($0)/38;puts 1>rand(n)?n:1#

Try it online!

Runic Enchantments, 31 bytes
UwR'10<;$\
I+:'RA0)?/1$;
1
l;
y

Try it online!
Uses the same structure as this answer to count how many times the source has been duplicated:

Just instead of outputting the nth number in a list, we use that value to randomly generate a number, if the result is not 0, print 1, else print that number.

Japt, 9 8 bytes
(°Tö)ÎªT

Test it | Doubled | TripledVerify distribution of 10000 runs after 10 repetitions
(°Tö)ÎªT
(            :Prevent the operator that follows from being implicitly applied to the first input variable, U
 °T          :Increment T (initially 0) by 1
   ö         :Random element in the range [0,T)
    )        :Closing the parentheses here instead of after the T saves a byte as there would need to be a space here to close the random method
     Î       :Sign - 0 (falsey) or 1 (truthy)
      ªT     :Logical OR with current value of T

Original, 13 11 10 9 bytes
Note the trailing space.
NoÎp°T ö

Test it | Doubled | TripledVerify distribution of 10000 runs after 10 repetitions
NoÎp°T ö
N             :Initially, the (empty) array of inputs
 o            :Replace the last element with
  Î           :  Its sign (always 1)
   p          :Push
    °T        :  T (initially 0) incremented
       ö      :Random element of N

JavaScript (JavaScript shell 71), 78 bytes
(async x=>x)().then(x=>f((''+f).length/78));f=x=>print(1-~x*Math.random()|0)//

No tio link, spidermonkey on tio is too old...
Firefox (Spidermonkey) consider the comment as a part of function f. As the result, (''+f).length will be b+79n where b < 78, and (n + 1) is the times of source code repeated.
This buggy (? I'm not sure. I would prefer it is a bug of JavaScript specification rather than any interpreter) behavior had been submit to BMO by someone else just after this answer posted: https://bugzilla.mozilla.org/show_bug.cgi?id=1579792 . (Neither of the bmo thread nor the tweet is posted by me.)

What's with the (async x=>x)()? Why is it async?

@TomášZato It is literally asynchronous. So the callback x=>f(...) will be invoked after function f been defined.

C# (Visual C# Interactive Compiler), 133 114 112 bytes
This is the first (and hopefully last) time I have ever used C# preprocessor directives.
#if!I
#define I
static int i;
class p{~p()=>Console.Write(new Random().Next(i)<1?i:1);}p s=new p();
#endif
i++;

Try it online!

Charcoal, 12 bytes
⎚Ｉ⎇‽Ｌ⊞Ｏυω¹Ｌυ

Try it online! Based on my answer to the linked question. Outputs n with probability ¹/ₙ, otherwise 1. Explanation:
⎚               Remove output from previous iterations
       υ        Initially empty list
        ω       Empty string
     ⊞Ｏ         Push
    Ｌ           Length
   ‽            Random integer [0..length)
  ⎇             Ternary
         ¹      If nonzero then literal 1
          Ｌυ    If zero then the new length
 Ｉ              Cast to string for implicit print

source: Stack Exchange

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

sort: votes


text:
43 quintillion permutations
We can represent a Rubik's Cube as a net as follows (when solved):
   WWW
   WWW
   WWW
GGGRRRBBBOOO
GGGRRRBBBOOO
GGGRRRBBBOOO
   YYY
   YYY
   YYY

Each letter represents the corresponding colour (W is white, G green etc.)
It has been shown that there are exactly \$43,252,003,274,489,856,000\$ (~\$43\$ quintillion) different permutations that a Rubik's Cube can be in.
Your task is to take an integer between \$1\$ and \$43,252,003,274,489,856,000\$ and output the corresponding permutation, in the manner shown above. You may choose how the permutations are ordered, but the algorithm you use must be shown to generate a unique, and correct, permutation for each possible input.
Invalid permutation rules
Taken from this page
To start with, the centre of each 3x3 face must stay the same, as the centre square on a Rubik's Cube cannot be rotated. The entire cube can be rotated, changing where a face appears to be, but this doesn't affect the net of the cube.
If we say each permutation has a parity, based on the parity of the number of swaps to reach that permutation, we can say

Each corner piece has three possible orientations. It can be oriented correctly (0), clockwise (1) or counterclockwise (2). The sum of corner orientations always remain divisible by 3
Each legal rotation on the Rubik's Cube always flips an even number of edges so there can't be only one piece oriented wrong.
Considering the permutation of all the corners and edges, the overall parity must be even which means that each legal move always performs the equivalent of an even number of swaps (ignoring orientation)

For example the following three net are invalid outputs:
   WWW
   WWW
   WWW
GGGWWWBBBOOO
GGGRRRBBBOOO
GGGRRRBBBOOO
   YYY
   YYY
   YYY

(Too many whites/not enough reds)

   WRW
   WRW
   WRW
GGGRWRBBBOOO
GGGWRRBBBOOO
YYGRWROOOBBB
   YYY
   GGY
   YYY

(There are two red/green center squares and no white/yellow center squares.
 In all valid permutations, the center squares are all different colours)

   WWW
   WWW
   WWW
GGGRRRBBBOOO
GGGRRRBBBOOO
GGGRRRBBOYOO
   YYY
   YYY
   YYB

(The yellow/orange/blue corner is rotated into an impossible permutation)

Rules

You must prove, however way you wish, that the algorithm is valid. You do not have to enumerate every single permutation, as long as you prove the validity of your algorithm.
As long as your program will work theoretically for all integers between \$1\$ and \$43,252,003,274,489,856,000\$, you don't have to worry about the practicalities of actually taking in inputs greater than your language can handle

This means that, if your language/type/whatever can only handle numbers up to \$2^{53}-1\$, the program itself can fail if the input is greater than \$2^{53}-1\$, but the algorithm that you use should not.
For example, if your Javascript program fails for an input of \$27,946,105,037,114,827,095\$ purely because that number is out of bounds, that's fine. However, if your algorithm were ported to a language with arbitrary sized integers and failed for that input, your program would not be valid.

You must include some sort of proof of validity in your answer. This proof can prove the validity in any accepted proof method, except for enumerating all possibilities.
You may choose to use an alternate input method if you wish, so long as:

The input is bounded
Each input corresponds to a unique output
You clearly explain the input format and how it corresponds to each output

You may change the characters used to use 6 different ASCII characters, between 33 (!) and 126 (~), instead of WGRBOY
You may output in any manner you wish, so long as it forms a clear representation of a cube where all 6 faces are able to be shown, including any valid cube net, a single lined string or a 3D rendering. If you are unsure about a specific format, don't hesitate to ask in the comments.

This is a code-golf so the shortest code, in bytes, in each language wins.
Example valid outputs
   YYY
   YYY
   YYY
GGGRRRBBBOOO
GGGRRRBBBOOO
GGGRRRBBBOOO
   WWW
   WWW
   WWW

(The `W` and `Y` faces have been swapped)

   ZZZ
   +++
   +}}
+[[}77ZZ7bbb
bb[}[[7}}+Z7
bb[}++[}}+Z7
   7bb
   [7Z
   [7Z

(To start with, the colours have been mapped W -> +, G -> b, R -> [, B -> }, O -> Z and Y -> 7.
 Then, the moves L, R, U and F' have been applied, in that order.
 Notice that each centre square is different, and corresponds to the same colour as in the mapping)

In the third invalid example it isn't just that the corner is in an invalid configuration, the r/y/o corner is an impossible corner due to r and o being opposite one another

Fixed the third invalid example (CC @fəˈnɛtɪk)

The same problem was also in the second invalid example but i hadn't noticed it. It matters less there because the colours are messed up anyway

When you write that alternate input methods are allowed, does that mean that we can take input as a vector of positive integers $(a_1,a_2,a_3,a_4)$ with the constraint $a_1\leq 8!$, $a_2\leq3^7$, $a_3\leq 12!/2$, $a_4\leq 2^{11}$? (the product of those numbers is 43 quintillion)

Does outputting in any manner we wish include, for (e.g.) the solved cube, outputting the single line string WWWWWWWWWGGGRRRBBBOOOGGGRRRBBBOOOGGGRRRBBBOOOYYYYYYYYY?

@Shaggy Yes, a single line string is fine

It is a theorem that there is an bijection between the group of transformations and the legal states of the cubes. Therefore it would be sufficient to create a function which can decode a given string of transformations from a solved cube into a state, or even more easily, a string of faces since each transformation is a quarter clockwise turn on a given face, and so is distinguished by each face. Moreover, it is known that every state can be represented by a string of less than 27 transformations. So it is possible to generate all $6^{26}$ combinations, decode them, and then output them.

I tried writing it, but I immediately ran into a wall with how to represent the cube. The best I could come up with is a graph with 8 points for each face (since the center stays put) where points which move together are connected.

@cairdcoinheringaahing, edit that into the spec and you've got my +1. Currently it reads as though we're tied to the output format you've used, which, in my opinion, adds an unnecessary complication to an already challenging challenge.

@Shaggy Edited in. I'd hoped that the final bullet point in the rules would have addressed the output format, but I've changed it to be (hopefully) less restrictive

@RobinRyder Yes, that's an acceptable input (It meets the requirements laid out in the post)

Charcoal, 334 297 bytes
Ｎθ≔×³﹪θ²¹⁸⁷ε≧⁺﹪±Σ⍘ε³¦³ε≧÷²¹⁸⁷θ≔⁴⁰³²⁰δ≔﹪θδζ≧÷δθ≔⊗﹪θ²⁰⁴⁸η≧⁺﹪Σ⍘η²¦²η≧÷²⁰⁴⁸θＦ⪪”B"↷:μêKＯ″ＫW#})”³«Ｊ⌕α§ι⁰Ｉ§ι¹§ι²»≔⁰ω≔⪪”A‽}y≔Ｗ⊞≦≦⧴!O×➙⟧ï!Ｙ9⁺`↙1δQ1ξzＴ”⁶υ≔⪪”{➙∧⊙ηr⸿ξd⊕÷M→¡$≧”³δＦ²«Ｆδ«≔§υ⎇⁼Ｌυ⊗ιωζδ≧÷Ｌυζ≧⁺⌕υδω≔Φυ¬⁼λδυＦＬκ«Ｊ⌕α§δ⊗⁺λεＩ§δ⊕⊗⁺λε§κλ»≧÷Ｌκε»≔⪪”A‽}R›Ｋ<≡^μ≡⟦σＤ⎚+πη±t¿e∧Ｌ⸿~↑�w”⁴υ≔⪪”{➙∧⊙ηr⸿ξe'→↑Þ³№¹”²δ≔θζ≔ηε

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

Input the integer into variable q.
≔×³﹪θ²¹⁸⁷ε≧⁺﹪±Σ⍘ε³¦³ε≧÷²¹⁸⁷θ

Divide q by 3⁷, putting the remainder in e. Then, considering e as a number in base 3, suffix a digit to e so that its digits (in base 3) add up to a multiple of 3. This allows e to define the rotations of the corners.
≔⁴⁰³²⁰δ≔﹪θδζ≧÷δθ

Divide q by 8!, putting the remainder in z. (8! is temporarily stored in d to save a byte.) This allows z to define the positions of the corners.
≔⊗﹪θ²⁰⁴⁸η≧⁺﹪Σ⍘η²¦²η≧÷²⁰⁴⁸θ

Divide q by 2¹¹, putting the remainder in h. Then, considering h as a number in base 2, suffix a digit to h so that its digits (in base 2) add up to a multiple of 2. This allows h to define the flips of the edges.
Ｆ⪪”B"↷:μêKＯ″ＫW#})”³

Loop over a string representation of the centres.
«Ｊ⌕α§ι⁰Ｉ§ι¹§ι²»

Jump to the position of each centre and print it.
≔⁰ω

Keep track of the parity of the corner positions in variable w.
≔⪪”A‽}y≔Ｗ⊞≦≦⧴!O×➙⟧ï!Ｙ9⁺`↙1δQ1ξzＴ”⁶υ

Create an array of corner positions.
≔⪪”{➙∧⊙ηr⸿ξd⊕÷M→¡$≧”³δ

Create an array of corner colours.
Ｆ²«

Loop twice, once for corners, once for edges, hereinafter referred to as "cubes".
Ｆδ«

Loop over the array of cube colours.
≔§υ⎇⁼Ｌυ⊗ιωζδ≧÷Ｌυζ≧⁺⌕υδω≔Φυ¬⁼λδυ

Extract the next cube position from z, updating the parity in w. Use this parity for the last but one edge. This ensures that the sum of parity of the edges and corners is even.
ＦＬκ«Ｊ⌕α§δ⊗⁺λεＩ§δ⊕⊗⁺λε§κλ»

Print the cube at that position, adjusted for the next rotation or flip as appropriate.
≧÷Ｌκε»

Remove the rotation or flip from e.
≔⪪”A‽}R›Ｋ<≡^μ≡⟦σＤ⎚+πη±t¿e∧Ｌ⸿~↑�w”⁴υ

Create an array of edge positions. This will be used the second time through the loop.
≔⪪”{➙∧⊙ηr⸿ξe'→↑Þ³№¹”²δ

Create an array of edge colours.
≔θζ≔ηε

Overwrite the corner variables z and e with the corresponding edge variables q and h so that the edges are permuted and flipped during the second pass of the loop.

Advise to myself: If something golfed in Charcoal is 330 bytes, don't try it in PHP!

@Night2 Sadly 334 now, due to a bugfix (incorrect parity calculation).

Ruby, 570 408 bytes
->g,h{z=[]
c=a="\x19)!$'%\x177\x1F495.)@7g~yp"
20.times{|i|z<<a[k=g%r=12+i/12*8-i];a[k]="";g/=r}
19.times{|i|z[0..i].map{|j|j>z[i+1]&&c=!c}}
c||(z[19],z[18]=z[18,2])
h+=h+("%b"%(h%2048)).sum%2
j=0
b="023451"
20.times{|i|b<<("%0*o"%[r=2+i/12,z[i].ord-20]*2)[h%r+i/19*j%3,r];j-=r/3*h;h/=r}
s=(t="...
"*3)+(?.*12+$/)*3+t
54.times{|i|s["<QTWZo;MP[ngD@RS^k=GVUpaJ8XYdsAFE?CN7LK9IHl_`jh]reftbc"[i].ord-55]=b[i]}
s}

Try it online!
Original version, with arrays of magic numbers instead of magic strings
->g,h{z=[]
a=[05,025,015,020,023,021,03,043,013,040,045,041,   032,025,054,043,0123,0152,0145,0134]
#PERMUTE
20.times{|i|r=12+i/12*8-i;z<<a.delete_at(g%r);g/=r}
c=1
19.times{|i|z[0..i].map{|j|j>z[i+1]&&c=!c}}
c||(z[19],z[18]=z[18],z[19])
#ROTATE
h+=h+(h%2048).to_s(2).sum%2
j=0
b="023451"
20.times{|i|r=2+i/12;b<<("%0*o"%[r,z[i]]*2)[h%r+i/19*j%3,r];j-=r/3*h;h/=r}
#DISPLAY
s=(t="...
"*3)+(?.*12+$/)*3+t
54.times{|i|s[
[5,26,29,32,35,56,
4,22,25,36,55,48,
13,9,27,28,39,52,
6,16,31,30,57,42,
19,1,33,34,45,60,
10,15,14,8,12,23,0,21,20,2,18,17,
53,40,41,51,49,38,59,46,47,61,43,44][i]]=b[i]}
s}

Try it online!
An anonymous function which in its current form takes an input of two integers, which seems to be allowed:  "you may choose an alternate input method." The first is the permutation in the range 0 to 12!*8!/2 - 1 and the second is the orientation of the pieces in the range 0 to 2**11 * 3*7 - 1. The output in the solved state is the following string:
000
000
000
222333444555
222333444555
222333444555
111
111
111

Further golfing
There are approximately 10 more characters to be saved by adjusting the output format to the following shape. But this would reduce the readability, so I will not be doing it at present
      #########
      #########
      #########
#########
#########
#########

Explanation
Permutation
Internally, the solved state is represented by the series of octal numbers in the array a. The input g is divided by the numbers 12..1 with the modulus being used to pick and remove an edge from a and place it in z. Once this is done, only the corners remain in a, so g is divided by the numbers 8..1 with the modulus being used to remove a corner from a and place it in z.
As there is insufficient info to determine the order of the last two corners, the value of g will have been divided down to zero by the time it reaches them, so they will always be added to z in there original order. A check is then made to determine if the overall permutation is even or odd, and if necessary the last two corners are swapped to make the permutation even.
Orientation
There are various different ways of deciding if a corner or edge is in the correct orientation if it is not in its solved location. For the purpose of this answer, a corner is considered in its correct orientation if it shows 0 or 1 on the top or bottom face. Therefore rotating the top or bottom face does not change the corner orientation. Rotating the other faces does change the orientation, but in such a way that the overall parity sum remains unchanged. The edges are considered in the correct orientation if they show a 2 or 4 to the front / back or a 3 or 5 to the left / right. This means that rotation of the top or bottom by a quarter turn flips the four edges but rotation of the other faces leaves the flip status unchanged.
The input contains explicit information for all but the first edge and the last corner. The 11 least significant bits h%2048 are summed and the modulus used to determine the orientation of the first edge. h is multiplied by 2 by adding it to itself and the value for the orientation of the first edge is added as the least significant bit. The orientation of the last corner is found by progressively subtracting the orientation of the other corners from j. For the very last corner (where i/19 = 1) the value of j%3 is added to h (which will have been reduced to zero) and this determines the orientation of the last corner.
The string b comes preinitialized with the text for the centres of the faces. h is divided by 2 twelve times then by 3 eight times, with the modulos being used to determine the orientation of the pieces. In each case, the number in z is converted to a string with the appropriate number of digits (2 or 3) and the string is then duplicated. This allows the correct rotation of the digits as found by the modulo to be extracted from the string by indexing and appended to b
Display
Finally, the raw stickers are copied from b into a more human readable format in s using the magic numbers in the index table.

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


text:
Return the nth element of an array even if its out of bound
The challenge
Write a function that returns the nth element of an array even if its out of bound.
function safeGet(index, arr) {
  const safeIndex = ???
  return arr[safeIndex]
}

const arr = ["a", "b", "c"];

safeGet(0, arr) // "a"
safeGet(1, arr) // "b"
safeGet(2, arr) // "c"

safeGet(3, arr) // "a" go back to the beginning
safeGet(4, arr) // "b" all over again
safeGet(5, arr) // "c"

safeGet(30, arr) // "a"
safeGet(400, arr) // "b"
safeGet(5000, arr) // "c"

Negative indices works exactly the same way, but beginning from the end:
safeGet(-1, arr) // "c" begin from the end
safeGet(-2, arr) // "b"
safeGet(-3, arr) // "a"

safeGet(-4, arr) // "c" go back to the end again
safeGet(-20, arr) // "b"
safeGet(-300, arr) // "a"

Visually it looks like this:
// (For 1-element sized arrays, any natural number is a valid index)
//   2
//   1
//   0
// ["a"]
//  -1
//  -2
//  -3

//   6    7    8
//   3    4    5
//   0    1    2
// ["a", "b", "c"]
//  -3   -2   -1
//  -6   -5   -4
//  -9   -8   -7

//   6    7    8    9   10   11
//   0    1    2    3    4    5
// ["a", "b", "c", "d", "e", "f"]
//  -6   -5   -4   -3   -2   -1
// -12  -11  -10   -9   -8   -7

Rules

You can't mutate the array.
You can't even traverse the array.
Any programming languages will be accepted.
It's a CodeGolf, meaning the smallest answer wins.

First, this behavior is (mostly) built into some languages already (*cough* python). Second, your restrictions don't make much sense. What do you mean by transversing an array? Are languages that use linked lists as arrays excluded? For example, in Java, new LinkedList<>().get(2) transverses over the array to get the element at index 2. Coming back to python: lambda a,n:a[n%len(a)] should do the trick.

Sorry I thought it would be clear that by not allowing array traversing, I meant explicitly, and not internally by the language. Of course new LinkedList<>().get(2) traverses the array, but you, as a developer, are not iterating over the list (with a for-loop for example, that's what I meant). And yes, python does this built-in, maybe I should add that you have to implement MATHMATICALLY (using the modulo operator to get the remainder, just like you did). The python answer you made is correct, but isn't eligible as a commentary, I'm sorry. Also you must be fun at parties. @BenjaminUrquhart

What is the rationale for not allowing explicit traversal? If there's some language where that's shorter than indexing mod the length, I'd personally be quite glad to see that approach taken

How should 1-indexing work? In zsh, $a[0] is empty, while $a[-1] starts at the end of the array as desired.

Your restrictions are intending to make an easy task more difficult, but they seem to be unobservable requirements. Consider making a harder or more creative challenge.

The You can't even traverse the array. is rather unobservable in most languages. Since it doesn't really seem to add anything to the challenge and is rather confusing, I'd recommend removing it. I'd also suggest removing the You can't mutate the array., because that only really makes sense for languages with pointers, and even then, it's a weird restriction

Python, 22 21 bytes
-1 byte thanks to ovs
This does not mutate the given array. Rather, it makes a n^2 larger copy of it. There's also no explicit iteration being done here.
lambda a,n:(n*n*a)[n]

TIO (updated test array)

lambda a,n:(n*n*a)[n] (21 bytes) technically complies with all the rules in the challenge as it creates a copy of the given list.

@ovs I didn't think of that. Thanks.

Stax, 1 bytes
@

Run and debug it
@ is the array indexing instruction in stax.  It works exactly as specified.

Perl 6, 17 9 bytes
{*[$_%*]}

Explanation
{*[$_%*]}($idx)(@arr)     # curried input
*[$idx % *](@arr)         # $_ takes the $index
@arr[$idx % *]            # first * takes @array
@arr[$idx % @arr.elems]   # * in [] is number of elems

Try it online!

Perl 6, 12 bytes
*[0]o&rotate

Try it online!
Works differently from guifa's answer in that it first rotates the array by the given amount, then takes the first element.

Zsh, 27 24 bytes
<<<${@[(`<&0`%#+#)%#+1]}

Turned out a bit more interesting than I thought. Takes array as arguments, index on stdin.
Try it online!
Try it online!
Arrays in zsh are one-indexed, and $a[0] is empty. Negative indexing works as expected for -1, -2, ..., -n.
New strategy: While negative indexing seems useful, the empty zero-index makes it less so. So, we just "mod n, add n, mod n" to make everything in the range [0,n-1], then add one.

Old strategy:

take the index % length, leaving us something in the range [-n+1,n-1].
if that is non-negative, add 1.

C (gcc), 53 32 31 bytes
a(b,c,d)int*b;{b=b[(d%c+c)%c];}

Thanks to wastl for 31 bytes
Try it online!

37 bytes

Take an array of int to save a byte: https://tio.run/##jY69CsMgEMd3n0ICorYnmGomyZOEDHqhJUNDCd3EZ7dm9ZbCHRy/4/@B5oVYa1QJEDa9H99bCjnNaVGbwDtqgWsotXH@jvuhdGbXHc9zXNw6ZxklyNQWZQnsc7bnUw0C@d8zAOM8qssRuANudQfGHjx64HrgezARCYnxlqDJUmZIHUP6GFLIeKqi1q7FMR1YqT8

Charcoal, 1 byte
§

Try it online! This is Charcoal's AtIndex operator, but as a full program, it automatically accepts array and integer parameter inputs.

Japt, 2 bytes
0-indexed. Input order is irrelevant.
gV

Try it

Javascript, 28 bytes
a=>i=>a[(i<0?-i:i)%a.length]

That looks like 28 bytes to me, without counting the space

Thanks. I can't count :(

-1 is supposed to count back from the end...

C# (Visual C# Interactive Compiler), 28 bytes
a=>b=>b[(a%(a=b.Count)+a)%a]

Try it online!

This isn't working as specified. The -1 index should return the last array element (a.k.a. 1st element from the end) which is "c" in the given example, but yours is printing "b" instead. Same goes for any other negative indexes.

PHP, 53 bytes
function($i,$a){return$a[(($c=count($a))+$i%$c)%$c];}

Try it online!

$i is the requested index.
$a is the array.
$c is count of array items.

PHP doesn't support negative array indexes to get items from the end (as you can actually have negative indexes in PHP arrays like this: [-1 => 'X', -2 => 'Y']).
So I'm always returning the array item at this position: (($i % $c) + $c) % $c

The above formula for $i=0 is always 0.
For $i>0 (positive index) it is same as $i % $c, since we add the $c to the result once and then get mod of it by $c again. For example, for $c=3 and $i=5 the resulting position will be 2.
For $i<0 (negative index) it will get the reversed position as a positive number (which is like getting the position from the end of the array). For example, for $c=3 and $i=-5 it will be ((-5%3)+3)%3 = (-2+3)%3 = 1%3 = 1.
If we change $i from -5 to -6, the resulting position should be reduced by 1, it will be ((-6%3)+3)%3 = (0+3)%3 = 3%3 = 0
If we change $i from -5 to -4, the resulting position should be added by 1, it will be ((-4%3)+3)%3 = (-1+3)%3 = 2%3 = 2


text:
Find minimal set of rows to retain all unique values in each column
Given a matrix, the goal is to ensure all the values in each column occur at least once, while at the same time doing so requiring the least possible amount of rows. Fastest solution wins.
Note: a value in one column (e.g. 1) is considered different from the same value in another column.
Expected output: an array/list/series of row indices that retain all unique values across all columns.
Example data:
import numpy as np
import pandas as pd

np.random.seed(42)

num_rows = 10000
num_cols = 200
max_uniq_values = 10

data = pd.DataFrame({i: np.random.randint(0, max_uniq_values, num_rows)
                     for i in range(num_cols)})
# or python
# data = [np.random.randint(0, max_uniq_values, num_rows).tolist()
#         for i in range(num_cols)]

Minimal example (num_rows=5, num_cols=2, max_uniq_values=4)
Input:
    | 0  1
  --------
  0 | 1  1
  1 | 2  2
  2 | 3  4
  3 | 3  3
  4 | 4  4

Expected output:
[0, 1, 3, 4]

Additionally:

Benchmark will happen on a 2015 Macbook Pro with CPU Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz.
Restricted to use 1 core.
External libraries allowed
Blind test will be done on 10 random seeds (the same ones for each solution)

Wow, ok, your question is poorly worded. You want to SELECT the least number of rows to have unique values in each row for all columns. I definitely did not get that from your Question.

Your example is really confusing because you're saying 2 columns, but the example contains 3 columns. Please don't copy/paste from Pandas and consider re-writing the question using pure Python.

Your own question states "all the values in each column occur..." If all columns don't matter, then this statement is wrong.

@mmla The "first" column is the row index. It's not part of the data set. Which is why there's a blank spot on the first row/first column area.

@Draco18s Yes, I know. It adds nothing to the problem statement. Why include it?

@Draco18s @mmla I now show it more as a table structure. The idea is that the index is still useful to refer to the indices as in the Output - but I understand at first glance it was confusing.

Your "python" way to get example data has interchanged rows and columns. And you seem much too optimistic wrt the order of magnitude of the sizes a program that finds the optimal solution can handle.

Python3 + PuLP library
This is equivalent to a set covering problem (where the elements are column/value pairs) which can be transformed into an integer linear programming problem.
from pulp import *

def opt(mat):
    num_rows = len(mat)
    covering_rows = {}
    for row_nr, vals in enumerate(mat):
        for pair in enumerate(vals):
            covering_rows.setdefault(pair, []).append(row_nr)
    prob = LpProblem("Minimal Covering Set of Rows", LpMinimize)
    vars = LpVariable.dicts("R", range(num_rows), 0, 1, LpInteger)
    prob += lpSum([vars[i] for i in range(num_rows)])
    for rowlist in covering_rows.values():
        prob += lpSum([vars[r] for r in rowlist]) >= 1
    prob.solve()
    assert prob.status==LpStatusOptimal, "Couldn't solve"
    return [r for r in range(num_rows) if value(vars[r])==1]

On debian, the relevant package is called python3-pulp.
The function handles matrices with 20 columns and 100 rows in about one minute on weak hardware. The best way to substantially improve the speed is probably to use a better solver, which the PuLP library allows by adding an argument to the solve method call.

I am not sure what transformation is expected from the DataFrame example to be taken as input for opt?

@PascalVKooten The function takes an ordinary list of lists, so the small example is computed like this: opt([[1,1],[2,2],[3,4],[3,3],[4,4]]).

Thanks! It is very slow but it is a solution that gets an optimal result. The alternative of doing a greedy solution is much faster, but at the cost of not giving an optimal solution.

I was not able to find an optimizer that gave me a faster solution than 1 minute.

You asked for a minimal set, not a small one. I don't think you can do that much faster. Asking for the best solution one can get in a fixed time would have been another interesting challenge. What input sizes did you use in your tests?

Indeed, which is why your solution is the best as it stands. It's more for anyone who reads this to reconsider if a small set is good enough. I used your 100 by 20 to take 1 minute for an actual minimal set. As for a greedy solution, it was possible to do 10k by 200 in under a second. Further details: the minimal solution would yield 18 rows, the greedy one would yield 21 (on the 100 rows).


text:
Parallel resistance in electric circuits
Introduction:
Two resistors, R1 and R2,  in parallel (denoted R1 || R2) have a combined resistance Rp given as:
$$R_{P_2} = \frac{R_1\cdot R_2}{R_1+R_2}$$
or as suggested in comments:
$$R_{P_2} = \frac{1}{\frac{1}{R_1} + \frac{1}{R_2}}$$
Three resistors, R1, R2 and R3 in parallel (R1 || R2 || R3) have a combined resistance (R1 || R2) || R3 = Rp || R3 :
$$R_{P_3} = \frac{\frac{R_1\cdot R_2}{R_1+R_2}\cdot R_3}{\frac{R_1\cdot R_2}{R_1+R_2}+R_3}$$
or, again as suggested in comments:
$$R_{P_3} = \frac{1}{\frac{1}{R_1} + \frac{1}{R_2}+ \frac{1}{R_3}}$$
These formulas can of course be extended to an indefinite number of resistors.

Challenge:
Take a list of positive resistor values as input, and output the combined resistance if they were placed in parallel in an electric circuit. You may not assume a maximum number of resistors (except that your computer can handle it of course).
Test cases:
1, 1
0.5

1, 1, 1
0.3333333

4, 6, 3
1.3333333

20, 14, 18, 8, 2, 12
1.1295

10, 10, 20, 30, 40, 50, 60, 70, 80, 90
2.6117

Shortest code in each language wins. Explanations are highly encouraged.

There are a few other challenges that refer to the harmonic mean (1 2 3) but I don't think there is a duplicate. In line with what flawr suggested, I think this challenge body should have that phrase listed somewhere so we can close a future dupe more easily.

05AB1E, 5 3 bytes
zOz

Try it online!

Explanation
z                     # compute 1/x for each x in input
 O                    # sum input
  z                   # compute 1/sum

Excepting built-ins, this is probably as low as we can go!

Haskell, 18 16 bytes
(1/).sum.map(1/)

Try it online!

It looks beautiful.

Solution along the OP's recursive lines would be 22 chars: foldr1(\r s->r*s/(r+s)).

MATLAB, 14 bytes
In MATLAB norm(...,p) computes the p-norm of a vector. This is usually defined for \$p \geqslant 1\$ as
$$\Vert v \Vert_p = \left( \sum_i \vert v_i \vert^p \right)^{\frac{1}{p}}.$$
But luckily for us, it also happens to work for \$p=-1\$. (Note that it does not work in Octave.)
@(x)norm(x,-1)

Don't try it online!

This is horrible and beautiful simultaneously!

Thanks, these are the best compliments:)

Jelly,  5  3 bytes
İSİ

Try it online!
How?
Initially I forgot this form from my electronic engineering days ...how easily we forget.
İSİ - Link: list of numbers, R   e.g. [r1, r2, ..., rn]
İ   - inverse (vectorises)            [1/r1, 1/r2, ..., 1/rn]
 S  - sum                             1/r1 + 1/r2 + ... + 1/rn
  İ - inverse                         1/(1/r1 + 1/r2 + ... + 1/rn)

I'm assuming İ is pronounced the same way i is pronounced in list. Is this a way of saying the challenge was easy?

Octave, 15 bytes
@(x)1/sum(1./x)

Try it online!
Harmonic mean, divided by n. Easy peasy.

@tsh you know, I don't think I ever noticed that. I guess it's almost the harmonic mean...

PowerShell, 22 bytes
$args|%{$y+=1/$_};1/$y

Try it online!
Takes input via splatting and uses the same 1/sum of inverse trick as many of the others are doing

APL (Dyalog Unicode), 4 bytes
÷1⊥÷

Try it online!
-1 thanks to Adám.

APL is the original golfing language!

@YiminRong It's not a golfing language... :P

I know, but its byte count is on par with modern golfing languages!

-1 byte: ÷1⊥÷ Try it online!

@Adám Oh duh of course 1∘⊥ is the same as +/ for vectors...

Heh, it is even on APLcart.

@Adám Hm... somewhat obscure entry... :P

R, 15 bytes
1/sum(1/scan())

Try it online!
Follows the same Harmonic Mean principle seen in other answers.

JavaScript, 28 bytes
a=>a.map(y=>x+=1/y,x=0)&&1/x

Try it Online!

Perl 6, 14 bytes
1/*.sum o 1/**

Try it online!
1 / ** is an anonymous function that returns a list of the reciprocals of its arguments.  1 / *.sum is another anonymous function that returns the reciprocal of the sum of the elements of its list argument.  The o operator composes those two functions.

Very nice. I don't see HyperWhatevers used often enough in golfing since they can't be used in more complex expressions. If they were closer to normal Whatevers, I'd expect sumething like this to work, but alas...

Yeah, this is probably the first time I've even thought about using one for golfing, and I was disappointed to discover its limitations.

Perl 5 -pa -MList::Util=reduce, 26 bytes
$_=reduce{$a*$b/($a+$b)}@F

Try it online!

20 bytes

@NahuelFouilleul 17 bytes, no -M

bash + coreutils, 25 bytes
bc -l<<<"1/(0${@/#/+1/})"

TIO

Wolfram Language (Mathematica), 10 bytes
1/Tr[1/#]&

Try it online!

Is there no harmonic mean builtin, or is it longer to type?

@Eric AFAIK it's intuitively named HarmonicMean and is longer.

MathGolf, 3 bytes
∩Σ∩

The same as other answers, using the builtins ∩ (\$\frac{1}{n}\$) and Σ (sum):
$$M(x_1,...,x_n)=\frac{1}{\frac{1}{x_1} + \frac{1}{x_2} + ... + \frac{1}{x_n}}$$
Try it online.

Java 8, 24 bytes
a->1/a.map(d->1/d).sum()

I noticed there wasn't a Java answer yet, so figured I'd add one.
Try it online.
Explanation:
Uses the same Harmonic Mean approach as other answers:
$$M(x_1,...,x_n)=\frac{1}{\frac{1}{x_1} + \frac{1}{x_2} + ... + \frac{1}{x_n}}$$
a->                       // Method with DoubleStream parameter and double return-type
     a.map(d->1/d)        //  Calculate 1/d for each value `d` in the input-stream
                  .sum()  //  Then take the sum of the mapped list
   1/                     //  And return 1/sum as result

JavaScript (ES6), 29 bytes
a=>a.reduce((p,c)=>p*c/(p+c))

Try it online!
or:
a=>1/a.reduce((p,c)=>p+1/c,0)

Try it online!
But with this approach, using map() (as Shaggy did) is 1 byte shorter.

MATL, 5 bytes
,1w/s

Try it online!
I'm not sure if "do twice" (,) counts as a loop, but this is just the harmonic mean, divided by n.
Alternately, ,-1^s is five bytes as well.

PHP, 51 bytes
Reciprocal of sum of reciprocals. Input is $a.
1/array_reduce($a,function($c,$i){return$c+1/$i;});

Try it online!

With PHP7.4, I think you can do this: 1/array_reduce($a,fn($c,$i)=>$c+1/$i); (38 bytes). Read more in https://wiki.php.net/rfc/arrow_functions

I think you're right! But nowhere to demo?

You have to download it yourself. However, since PHP 7.4.0RC1 was released on the 5th of this month (https://www.php.net/archive/2019.php#2019-09-05-1), you probably are safe using it. If you have doubts, you can ask in the meta.

Python 3, 30 bytes
lambda r:1/sum(1/v for v in r)

Try it online!

Perl 5 (-p), 17 bytes
$a+=1/$_}{$_=1/$a

Try it online!

x86-64 Machine code - 20 18 bytes
0F 57 C0             xorps       xmm0,xmm0
loopHead
F3 0F 53 4C 8A FC    rcpss       xmm1,dword ptr [rdx+rcx*4-4]
0F 58 C1             addps       xmm0,xmm1
E2 F6                loop        loopHead
0F 53 C0             rcpps       xmm0,xmm0
C3                   ret

Input - Windows calling convention. First parameter is the number of resistors in RCX. A pointer to the resistors is in RDX. *ps instructions are used since they are one byte smaller. Technically, you can only have around 2^61 resistors but you will be out of RAM long before then. The precision isn't great either, since we are using rcpps.

“Only 2⁶¹ resistors” would probably fill the observable universe (many times over)!

Actually, 2^61 is only 2.305843e+18 and the observable universe is 8.8 × 10^26 m in diameter.

Yeah, serious overestimation! Actual magnitude would be around the size and mass of Deimos, smaller moon of Mars.

Intel 8087 FPU machine code, 19 bytes
 D9 E8      FLD1                    ; push 1 for top numerator on stack
 D9 EE      FLDZ                    ; push 0 for running sum
        R_LOOP:
 D9 E8      FLD1                    ; push 1 numerator for resistor
 DF 04      FILD WORD PTR[SI]       ; push resistor value onto stack
 DE F9      FDIV                    ; divide 1 / value
 DE C1      FADD                    ; add to running sum
 AD         LODSW                   ; increment SI by 2 bytes
 E2 F4      LOOP R_LOOP             ; keep looping
 DE F9      FDIV                    ; divide 1 / result
 D9 1D      FSTP WORD PTR[DI]       ; store result as float in [DI]

This uses the stack-based floating point instructions in the original IBM PC's 8087 FPU.
Input is pointer to resistor values in [SI], number of resistors in CX.  Output is to a single precision (DD) value at [DI].

Rattle, 24 bytes
|>II^[=1+#g`e_1P+~s]`e_1

Try it Online!
This answer can probably be golfed more (can anyone outgolf me in my own language?)
Explanation
|                 take input, parse automatically (Rattle's input parsing is powerful
                   enough to recognise "1,2,3" etc. as a list)
 >                move pointer to the right (to slot 1)
  I               flatten input list and insert into consecutive memory slots
   I^             get length of this list (which is still on top of the stack)
     [ ... ]`     loop structure: loop as many times as the length of the list

=1                set top of stack to 1
  +#              increment top of stack by list's iterator
                   (the number of times the loop has run)
    g`            get the value in storage at the calculated index (iterator + 1)
      e_1         get 1/x of this value
         P        set the pointer to slot 0
          +~      increment the current value by the stored value in slot 0
            s     save the result to slot 0
e_1                get 1/x of this value

Charcoal, 7 bytes
Ｉ∕¹Σ∕¹Ａ

Try it online! Link is to verbose version of code. Works by calculating the current drawn by each resistor when 1V is applied, taking the total, and calculating the resistance that would draw that current when 1V is applied. Explanation:
      Ａ Input array
    ∕¹  Reciprocal (vectorised)
   Σ    Sum
 ∕¹     Reciprocal
Ｉ       Cast to string for implicit print

Dart, 42 bytes
f(List<num>a)=>a.reduce((p,e)=>p*e/(p+e));

Try it online!
Having to explicitly specify the num type is kinda sucky, prevents type infering, because it would infer to (dynamic, dynamic) => dynamic which can't yield doubles for some reason

PHP, 40 bytes
for(;$n=$argv[++$i];$r+=1/$n);echo 1/$r;

Try it online!
Tests: Try it online!
Similar to Yimin Rong's solution but without built-ins and all program bytes are included in the bytes count.

Python 3, 58 44 bytes
f=lambda x,y=0,*i:f(x*y/(x+y),*i)if y else x

A recursive function. Requires arguments to be passed unpacked, like so:
i=[10, 10, 20]
f(*i)

or
f(10, 10, 20)

Explanation:
# lambda function with three arguments. *i will take any unpacked arguments past x and y,
# so a call like f(10, 20) is also valid and i will be an empty tuple
# since y has a default value, f(10) is also valid
f=lambda x,y=0,*i: \

# a if case else b
# determine parallel resistance of x and y and use it as variable x
# since i is passed unpacked, the first item in the remaining list will be y and
# the rest of the items will be stored in i
# in the case where there were no items in the list, y will have the default value of 0
f(x*y/(x+y),*i) \

# if y does not exist or is zero, return x
if y else x

J, 6 bytes
1%1#.%

Try it online!

it's a pity "sum under reciprocal" is the same number of bytes: +/&.:%

@ngn Yes, but your solution looks more idiomatic to J.

Ruby, 26 22 bytes
-4 bytes thanks to @ValueInk.
->x{1/x.sum{|i|1.0/i}}

Try it online!

x.sum{...} is equivalent to x.map{...}.sum

@ValueInk: Doh! Thanks a lot

[MATLAB], 15 bytes
One more byte than flawr excellent answer, but I had to use other functions so here goes:
@(x)1/sum(1./x)

It's rather explicit, it sums the inverse of the resistances, then invert the sum to output the equivalent parallel resistance.

Forth (gforth), 49 bytes
: f 0e 0 do dup i cells + @ s>f 1/f f+ loop 1/f ;

Try it online!
Input is a memory address and array length (used as an impromptu array, since Forth doesn't have a built-in array construct)
Uses the sum-of-inverse method as most other answers are
Code Explanation
: f           \ start a new word definition
  0e          \ stick an accumulator on the floating point stack
  0 do        \ start a loop from 0 to array-length -1
    dup       \ copy the array address
    i cells + \ get the address of the current array value
    @ s>f     \ get the value and convert it to a float
    1/f f+    \ invert and add to accumulator
  loop        \ end the loop definition
  1/f         \ invert the resulting sum
;             \ end the word definition

C#, 16 bytes
1/l.Sum(n=>1f/n)

Try It

Since the Sum() function can also accept a selector, you can cut 9 bytes by ommiting the .Select() part, like so

Just realized, one more byte can be saved by writing 1f/n instead of 1.0/n as both methods will avoid integer division.

nice catch mate!

expl3 (LaTeX3 programming layer), 65 bytes
The following defines a function that prints the result to the terminal (unfortunately expl3 has very verbose function names):
\def\1#1{\fp_show:n{1/(\clist_map_function:nN{#1}\2)}}\def\2{+1/}

A complete script which can be run from the terminal including all the test cases as well as the setup to enter expl3:
\RequirePackage{expl3}\ExplSyntaxOn
\def\1#1{\fp_show:n{1/(\clist_map_function:nN{#1}\2)}}\def\2{+1/}
\1{1, 1}
\1{1, 1, 1}
\1{4, 6, 3}
\1{20, 14, 18, 8, 2, 12}
\1{10, 10, 20, 30, 40, 50, 60, 70, 80, 90}
\stop

If run with pdflatex <filename> the following is the console output:
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./cg_resistance.tex
LaTeX2e <2018-12-01>
(/usr/local/texlive/2019/texmf-dist/tex/latex/unravel/unravel.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def))
 (/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/gtl/gtl.sty))
> 1/(\clist_map_function:nN {1,1}\2)=0.5.
<recently read> }

l.3 \1{1, 1}

?
> 1/(\clist_map_function:nN {1,1,1}\2)=0.3333333333333333.
<recently read> }

l.4 \1{1, 1, 1}

?
> 1/(\clist_map_function:nN {4,6,3}\2)=1.333333333333333.
<recently read> }

l.5 \1{4, 6, 3}

?
> 1/(\clist_map_function:nN {20,14,18,8,2,12}\2)=1.129538323621694.
<recently read> }

l.6 \1{20, 14, 18, 8, 2, 12}

?
> 1/(\clist_map_function:nN
{10,10,20,30,40,50,60,70,80,90}\2)=2.611669603067675.
<recently read> }

l.7 \1{10, 10, 20, 30, 40, 50, 60, 70, 80, 90}

?
 )
No pages of output.
Transcript written on cg_resistance.log.

Explanation
\fp_show:n
: evaluates its argument as a floating point expression and prints the result on the terminal, every expandable macro is expanded during that process.
\clist_map_function:nN
: takes two arguments, a comma separated list and a function/macro, if called like \clist_map_function:nN { l1, l2, l3 } \foo it expands to something like \foo{l1}\foo{l2}\foo{l3}. In our case instead of \foo the macro \2 is used, which expands to +1/ so that the expression expands to +1/{l1}+1/{l2}+1/{l3}

SimpleTemplate, 72 bytes
Okay, this was VERY hard!
Specifically with a language that has VERY poor math support.
{@fnx A,S}{@eachA}{@set/_ 1 _}{@set+S S,_}{@/}{@set/S 1 S}{@returnS}{@/}

Creates a function x that must be called by passing an array as the first and only argument.
Ungolfed:
{@fn calc values, sum}
    {@each values as value}
        {@set/ value 1 value}
        {@set+ sum sum, value}
    {@/}
    {@set/ sum 1 sum}
    {@return sum}
{@/}

Explanation:

{@fn calc values, sum} - Creates the function calc, which has 2 variables (values and sum) taking the values of the first arguments (defaults to null)
{@each values as value} - Loops over each value in values
{@set/ value 1 value} - Divides 1 by value, storing it into value
{@set+ sum sum, value} - Adds sum to value, storing it into sum
{@/} - Closes the {@each} (usually optional)
{@set/ sum 1 sum} - Divides 1 by sum, storing it into sum
{@return sum} - Returns sum (duh)
{@/} - Closes the {@fn} (usually optional, even if it shouldn't be for functions)

To use the function, you can use this code:
{@set values 10, 10, 20, 30, 40, 50, 60, 70, 80, 90} {@//array of values}
{@call calc into result values}
{@echo result} {@//2.6116696030677}

If you are curious, the ungolfed example compiles to this PHP code:
// {@fn calc values, sum}
$DATA['calc'] = function()use(&$FN, &$_){
    $DATA = array(
        'argv' => func_get_args(),
        'argc' => func_num_args(),
        'VERSION' => '0.62',
        'EOL' => PHP_EOL,
        'PARENT' => &$_
    );
    $_ = &$DATA;
    $DATA["values"] = &$DATA["argv"][0];
    $DATA["sum"] = &$DATA["argv"][1];

    // {@each values as value}
    // loop variables
    $tmp_1_val = isset($DATA['values']) ? $tmp_1_val = &$DATA['values'] : null;
    $tmp_1_keys = gettype($DATA['values']) == 'array'
        ? array_keys($DATA['values'])
        : array_keys(range(0, strlen($tmp_1_val = $tmp_1_val . '') - 1));
    $tmp_1_key_last = end($tmp_1_keys);

    // loop
    foreach($tmp_1_keys as $tmp_1_index => $tmp_1_key){
        $DATA['loop'] = array(
            'index' => $tmp_1_index,
            'i' => $tmp_1_index,
            'key' => $tmp_1_key,
            'k' => $tmp_1_key,
            'value' => $tmp_1_val[$tmp_1_key],
            'v' => $tmp_1_val[$tmp_1_key],
            'first' => $tmp_1_key === $tmp_1_keys[0],
            'last' => $tmp_1_key === $tmp_1_key_last,
        );
        $DATA['__'] = $tmp_1_key;
        $DATA['value'] = $tmp_1_val[$tmp_1_key];

        // {@set/ value 1 value}
        $DATA['value'] = array_map(function($value)use(&$DATA){return (1 / $value);}, $FN['array_flat']((isset($DATA['value'])?$DATA['value']:null)));

        // {@set+ sum sum, value}
        $DATA['sum'] = array_sum($FN['array_flat'](array((isset($DATA['sum'])?$DATA['sum']:null),(isset($DATA['value'])?$DATA['value']:null))));

    // {@/}
    };

    // {@set/ sum 1 sum}
    $DATA['sum'] = array_map(function($value)use(&$DATA){return (1 / $value);}, $FN['array_flat']((isset($DATA['sum'])?$DATA['sum']:null)));

    // {@return sum}
    return (isset($DATA['sum'])?$DATA['sum']:null);

// {@/}
};

// {@set values 10, 10, 20, 30, 40, 50, 60, 70, 80, 90}
$DATA['values'] = array(10,10,20,30,40,50,60,70,80,90);

// {@call calc into result values}
$DATA['result'] = call_user_func_array(isset($DATA['calc']) && is_callable($DATA['calc'])? $DATA['calc']: (isset($FN["calc"])? $FN["calc"]: "calc"), array((isset($DATA['values'])?$DATA['values']:null)));

// {@echo result}
echo implode('', $FN['array_flat']((isset($DATA['result'])?$DATA['result']:null)));

Vyxal d, 3 bytes
Ė∑Ė

Try it Online!
Reciprocal, sum, reciprocal.
You can remove d if you're fine with the result being double-wrapped in a list for some reason.

am I crazy or is that 7 bytes, not 3? (the TIO link is just for the byte count)

@DanielH. Vyxal scores bytes using a SBCS, or Single Byte Character Set here.

Pyth, 6 bytes
c1scL1

Try it online!
Uses the modified formula \$\frac{1}{R_P}=\frac{1}{R_1} + \frac{1}{R_2}\$.
c1      # 1/
  s     #   sum(                     )
   cL1  #       map(lambda x: 1/x, Q)  # Q (=input) is implicit

Japt v2.0a0, 7 bytes
1÷Ux!÷1

Try it

OCaml, 50 bytes
fun l->1./.(List.fold_left(fun a e->a+.1./.e)0. l)

Try it online!

Stax, 5 bytes
{u+Fu

Run and debug it at staxlang.xyz!
{  F     For each:
 u         Invert
  +        Add to running total
    u    Invert
         Implicit print as fraction

Python, 30 bytes
lambda v:1/sum(1/x for x in v)

-2, thanks @JoKing

Welcome to PPCG! Unfortunately, submissions should either be a full program (preface with v=input();print ) or a function (preface with lambda v:) to be valid. A snippet which presumes pre-defined variables isn't allowed.

Welcome to the site! This is a snippet, which means that you don't output or input according to our Input/Output rules. You can correct this by wrapping the statement in print(...) and by taking v as input, either in a lambda or by using input.

That's unfortunate, thanks for pointing me to the IO conventions. I have updated my answer. :)

Scala, 15 bytes
1/_.map(1/).sum

Try it online!

jq, 16 characters
1/(map(1/.)|add)

Sample run:
bash-5.0$ jq '1/(map(1/.)|add)' <<< '[10, 10, 20, 30, 40, 50, 60, 70, 80, 90]'
2.611669603067675

Try it online!

C (gcc), 65 62 bytes
Thanks to ceilingcat for -3 bytes.

float a(b,c)int*b;{float d=0;for(;c--;)d+=1./b[c];return 1/d;}

Try it online!

if you change it to clang on TIO, you can do float a(*b,c) instead of float a(b,c)int*b;

C++ (clang), 78 bytes
#import<list>
void f(std::list<int>r,double&s){s=0;for(int p:r)s+=1./p;s=1/s;}

Try it online!

77 bytes

Pyt, 3 bytes
⅟Ʃ⅟

Try it online!
⅟        implicit input; take reciprocal
 Ʃ       sum
  ⅟      take reciprocal; implicit print

Thunno, \$ 3 \log_{256}(96) \approx \$ 2.47 bytes
oSo

Attempt This Online!
Explanation
oSo  # Implicit input
o    # Inverse: 1 / input
 S   # Sum this list
  o  # Inverse: 1 / sum
     # Implicit output

JavaScript (Node.js), 27 bytes
a=>1/eval('1/'+a.join`+1/`)

Try it online!

Thunno 2, 3 bytes
ỊSỊ

Try it online!
Explanation
ỊSỊ  # Implicit input
Ị    # Reciprocal
 S   # Sum
  Ị  # Reciprocal
     # Implicit output


text:
Write a function that returns an iterable object of all valid points 4-directionally adjacent to (x, y)
A very common need in algorithms classes and computer science in general is to iterate 4-directionally over a grid or matrix (such as in BFS or DFS). This seems to often result in a lot of clunky and verbose code with a lot of arithmetic and comparisons within loops. I've seen many different approaches to this, but I can't shake the feeling that there's a more concise way to do this.
The challenge is to write a pure function that, given the width and height of a finite plane n, m originating at point (0,0), and coordinates (x,y) that can represent any valid point within that plane, returns an iterable object of all points within the plane that are 4-directionally adjacent to (x,y).
The goal is to define that function in as few bytes as possible.
Some examples to help illustrate valid input/output:
n = 5 (y-axis), m = 3 (x-axis) (zero-based)

matrix = [
    [A, B, C],
    [D, E, F],
    [G, H, I],
    [J, K, L],
    [M, N, O],
]

(x, y) => [valid iterable points]

E: (1, 1) => [(1, 0), (2, 1), (1, 2), (0, 1)]
A: (0, 0) => [(1, 0), (0, 1)]
L: (2, 3) => [(2, 2), (2, 4), (1, 3)]
N: (1, 4) => [(1, 3), (2, 4), (0, 4)]

n = 1 (y-axis), m = 1 (x-axis) (zero-based)

matrix = [
    [A],
]

(x, y) => [valid iterable points]

A: (0, 0) => []

n = 2 (y-axis), m = 1 (x-axis) (zero-based)

matrix = [
    [A],
    [B],
]

(x, y) => [valid iterable points]

A: (0, 0) => [(0, 1)]
B: (0, 1) => [(0, 0)]

And here's an example (this one in Python) of a function that satisfies the conditions:
def four_directions(x, y, n, m):
    valid_coordinates = []
    for xd, yd in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        nx, ny = x + xd, y + yd
        if 0 <= nx < m and 0 <= ny < n:
            valid_coordinates.append((nx, ny))
    return valid_coordinates

The example above defined a named function, but anonymous functions are also acceptable.
The inputs n, m, x, y are all unsigned 32-bit integers within the following ranges:
n > 0
m > 0
0 <= x < m
0 <= y < n

The output must take the form of an iterable (however your language of choice defines that) of (x, y) pairs.
Additional clarifications:
Complex numbers (and other representations/serializations) are OK as long as the consumer of the iterable can access x and y as integers knowing only their location.
Non-zero-based indexes are acceptable, but only if the language of choice is a non-zero-indexed language. If the language uses a mix of numbering systems, default to the numbering system of the data structure most commonly used to represent a matrix. If these are still all foreign concepts in the given language, any starting index is acceptable.

Welcome to the site! This challenge is pretty good by our standards, but there are a couple of things here that go against our style.  For one we much prefer challenges that do not restrict to a single language if possible.  It is much more fun when everyone can compete.  We also generally score code-golf in bytes as opposed to characters, they are the same for most purposes but there are a couple of cheaty things you can do if answers are scored in characters.  Hope you have fun here!

We're guaranteed that (x,y) itself is in the rectangle, right?

@xnor yes, x, y is guaranteed to be a point that exists

By default, CGCC allows full programs as well as functions as submissions. This helps allow languages that don't necessarily have a concept of functions to compete as well

@JoKing How would that work with a full program, considering the goal is an in-code iterable? Happy to accept that, I'm just not sure how the desired output would be defined.

An output would be to STDOUT, rather than a code object. This can generally be any output with clear delimiters so it is unambiguous and follow the default Standard output formats

Is it allowed to represent coordinates as complex numbers rather than integer tuples?

Can we use 1-indexed coordinates?

@Joel Complex numbers (and other representations/serializations) are OK as long as the consumer of the iterable can access x and y as integers knowing only their location

@JoKing I would say yes, but only if the language of choice is a 1-indexed language. If the language has a mix of 0-based and 1-based indexing, default to the numbering system of the data structure most commonly used to represent a matrix.

Python 2, 66 bytes
lambda m,n,x,y:[(x-1,y),(x+1,y)][~x:m-x]+[(x,y-1),(x,y+1)][~y:n-y]

Try it online!
Lists the four neighbors, then uses list slicing to remove those that are out-of-bounds.

Python 2, 71 bytes
lambda m,n,x,y:[(k/n,k%n)for k in range(m*n)if(k/n-x)**2+(k%n-y)**2==1]

Try it online!
Instead of checking which of the four neighbors are in-bounds, we do it the slower way of checking all in-bounds points for those that are neighbors, that is have Euclidian distance exactly 1 from (x,y). We also use the classic div-mod trick to iterate over a grid, saving the need to write two loops like for i in range(m)for j in range(n).
I tried using complex arithmetic to write the distance condition, but it turned out longer to write abs((k/n-x)*1j+k%n-y)==1.

Python 2, 70 bytes
lambda m,n,x,y:[(x+t/3,y+t%3-1)for t in-2,0,2,4if m>x+t/3>=0<y+t%3<=n]

Try it online!

Congrats on the 100k!

Octave, 90 bytes
This uses a geometric approach: First we create an matrix of zeros of the desired size, and set a 1 to the desired location. Then we convolve with the kernel
[0, 1, 0]
[1, 0, 1]
[0, 1, 0]

which produces a new matrix of the same size with ones at the 4-neighbours of the original point. Then we find() the indices of the nonzero entries of this new matrix.
function [i,j]=f(s,a,b);z=zeros(s);z(a,b)=1;[i,j]=find(conv2(z,(v=[1;-1;1])*v'<0,'same'));

Try it online!
convolution is the key to success.

Indeed it is, no matter how small the font

Supbpbpbpberb technique ;-)

Wolfram Language (Mathematica), 42 37 bytes
pNorm[{##}-p]&~Array~#~Position~1&

Try it online!
Input [{x,y}][{m,n}]. 1-indexed, following Mathematica's convention.

JavaScript (ES6), 74 bytes
Boring approach.
(h,w,x,y)=>[x&&[x-1,y],~x+w&&[x+1,y],y&&[x,y-1],++y-h&&[x,y]].filter(_=>_)

Try it online!

JavaScript (Node.js), 74 bytes
Less boring but just as long. Takes input as ([h,w,x,y]).
a=>a.flatMap((_,d,[h,w,x,y])=>~(x+=--d%2)*~(y+=--d%2)&&x<w&y<h?[[x,y]]:[])

Try it online!

JavaScript (V8), 67 bytes
If all standard output methods were allowed, we could just print the valid coordinates with:
(h,w,x,y)=>{for(;h--;)for(X=w;X--;)(x-X)**2+(y-h)**2^1||print(X,h)}

Try it online!

Jelly,  13  12 bytes
2ḶṚƬNƬẎ+⁸%ƑƇ

A dyadic Link accepting a list of two (0-indexed) integers on the left, [row, column], and two integers on the right, [height, width], which yields a list of lists of integers, [[adjacent_row_1, adjacent_column_1], ...].
Try it online!
How?
2ḶṚƬNƬẎ+⁸%ƑƇ - Link: [row, column]; [height, width]   e.g. [3,2]; [5,3] (the "L" example)
2            - literal 2                                   2
 Ḷ           - lowered range                               [0,1]
   Ƭ         - collect up while distinct, applying:
  Ṛ          -   reverse                                   [[0,1],[1,0]]
     Ƭ       - collect up while distinct, applying:
    N        -   negate                                    [[[0,1],[1,0]],[[0,-1],[-1,0]]]
      Ẏ      - tighten                                     [[0,1],[1,0],[0,-1],[-1,0]]
        ⁸    - chain's left argument ([row, column])       [3,2]
       +     - add (vectorises)                            [[3,3],[4,2],[3,1],[2,2]]
           Ƈ - filter keep if:
          Ƒ  -   is invariant under:
         %   -     modulo ([height, width]) (vectorises)    [3,0] [4,2] [3,1] [2,2]
             - (...and [3,0] is not equal to [3,3] so ->)  [[4,2],[3,1],[2,2]]

You can replace ḶṚƬ with Ṭ€. 2ḶṚƬNƬẎ returns [[0, 1], [1, 0], [0, -1], [-1, 0]], while 2Ṭ€NƬẎ returns [[1], [0, 1], [-1], [0, -1]], and, since the singletons are wrapped, + only vectorizes with the first element of ⁸ for those, so they act as though their second element is 0 (the additive identity). As a result, only the order of the output may change.

Perl 6, 56 49 bytes
-7 bytes thanks to nwellnhof!
{grep 1>(*.reals Z/@^b).all>=0,($^a X+1,-1,i,-i)}

Try it online!
Removes the out of bounds elements by checking if when divided by the array bounds it is between 0 and 1. Takes input and output via complex numbers where the real part is the x coordinate and the imaginary is the y. You can extract these through the .im and .re functions.

49 bytes

@nwellnhof Very nice! I'd build on it to do something like this, but div doesn't seem to work for Nums

(*.reals>>.Int Zdiv@^b).none or (*.reals Z/@^b)>>.Int.none would work but the Int-cast seems too costly.

J, 30 29 28 bytes
(([+.@#~&,1=|@-)j./)~j./&i./

Try it online!
How:

Turn the right hand m x n arg into a grid of complex numbers j./&i./
Same for left arg (our point) j./
Create a mask showing where the distance between our point and the grid is exactly 1 1=|@-
Use that to filter the grid, after flattening both #~&,
Turn the result back into real points +.@

Haskell, 62 bytes
Using
f m n a b = [(x,y)|x<-[0..m-1],y<-[0..n-1],(x-a)^2+(y-b)^2==1]

Try it online!
Boring approach: 81 bytes
f m n x y=filter (\(x,y)->x>=0&&y>=0&&x<m&&y<n) [(x-1,y),(x+1,y),(x,y-1),(x,y+1)]

C# (Visual C# Interactive Compiler), 91 bytes
(a,b,x,y)=>new[]{(x+1,y),(x-1,y),(x,y+1),(x,y-1)}.Where(d=>((x,y)=d,p:x>=0&x<a&y>=0&y<b).p)

Try it online!
Alternatively:
(a,b,x,y)=>new[]{(x+1,y),(x-1,y),(x,y+1),(x,y-1)}.Where(d=>((x,y)=d).Item1>=0&x<a&y>=0&y<b)

Try it online!

Charcoal, 29 bytes
Ｊθη#ＦＩζＦＩε«Ｊικ¿№ＫＶ#⊞υ⟦ικ⟧»⎚Ｉυ

Try it online! Link is to verbose version of code. Takes inputs in the order x, y, width, height. Explanation:
Ｊθη#

Print a # at the provided position.
ＦＩζＦＩε«

Loop over the given rectangle.
Ｊικ

Jump to the current position.
¿№ＫＶ#⊞υ⟦ικ⟧

If there's an adjacent # then save the position.
»⎚Ｉυ

Output the discovered positions at the end of the loop.
Boring answer:
ＦＩζＦＩε¿⁼¹⁺↔⁻ιＩθ↔⁻κＩηＩ⟦ικ

Try it online! Link is to verbose version of code. Works by finding the adjacent positions mathematically.

Pip -xp, 18 bytes
$ALaCGbFI1=$+:_ADc

Takes three command-line arguments: m, n, and a list containing x & y. Replit! Or, here's a similar program in Pip Classic with a header to simulate the -x flag: Try it online!
Explanation
Generates a list of all points in the valid rectangle and filters for the ones that are one unit away from the given point.
$ALaCGbFI1=$+:_ADc
   aCGb             Generate a coordinate grid of a rows and b columns
$AL                 Fold on append-list: flatten once, giving a list of coord pairs
       FI           Filter on this function:
              _      The argument
               AD    Absolute difference (element-wise) with
                 c   The program's third argument
           $+:       The sum of the resulting pair
         1=          Must equal 1


text:
Some Prime Peerage
(Randomly inspired by https://mathoverflow.net/q/339890)
(Related: 1, 2)
Given an input list of distinct prime numbers (e.g., [2, 5, 7]), and a integer n, output all positive integers strictly smaller than n that contain only those primes as divisors. For input [2, 5, 7] and n=15 this means an output of [2, 4, 5, 7, 8, 10, 14].
Further Examples
[list] n | output

[2, 5, 7] 15 | [2, 4, 5, 7, 8, 10, 14]
[2, 5, 7] 14 | [2, 4, 5, 7, 8, 10]
[2] 3 | [2]
[2] 9 | [2, 4, 8]
[103, 101, 97] 10000 | [97, 101, 103, 9409, 9797, 9991]
[97, 101, 103] 104 | [97, 101, 103]

Rules and Clarifications

The input list is guaranteed non-empty, but may be only a single element
You can assume the input list is pre-sorted in whatever way is most convenient
n will always be larger than the largest element in the input list
Since, e.g., 2**0 = 1, you can optionally include 1 in your output list
Input and output can be given by any convenient method
You can print the result to STDOUT or return it as a function result
Either a full program or a function are acceptable
If applicable, you can assume the input/output integers fit in your language's native int range
Standard loopholes are forbidden
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins

Can we output in any order?

@xnor Yes, output in any order is fine.

Excuse me.. Just to be absolutely sure: "that contain only those primes as divisors" means "that contains only at least one of those primes as prime divisors"?

You should have informed the existing solutions of the change to the spec to allow 1 in the output.

@AZTECCO Right. But, for example, if your list is [2, 3, 7] you can't use 5.

@Shaggy Sorry - I didn't realize it made a difference to existing answers, or I would have.

05AB1E, 6 5 bytes
PmÑʒ›

-1 byte thanks to @ovs (and @Grimmy, who provided sиPÑʒ› as 6 bytes alternative initially).
Takes the list as first input, and integer as second. Includes the optional 1 in the output.
Extremely slow approach (the [2,5,7], 15 test case already times out).
Try it online. (No test suite, because it's too slow for most.)
Explanation:
P      # Take the product of the (implicit) input-list
       #  i.e. [2,5] → 10
 m     # Take the (implicit) input-integer to the power this product
       #  i.e. 10 → 10000000000
  Ñ    # Get all divisors of this integer
       # (the bottleneck for larger integers in this approach)
       #  → [1,2,4,5,8,10,16,20,25,32,40,50,64,80,100,125,128,160,200,250,256,320,400,500,512,625,640,800,1000,1024,1250,1280,1600,2000,2500,2560,3125,3200,4000,5000,5120,6250,6400,8000,10000,12500,12800,15625,16000,20000,25000,25600,31250,32000,40000,50000,62500,64000,78125,80000,100000,125000,128000,156250,160000,200000,250000,312500,320000,390625,400000,500000,625000,640000,781250,800000,1000000,1250000,1562500,1600000,1953125,2000000,2500000,3125000,3200000,3906250,4000000,5000000,6250000,7812500,8000000,9765625,10000000,12500000,15625000,16000000,19531250,20000000,25000000,31250000,39062500,40000000,50000000,62500000,78125000,80000000,100000000,125000000,156250000,200000000,250000000,312500000,400000000,500000000,625000000,1000000000,1250000000,2000000000,2500000000,5000000000,10000000000]
   ʒ   # Filter this list of divisors:
    ›  #  Only keep those where the (implicit) input-integer is larger than the divisor
       #  → [1,2,4,5,8]
       # (after the filter, the result is output implicitly)

Two faster 6 bytes alternatives:
<LʒfåP

Takes the integer as first input, list as second. Includes the optional 1 in the output.
Try it online or verify all test cases.
Explanation:
<       # Decrease the (implicit) input by 1
 L      # Create a list in the range [1,input-1]
  ʒ     # Filter it by:
   f    #  Get all prime factors of the current number (without duplicates)
    å   #  Check for each if its in the (implicit) input-list
     P  #  And check if this is truthy for all
        # (after the filter, the result is output implicitly)

Thanks to @Grimmy:
GNfåP–

Try it online or verify all test cases.
G       # Loop `N` in the range [1, (implicit) input):
 Nf     #  Get all prime factors of `N` (without duplicates)
   å    #  Check for each if its in the (implicit) input-list
    P   #  And check if this is truthy for all
     –  #  If it is, output the current `N` with trailing newline

Alternative 7: sиPÑ¦ʒ›. I thought I had a 6, but there doesn't seem to be a way around using s/I/¹

@Grimy Nice alternative, but that sure takes a long long time to execute, though. For first test case it has to find all divisors of 4747561509943000000000000000. ;)

For vertical output: GNfåP–

For the last approach PmÑʒ› works at 5 bytes.

@ovs Thanks! Pretty logical now that I see it, but well done coming up with it. :)

Stax, 6 bytes
Ç─☼?▬µ

Run and debug it at staxlang.xyz!
Unpacked (7 bytes) and explanation:
vf:Fn-!
vf         Filter range [1..n-1]:
  :F         Distinct prime factors
    n-       Remove all in provided list
      !      Is empty?

JavaScript (ES6),  64 ... 52  50 bytes
Takes input as (n)(primes) where primes is a set. Outputs by modifying the set.
n=>g=(s,q=1)=>{for(p of s)(p*=q)<n&&g(s.add(p),p)}

Try it online!
Commented
n =>              // n = maximum value
g = (             // g is a recursive function taking:
  s,              //   s = set of primes
  q = 1           //   q = current product, initialized to 1
) => {            //
  for(p of s)     // for each value p in s:
    (p *= q)      //   multiply p by q
    < n &&        //   if the result is less than n:
      g(          //     do a recursive call:
        s.add(p), //       with p added to the set
        p         //       with q = p
      )           //     end of recursive call
}                 //

Python 3, 68 65 bytes
f=lambda s,n,c=1:n//c*s and f(s,n,s[0]*c)+f(s[1:],n,c)or[c][:c<n]

Try it online!
-3 bytes thanks to @xnor
The function takes a prime sequence and an integer n as inputs. The output is a list that includes 1.
Ungolfed:
def f(s, n, c=1):
    if not c < n:
       return []
    elif not s:
       return [c]
    else:
       return f(s,n,s[0]*c) + f(s[1:],n,c)

Try it online!

That's some neat short-circuiting code you have. It looks like you can combine the first two conditions as c*s<n*s. Edit: n//c*s is shorter.

@xnor Thanks for the improvement. Your approach is quite good as well.

Haskell, 51 bytes
For each prime x in the list of primes p the expression mapM((<$>[0..n]).(^))p computes all powers \$1,x,x^2,\ldots,x^n\$ (where \$n\$ is the second input just used as an upper bound) and then the cartesian product of all these sequences. After that we compute the product of all entries of this cartesian product and filter out all that are too large.
This means that it is incredibly slow or might even crash if n is large or the list of primes p is large, as this cartesian product contains \$(\#p)^n\$ entries.
p#n=[k|k<-product<$>mapM((<$>[0..n]).(^))p,k<n,k>1]

Try it online!

Haskell, 39 bytes
l%n=[k|k<-[2..n-1],mod(product l^k)k<1]

Try it online!
Checks if k is divisible only by primes in l by seeing if the product of l taken to a high power is divisible by k.

Python 2, 65 bytes
lambda l,n:[k for k in range(2,n)if reduce(int.__mul__,l)**n%k<1]

Try it online!
Checks if k is divisible only by primes in l by seeing if the product of l taken to a high power is divisible by k.
If l can be taken as a list of strings eval("*".join(l)) saves 3 bytes over reduce(int.__mul__,l) and can be used in Python 3 which lacks reduce.
Python 3, 64 bytes
def f(l,n,P=1):
 for x in l:P*=x
 n-=1;P**n%n or print(n);f(l,n)

Try it online!
A function the prints in reverse order and terminates with error.
The recursive solution below would be shorter if n itself were included in the list. I tried recursively computing the product of l as well, but that was longer.
62 bytes (non-working)
f=lambda l,n:n*[f]and[n][reduce(int.__mul__,l)**n%n:]+f(l,n-1)

Try it online!

APL (Dyalog Unicode), 25 bytes SBCS
{⍺{v/⍨⍺>v←∪,∘.×⍨⍵}⍣⍺⊢1,⍵}

Try it online!
How it works:
The main idea of this solution is that we take the input primes ⍵, we prepend 1 to them with 1,⍵ and we multiply these numbers all together a bunch of times, where "a bunch of times" is the n input (refered to by ⍺). This repetition is controlled by ⍣⍺. What we actually repeat is the inner dfn
{v/⍨⍺>v←∪,∘.×⍨⍵}
This dfn takes as ⍺ the input n and as ⍵ the multiplications we have so far. Then, ∘.×⍨⍵ multiplies all those accumulated multiplications so far with themselves, into a matrix that looks like a "times table" of ⍵ with itself.
Then ∪, flattens and removes duplicates and assigns that to v with v←.
Finally, v/⍨⍺>v filters out elements greater than or equal to ⍺, which is the n input.

https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/6s1HvVuftS7S/NRx8pHvVt1dB51zNA7PP1R7wogr/ZR7@JHnQv/pykA1SqkAYlHvX2Pupof9a551Lvl0HrjR20TgUYFBzkDyRAPz@D/hgZAoJCmYGhgDMSGCpbmAA 17 chars

Gaia, 10 bytes
…@e⟪ḍ‡⁻!⟫⁇

Try it online!
I've never used ‡ with a monad before, it's quite helpful for stack manipulation.
…		| push [0..n-1]
@e		| push list of primes
  ⟪    ⟫⁇	| filter [0..n-1] for where the following predicate is true:
   ḍ‡		| the list of prime factors
     ⁻		| minus the list of primes
      !		| is empty

J, 24 bytes
(]#~0=1#.(-."1~q:))2}.i.

Try it online!

Jelly, 7 bytes
ṖÆffƑ¥Ƈ

Try it online!
A dyadic link taking the exclusive upper bound as its left argument and the list of primes as its right. Returns a list that includes 1 as well as the numbers only composed of the supplied primes.
An alternative 7 would be ṖÆfḟ¥Ðḟ

Python 2, 98 bytes
lambda a,n:[i for i in R(2,n)if{p for p in R(2,i+1)if(i%p<1)*all(j%p for j in R(2,p))}<=a]
R=range

Try it online!

C (clang), 115 bytes
#define f(n,l,z){int j,i,k,x[n]={};for(i=x[1]=1;i<n;printf(x[i]+"\0%d ",i++))for(j=z;j--;k<n?x[k]=x[i]:0)k=i*l[j];}

Try it online!
A Sieve of Eratosthenes based solution.
(Includes 1 in the output)
Thanks to @ceilingcat suggestion :
  printf(x[i]+"\0%d ",i++) instead of x[i]&&printf("%d ",i),i++
  I suppose it shifts the pointer of the literal but didn't found any documentation, if anyone can give me some insights it would be welcome.

Thanks but.. how does it work?

If x[i]==1 then the string is "%d ". If x[i]==0 then the string is "". C strings are null terminated so an explicit null character terminates the string. This hack also abuses some undefined behavior in clang related to the i++.

Japt -f, 11 8 bytes
k
è@e!øV

Try it

Japt -f, 7 bytes
©k e!øV

Try it

This includes 1 in the output, which it shouldn't. I started with k e!øV for my solution too but needed the 2 extra bytes to filter 0 & 1.

Since, e.g., 2**0 = 1, you can optionally include 1 in your output list

That was not a part of the original spec.

Ruby -rprime, 61 bytes
->n,l{(2..n).select{|i|i.prime_division.all?{|b,|[b]-l==[]}}}

Try it online!

Retina 0.8.2, 64 bytes
\d+
$*
\G1
$.`,$`;
+`,(1+)(\1)*(?=;.* \1\b)
,1$#2$*
!`\d+(?=,1;)

Try it online! List includes smaller test cases (10000 times out because of all the long strings). Takes input in the order n f1 f2 f3... (factors do not need to be prime but they do need to be coprime). Output includes 1. Explanation:
\d+
$*

Convert to unary.
\G1
$.`,$`;

Generate a list from 0 to n-1, in both decimal and unary.
+`,(1+)(\1)*(?=;.* \1\b)
,1$#2$*

Repeatedly divide the unary by any available factors.
!`\d+(?=,1;)

Output the decimal numbers where the unary number has been reduced to 1.

Charcoal, 22 20 bytes
ＩΦ…²η⬤…·²ι∨﹪ιλ⊙θ¬﹪λν

Try it online! Link is to verbose version of code. Too slow for the larger test case. Explanation:
 Φ                      Filter on
  …                     Range from
   ²                    Literal `2` to
    η                   Input limit
     ⬤                  Where all values
      …·                Inclusive range from
        ²               Literal `2` to
         ι              Filter value
          ∨             Either
             λ          Inner value
           ﹪            Is not a divisor of
            ι           Filter value
              ⊙         Or any of
               θ        Input primes
                   ν    Current prime
                ¬﹪      Is a divisor of
                  λ     Inner value
Ｉ                       Cast to string for implicit print

Previous faster 22-byte answer:
⊞υ¹ＦυＦ×ιθＦ›‹κη№υκ⊞υκＩυ

Try it online! Link is to verbose version of code. Output includes 1. Explanation:
⊞υ¹

Push 1 to the predefined empty list.
Ｆυ

Loop over the list, including any items pushed to it during the loop.
Ｆ×ιθ

Multiply the current item by each prime and loop over the products.
Ｆ›‹κη№υκ

Check whether the product is a new value.
⊞υκ

If so then push it to the list.
Ｉυ

Print the list.

Pyth, 10 bytes
f!-PThQtUe

Try it online!
Takes input as [[primes...], n]
        Ue  # range(0, Q[-1])  (Q is the input, implicit)
       t    #                [1:] -> range(1, Q[-1]), tUe == PSe
f           # filter that on the condition: lambda T:
   PT       # prime_divisors(T)
  -  hQ     #                   - Q[0]
 !          # logical negation (![] == True)

Perl 6, 27 bytes
{grep [*](@^a)**$^b%%*,^$b}

Try it online!
Port of xnor's Haskell solution. Also outputs 1.

Husk, 8 bytes
fȯ¦⁰upŀ²

Try it online!