text:
Will Mario fall into the Shrinking Satellite? (Diagram added)
Super Mario Galaxy features two rhombicuboctahedron-shaped* planets tiled with platforms that shrink as Mario runs across. Should Mario fall into a triangular hole or a gap left by a tile he previously touched, he will be consumed by the black hole at the core. (Watch: Hurry-Scurry Galaxy, Sea Slide Galaxy)

Image: MarioWiki.com
(You can think of the planet as a 2x2x2 cube whose faces have been detached and connected to each other by 2x3 "bridges".)
Unfortunately, since my controller is very broken, Mario cannot jump and is limited to the four cardinal directions. Additionally, Mario moves very slowly and cannot retrace even one step without first having the platform behind him disappear.
Let's assume the camera is always above Mario's head and he starts at the bottom right of a 2x2 face:
      ■ ■
      ■ ■
      ■ ■
■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ M ■ ■ ■
      ■ ■
      ■ ■
      ■ ■

Your program will take a list or string of directions, U D L R (up, down, left, right), representing Mario's walk around the planet so far as a series of steps. The program can output one of two distinct outputs: one representing that Mario is still alive and walking, and the other representing that somewhere along his walk, Mario has fallen into the Shrinking Satellite.
RR:   ■ ■                 RRD:  ■ ■                 RRL:  ■ ■
      ■ ■                       ■ ■                       ■ ■
      ■ ■                       ■ ■                       ■ ■
■ ■ ■ ■ ■ ■ ■ ■           ■ ■ ■ ■ ■ ■ ■ ■           ■ ■ ■ ■ ■ ■ ■ ■
■ ■ ■ ■ □ □ M ■           ■ ■ ■ ■ □ □ □ ■           ■ ■ ■ ■ □ M □ ■
      ■ ■    \                  ■ ■   M                   ■ ■  \
      ■ ■     Let's-a go!       ■ ■    \                  ■ ■   W-aaaaaaaaaahh!
      ■ ■                       ■ ■     W-aaaaaaaaaahh!   ■ ■

Of course, unlike the above diagrams, you'll have to take the 3D into account. Here's a diagram that might help you visualize the scenario better:
                Top 2x2 face
   <- clockwise           anticlockwise ->
   -   ■    -    ■    -    ■    -    ■   -
     /   \     /   \     /   \     /   \
   ■       ■ ■       ■ ■       ■ ■       ■
   ■       ■ ■       ■ ■       ■ ■       ■
   ■       ■ ■       ■ ■       ■ ■       ■
   ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■    Left and right
   ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ M ■ ■ ■ ■ ■ ■ ■ ■ ■    edges wrap around.
   ■       ■ ■       ■ ■       ■ ■       ■
   ■       ■ ■       ■ ■       ■ ■       ■
   ■       ■ ■       ■ ■       ■ ■       ■
     \   /     \   /     \   /     \   /
   -   ■    -    ■    -    ■    -    ■   -
   <- anticlockwise           clockwise ->
               Bottom 2x2 face

So according to this diagram, UUUUURRRR might look like this:
   -   ■    -    ■    -    □    -    ■   -
     /   \     /   \     /   \     /   \
   ■       ■ ■       ■ □       □ ■       ■
   ■       ■ ■       ■ □       □ ■       ■
   ■       ■ ■       ■ □       □ ■       ■
   ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ □ ■ ■ ■ M ■ ■ ■ ■ ■
   ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ □ ■ ■ ■ ■ ■ ■ ■ ■ ■
   ■       ■ ■       ■ ■       ■ ■       ■
   ■       ■ ■       ■ ■       ■ ■       ■
   ■       ■ ■       ■ ■       ■ ■       ■
     \   /     \   /     \   /     \   /
   -   ■    -    ■    -    ■    -    ■   -

And UUUUUUUUULURRRRRR might look like this:
   -   ■    -    ■    -    □    -    □   -
     /   \     /   \     /   \     /   \
   ■       ■ ■       ■ □       ■ ■       □
   ■       ■ ■       ■ □       ■ ■       □
-> □       ■ ■       ■ □       ■ ■       □ ->
<- □ ■ ■ ■ ■ ■ ■ ■ ■ ■ □ ■ ■ ■ M □ □ □ □ □ <-
   ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ □ ■ ■ ■ ■ ■ ■ ■ ■ ■
   ■       ■ ■       ■ ■       ■ ■       ■
   ■       ■ ■       ■ ■       ■ ■       ■
   ■       ■ ■       ■ ■       ■ ■       ■
     \   /     \   /     \   /     \   /
   -   ■    -    ■    -    ■    -    ■   -

May the shortest program in bytes w-aaaaaaaaaahh!
Test Cases
Output 1: Still Alive
DDDDDLUUUUU - Mario walks across a bridge and back.
RRRRDDDDLLL - Mario walks in a triangle.
LLLLLLUUUUUURRRRR - Mario walks in a bigger triangle.
ULLDRDDDRU - Mario puts himself in peril.
RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRRR - Mario takes an unconventional route... and puts himself in peril.
Mario crosses every tile exactly once.
DDDDLUUUULLLLDDDLUUULLLLDDDDLUUUULLLLDDDLUUULLLURRRUUURDDDRRRRUUURDDDRRRRUUURDDDRRRRUUUUURDDDDD
DLDRDLDLLLDRRRDDDDLLLLLLLLLDRRRRRRRRRDDDDLLLDRRRDDDRUUURRRRULLLLUUUURRRULLLUUUUURDRURDRUURULURU
Output 2: W-aaaaaaaaaahh!
LLR - Mario attempts to retrace a step and falls off.
UULDR - Mario attempts to cross a tile twice and steps into air.
RRDDDDD - Mario walks off a bridge at the first D (ignore any following steps).
RRRRDDDDLLLL - Mario walks in a triangle and falls through the starting tile.
LLLLLLUUUUUURRRRRR - Mario walks in a bigger triangle and falls through the starting tile.
UUUUUUUUUUUUUUUUUUUU - Mario walks all the way around the planet and falls through the starting tile.
RURDRURDRDLDRDLDLDLULDLLUU - Mario takes an unconventional route and becomes disoriented.
Mario, realizing the peril he is in, is left with no choice.
ULLDRDDDRUUU ULLDRDDDRUUL ULLDRDDDRUUR ULLDRDDDRUUD RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRRRR RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRRRU RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRRRL RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRRRD
Finally, copy any test case from "Mario crosses every tile exactly once" and change or add one step at random. Mario should fall. (If you add a step to the end, Mario falls to grab the Power Star!)
*Cantellated cube would be a more correct term as some faces aren't square, but you've got to admit - "rhombicuboctahedron" flows nicer.

Bonus points for solving this in Cubix or Cubically

This brings back so many memories of playing Mario Galaxy - easily one of my favorite games of all time.

@StepHen Or MarioLANG :P

@Stephen even though it's an octogon, hexagony sti... Y'know what, never mind, who'd do this in hexAgony.

In the 4th from last test case, Mario doesn't die unless you add an extra R.  I have worked this out on paper to be sure my code is correct.

@LevelRiverSt Good catch, corrected!

From the third test case: I am "LLLLLLUUUUUURRRRRR“, ruler of the planet Omicron Persei 8!

APL (Dyalog), 457 441 bytes (Classic Dyalog Character Set)
r←'RULD'
S←{(r⍳⍵)⌷4 4⍴2 3 4 1 4 3 1 2 4,(⍳3),3 4 2 1}
C←{(⊂⍺)⌷⍵}
P←,⍉0 1 2 3∘.{2 4 1 3(C⍨⍣⍺)⍵}(⊂⍳4),C\S¨'LUULU'
v←6 6⍴(3⍴0),2(⊥⍣¯1)4512674568
a←1 4 4
N←{s y x←⍵+0,(r⍳⍺)⌷4 2⍴0 1 ¯1 0 0 ¯1 1 0
t Y X←⊃(1+(7<y+x)(0<y-x))⌷2 2⍴('U'5 0)('L'0 5)('R'0 ¯5)('D'¯5 0)
⊃(1+(1+y x)⌷(¯2⊖¯2⌽8 8↑4 4⍴1)∨¯1⊖¯1⌽8 8↑v)⌷((P⍳⊂(⊃s⌷P)C(S t)),(Y X+y x))(s y x)}
M←{T←24 6 6⍴0
~∨/,0>(6 6 6⍴v)-+/[2]6 4 6 6⍴↑(24⍴⍳4){{⊖⍉⍵}⍣⍺⊢⍵}¨⊂[2 3]T⊣{T[⊂⍵]+←1}¨(⊂a),{⊃N/(⌽⍵),⊂a}¨,\⍵}

Thanks, Bubbler, for helping me shave off several bytes!
Try it online!
To see how this works, let's learn some group theory! First, observe that the entire cuboid structure can be realized as the following shape, tessellated onto the six faces of a cube.
      .
    . .
. . . . .
  . . . . .
    . .
    .

Now, in our case, I won't be using just six faces. Because Mario's position doesn't just depend on which face he's on; it also depends on his current orientation (i.e. the direction he's facing). So I'll be using 24 states to represent his current state (24 = 6 faces × 4 orientations). Since this is APL, we'll do the calculation in a massive array. Specifically, we'll use a 24×6×6 array to store every position Mario steps on, and how many times he's been there. So Mario's position at a given moment with be a 3-vector s y x, where s is the cuboid state (face times orientation) and y, x are the coordinates within that face.
Now, if Mario is in the middle of a face, then when he moves we simply update the position vector accordingly. So a movement U (up) would add 0 ¯1 0 to his position. A movement R (right) would add 0 0 1, etc., etc.
The tricky case comes into play when Mario is at an edge. So if we're here
      M
    . .
. . . . .
  . . . . .
    . .
    .

and we move up, what do we do? We end up moving four down (effectively wrapping around) and to some other cuboid state. So if we started as s y x, our new position will be t (y + 4) x. But what is t? To figure that out, we need to look at rotations of a cube.
As I already mentioned, there are 24 rotations of a cube. Let's try to represent the vertices of a cube numerically.
  5--6
 /| /|
1--2 |
| 7|-8
|/ |/
3--4

Okay, neat. But that's not all of the information we have. In particular, any rotation of a cube will take opposite vertices to opposite vertices. So, in the above diagram, 1 and 8 are at opposite sides. No matter which way I rotate this cube, 1 and 8 will still be opposites. So we really only have four points we care about, as the other four can be calculates from those.
  4--3
 /| /|
1--2 |
| 2|-1
|/ |/
3--4

As it turns out, this is all of the information we need. If we look at the cube head-on so that the above cube looks like
1--2
|  |
|  |
3--4

Then every permutation of those four points is a rotation of the cube, and every rotation of the cube can be represented as a permutation of those four points. You can read more about that on Wikipedia, but the basic idea is that rotations of the cube can be represented using the symmetric group S4, which has 24 elements. We'll represent it this way, since APL has some nice built-in functions to apply permutations.
Now, how does this help us? Well, we wanted to know, given a state s and a side of the screen we went off (say, to the right, for this example), what is our new state t? If we can enumerate the 24 elements of S4 in a nice order, then s is simply some element of that enumeration. Then we figure out what the permutation for "go off the screen to the right" is, and compose the two to get t. So, if our cube is
  5--6
 /| /|
1--2 |
| 7|-8
|/ |/
3--4

Then, if we go off the screen to the right, we rotate the cube so the face Mario is now on is facing frontward. We get
  1--5
 /| /|
2--6 |
| 3|-7
|/ |/
4--8

Remember that we're identifying opposite vertices, so
  1--4
 /| /|
2--3 |
| 3|-2
|/ |/
4--1

Looking from the front, we turned a 1 2 3 4 cube into a 2 3 4 1 cube. So our permutation group element is 2 3 4 1. This works whenever we move right. If we take our current cuboid state (which is an element of S4), and compose it with 2 3 4 1, we get the new state. A pencil and a bit of effort, and we can calculate the element of S4 representing right, up, left, and down movements.
Right 2 3 4 1
Up    4 3 1 2
Left  4 1 2 3
Down  3 4 2 1
*     2 4 1 3

That last one (with the *) is a rotation of the current face that doesn't change which face Mario is on. So it corresponds to Mario just facing a different direction without walking. In the problem statement, it's not possible for Mario to do that, but we'll need that permutation later for our calculations.
Alright, that should be all the background we need. Let's dig into the code.
r←'RULD'

Nothing to see here. We use the string 'RULD' a few times, so it saves us a couple characters to store it.
S←{(r⍳⍵)⌷4 4⍴2 3 4 1 4 3 1 2 4,(⍳3),3 4 2 1}

S is the function which takes R, U, L, or D and converts it to the corresponding permutation we found above.
C←{(⊂⍺)⌷⍵}

Like I mentioned earlier, APL has nice built-ins for applying permutations. C composes two elements of S4. This is how we model multiple steps, like "go right, then go right again".
P←,⍉0 1 2 3∘.{2 4 1 3(C⍨⍣⍺)⍵}(⊂⍳4),C\S¨'LUULU'

P consists of all permutations of 1 2 3 4, i.e. all elements of the group S4. Let's break it down.
(⊂⍳4),C\S¨'LUULU'

From the starting orientation, LUULU will visit each face of the cube exactly once. So the above expression consists of one permutation representing each face of the cube, ignoring rotations for the moment. We manually tack on the identity 1 2 3 4, which is our starting state.
{2 4 1 3(C⍨⍣⍺)⍵}

I mentioned earlier that 2 4 1 3 corresponds to Mario turning his head 90 degrees. We have each face, so we'll want to rotate the faces to get every possible state. This function rotates a face once.
0 1 2 3∘.{2 4 1 3(C⍨⍣⍺)⍵}(⊂⍳4),C\S¨'LUULU'

Now we rotate every face zero times, once, twice, and thrice, to get every possible permutation.
,⍉0 1 2 3∘.{2 4 1 3(C⍨⍣⍺)⍵}(⊂⍳4),C\S¨'LUULU'

⍉ will transpose the result, which gives us the permutations in a nice order (namely, every cube is represented contiguously, by its four rotations in a sequence in the array). Then we ravel , the array to get one nice, flat vector of vectors.
v←6 6⍴(3⍴0),2(⊥⍣¯1)4512674568

v is a representation of the below valid positions grid, encoded in base 10 for compactness.
0 0 0 1 0 0
0 0 1 1 0 0
1 1 1 1 1 0
0 1 1 1 1 1
0 0 1 1 0 0
0 0 1 0 0 0

a←1 4 4

Mario's starting state. Again, we use this twice, so it's just barely shorter to assign it to a variable.
N←{...}

N is a big one. Given a direction ⍺ (one of the letter RULD) and a position ⍵, this moves Mario in that direction. Remember, our position is a 3-vector s y x, so we'll be moving in 3-dimensional space, where the third dimension is our state space.
s y x←⍵+0,(r⍳⍺)⌷4 2⍴0 1 ¯1 0 0 ¯1 1 0

In the easy case, we simply shift y and x and leave s alone. This is fine as long as we don't run off the edge. If we don't, then s y x, as declared above, is the correct answer. If we do, then we need to do some more work.
2 2⍴('U'5 0)('L'0 5)('R'0 ¯5)('D'¯5 0)

On the other hand, if we do run off the edge, this tells us what we have to do. In the first case, we shift the cube up and move Mario down 5. In the second case, we shift the cube left and shift Mario to the right 5, and so on.
t Y X←⊃(1+(7<y+x)(0<y-x))⌷...

To figure out which case we're in, we draw two diagonal lines along the grid as follows
\     .   /
  \ . . /
. . \ / .
  . / \ . .
  / . . \
/   .     \

This partitions our grid space into four sections. The lines are determined by 7<y+x and 0<y-x. Then we look up our cases in the previous 2×2 array. Note that if we're in the easy case, then this calculation is pointless but ultimately harmless. We'll determine which case we're in next.
(¯2⊖¯2⌽8 8↑4 4⍴1)∨¯1⊖¯1⌽8 8↑v

This expression uses v above and produces the array below
0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0
0 0 1 1 1 1 0 0
0 1 1 1 1 1 0 0
0 0 1 1 1 1 1 0
0 0 1 1 1 1 0 0
0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0

Then, if Mario ends up on a 0, we need to change cuboid state. If not, then we're good. Note that I include a few "out of bounds" points here where there aren't platforms. This prevents Mario from warping to out of the array bounds if he walks off the edge.
(1+y x)⌷(...)

Look at Mario's position and see if it's a zero in the above array.
⊃(1+(1+y x)⌷(¯2⊖¯2⌽8 8↑4 4⍴1)∨¯1⊖¯1⌽8 8↑v)⌷(...)(s y x)

We use the above 0 or 1 to index into our two cases. If it's a 1, simply return s y x. If not, then we have more work to do.
(P⍳⊂(⊃s⌷P)C(S t)),(Y X+y x)

The Y and X coordinates are simply y x added to our shift amount we calculated earlier. As for the new cuboid state, we have our direction t. Then S t is the permutation, which we compose with our permutation for our current state ⊃s⌷P, then we convert the permutation back to an index in state space P⍳⊂.
M←{...}

Now, M is the final piece. It's the function that, given a sequence of inputs, actually determines whether or not Mario falls. It will return 1 on success and 0 if he falls off.
T←24 6 6⍴0

Our initial state is a 24×6×6 state space, consisting of all zeroes, since Mario hasn't been anywhere yet.
(⊂a),{⊃N/(⌽⍵),⊂a}¨,\⍵

Now we take all of the prefixes of our input (,\⍵) and we move Mario along those paths ({⊃N/(⌽⍵),⊂a}¨). Then we tack on the initial state ((⊂a),), since Mario clearly starts off by visiting the initial position. Now we have a vector of all of Mario's positions at every moment.
{T[⊂⍵]+←1}¨...

For each position Mario ever visits, go to that place in the array T and add one to it.
(24⍴⍳4){{⊖⍉⍵}⍣⍺⊢⍵}¨⊂[2 3]T

We have 24 faces on our "cube". In reality, our cube only has 6 faces. So it's time to account for which faces are rotations of which others. Remember, we enumerated our permutations earlier so that the first four states are rotations of one another, then the next four are rotations of one another, and so on. So we'll take T (a 24×6×6 array) and, along the first axis (state space), we rotate. We'll rotate the first 6×6 once, the second twice, the third three times, then four times, then once, then twice, and so on. The actual rotation is done by {⊖⍉⍵}, which is a transpose followed by a flip. This corresponds to a 90 degree rotation. Now everything is oriented correctly.
+/[2]6 4 6 6⍴↑...

Now that everything has the right orientation, we want to add together the faces that are actually the same. So reshape the array to a 6×4×6×6 (where the dimensions are, respectively: face, orientation, y, x). Then we sum along the second axis, which represents orientation, giving us a 6×6×6 array of all of the actual positions on the grid.
(6 6 6⍴v)-...

v tells us which positions Mario is allowed to visit. So we subtract the ones we actually visited from this. If we ever end up with a negative number, that means Mario either went somewhere he shouldn't have or he revisited the same space twice.
R←~∨/,0>...

See if any positions are less than zero. Then invert the result (since success means they're all greater than zero, and failure means there is one which is less).
And that's all there is to it. If you actually read this dissertation of mine, then congratulations! This is my first APL golf, so I'm sure there's room for improvement. But I enjoyed the opportunity to use a bit of math in my answer as well.

Do you have a reason using tradfn (∇-function) over dfn ({}-function) for the functions N and M?

Not particularly. I started with tradfn's for everything, then converted everything that could be one-lined to dfn. Those two use, respectively, pattern matching and mutable state, which can't be put into one statement. So I just didn't bother converting them.

They can be converted to dfns like this. After all, what you call "pattern matching" is just multi-assignment, and side effects can be used by chaining the statements with ⊣. Also, you can use the "footer" section to demonstrate the test cases to better show the score (or use "input" section, which works like the session for Dyalog APL).

Thanks a lot! I'll update the answer. I only learned APL a few months ago, and I'm a Haskeller by trade, hence my terminology and jumping to calling it "pattern matching". Any advice is a huge help.

If you haven't already, check out the chat room dedicated to APL, where we discuss golfing and general programming in APL and related languages. We have regular lessons on APL too.

Wow, that was an awesome explanation. The tessellation shape you found is beautiful!

Most impressive code and explanation. While I didn't take the time to fully understand it, I did make some simple golfs: -69 (refer to SBCS instead of Classic)

What a first APL golf.

Ruby, golfed, 244 230 bytes
Seems to work fine, will test a bit more.
->s{a=[8**8/5]*8
v=[-1,x=d=0,1,0]
y=m=4
s.chars{|c|a[y]&=~(1<<x)
y+=v[e="URDL".index(c)+d&3]
x+=v[e-1]
r= ~0**q=x/4
i=q+x&1
j=q+y&1
y%9>7&&(y=4-i;x+=4-j*11-x%2;d+=r)
x&2>0&&-y/2==-2&&(y=i*7;x+=6-x%2*9+j;d-=r)
m*=1&a[y]>>x%=24}
m}

Ruby, first working version, 260 bytes
Try it online
Lambda function taking a string argument. Returns 4 for alive, 0 for dead.
->s{a=[0x333333]*8
v=[0,-1,0,1]
x=d=0
y=m=4
s.chars{|c|a[y]&=~(1<<x)
e="URDL".index(c)+d
x+=v[e%4]
y+=v[-~e%4]
p=x&-2
q=x/4%2
y%9>7&&(d-=q*2-1;y,x=4-(q+x)%2,(p+4-(q+y)%2*11)%24)
x&2>0&&-y/2==-2&&(y,x=(q+x)%2*7,(p+6-x%2*8+(q+y)%2)%24;d+=q*2-1)
m*=a[y]>>x&1}
m}

Explanation
The board is unfolded into 6 strips of size 2x8, represented by the /\ and O characters below. These are mapped onto a 24*8 2D map, where x=(strip number)*4+(horizontal position on strip) and y=vertical position on strip.
       Map        4         2         0          Initial state of array a
                 /         /         /
                / /       / /       / /          1100110011001100110011
               / /       / /       / /           1100110011001100110011
              O /       O /       O /            1100110011001100110011
             O O       O O       O O             1100110011001100110011
      \     / O \     / O \     / X              110011001100110011001X
     \ \   / / \ \   / / \ \   / /               1100110011001100110011
      \ \ / /   \ \ / /   \ \ / /                1100110011001100110011
       \ O /     \ O /     \ O /                 1100110011001100110011
        O O       O O       O O
         O \       O \       O \                 X=Mario's start point
          \ \       \ \       \ \
           \ \       \ \       \ \
            \         \         \
             5         3         1

These are stored in an array of 8 binary numbers, so x increases going left and y increases going down.
The array is intialized with 8 copies of the number 0x33333333. This forms the squares Mario is allowed to step on. As Mario moves around the square he is on is set to zero, and the square he is moving to is tested - he lives it contains a 1, and dies if it contains a 0.
If Mario walks off the top or bottom of the strip he is on, he moves to another strip. If he walks off the side of the strip he is on, if he is on a square with y=3 or y=4 he moves to another strip. If y is not 3 or 4, he does not move to another strip and ends up on a square which had 0 in it from the outset of the game, so he dies.
Because the camera is always above Mario's head, whenever Mario changes strip, the reference for the directions must be rotated by 90 degrees.
Ungolfed in test program
f=->s{                             #Move sequence is taken as string argument s.
  a=[0x333333]*8                   #Setup board as an array of 8 copies of 1100110011001100110011.
  v=[0,-1,0,1]                     #Displacements for moving.
  x=d=0                            #Mario starts at 0,4.
  y=m=4                            #d=offset for directions. m=4 when Mario is alive (value chosen for golfing reasons) 0 when dead.

  s.chars{|c|                      #For each character c in s
    a[y]&=~(1<<x)                  #Set the square where Mario is to 0.

    e="URDL".index(c)+d            #Decode the letter and add the offset
    x+=v[e%4]                      #x movement direction is v[e%4]
    y+=v[-~e%4]                    #y movement direction is v[(e+1)%4]
    p=x&-2                         #p is a copy of x with the last bit set to zero (righthand edge of strip).
    q=x/4%2                        #q is 0 for an even number strip, 1 for an odd number strip.
    y%9>7&&(                       #If y out of bounds (8 or -1)
      d-=q*2-1;                    #Adjust d so directions will be interpreted correctly on the next move.
      y,x=
        4-(q+x)%2,                 #y becomes 3 or 4 depending on the values of q and x.
        (p+4-(q+y)%2*11)%24        #If q+y is even, move 1 strip left. if even, move 2 strips right. Take x%24.
    )
    x&2>0&&-y/2==-2&&(             #If x&2>0 Mario has walked sideways off a strip. If y is 3 or 4, move him to a different strip.
      y,x=
        (q+x)%2*7,                 #y becomes 0 or 7, depending on the values of q and x.
        (p+6-x%2*8+(q+y)%2)%24;    #If x%2 is even, move 2 strips left. If odd, move 1 strip right*. Pick the left or right column of the strip depending on (q+y)%2. Take x%24
        d+=q*2-1                   #Adjust d so directions will be interpreted correctly on the next move.
    )

    m*=a[y]>>x&1                   #Multiply m by the value (0 or 1) of the current square. Mario is either alive (4) or dead (0).
    #puts x,y,m,a.map{|i|"%022b"%i}#Uncomment this line for diagnostics.
  }
m}                                 #Return value of m.

#Still alive, return value 4
puts f["DDDDDLUUUUU"] # Mario walks across a bridge and back.
puts f["RRRRDDDDLLL"] # Mario walks in a triangle.
puts f["LLLLLLUUUUUURRRRR"] # Mario walks in a bigger triangle.
puts f["ULLDRDDDRU"] # Mario puts himself in peril.
puts f["RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRR"] # Mario takes an unconventional route... and puts himself in peril.
puts f["DDDDLUUUULLLLDDDLUUULLLLDDDDLUUUULLLLDDDLUUULLLURRRUUURDDDRRRRUUURDDDRRRRUUURDDDRRRRUUUUURDDDDD"]
puts f["DLDRDLDLLLDRRRDDDDLLLLLLLLLDRRRRRRRRRDDDDLLLDRRRDDDRUUURRRRULLLLUUUURRRULLLUUUUURDRURDRUURULURU"]

#Dead, return value 0

puts f["LLR"] #  Mario attempts to retrace a step and falls off.
puts f["UULDR"] #  Mario attempts to cross a tile twice and steps into air.
puts f["RRDDDDD"] #  Mario walks off a bridge at the first D (ignore any following steps).
puts f["RRRRDDDDLLLL"] #  Mario walks in a triangle and falls through the starting tile.
puts f["LLLLLLUUUUUURRRRRR"] #  Mario walks in a bigger triangle and falls through the starting tile.
puts f["UUUUUUUUUUUUUUUUUUUU"] #  Mario walks all the way around the planet and falls through the starting tile.
puts f["RURDRURDRDLDRDLDLDLULDLLUU"] #

puts f["ULLDRDDDRUUU"]
puts f["ULLDRDDDRUUL"]
puts f["ULLDRDDDRUUR"]
puts f["ULLDRDDDRUUD"]
puts f["RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRRRR"] #text case in q is wrong. one more R added to make the kill.
puts f["RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRRU"]
puts f["RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRRL"]
puts f["RURDRURDRDLDRDLDLDLULDLLLLLLLLLLLLLLLLURRRRRRRRRRRRRD"]

Nicely done! I really like the "strip" mapping and the way you accounted for the camera angle.

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


text:
Additional facts!
In mathematics, the factorial, shortened "fact" of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5! is 1 * 2 * 3 * 4 * 5 = 120
The factorial of 0 is 1, according to the convention for an empty product.

These are the regular facts we are used to. Let's add some alternatives:

The factorial (defined above)
The double factorial: n!! = 1 + 2 + ... + n
The triple factorial: n!!! = 1 - (2 - (3 - ( ... - n)))...)
The quadruple factorial: n!!!! = 1 / (2 / (3 ... / n)))...). Note: This is floating point division, not integer division.

Challenge
Take a non-negative integer input n, directly followed by between 1 and 4 exclamation marks. The input will look (exactly) like this: 0!, 5!!, 132!!! or 4!!!!. In this challenge, you may not assume a flexible input format, sorry.
Output
The output should be the result, on any convenient format. The result of the quadruple factorial must have at least 2 digits after the decimal point, except for 0!!!! = 0.
Test cases:
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
---
0!! = 0
1!! = 1
2!! = 3
3!! = 6
4!! = 10
5!! = 15
6!! = 21
7!! = 28
8!! = 36
9!! = 45
10!! = 55
---
0!!! = 0
1!!! = 1
2!!! = -1
3!!! = 2
4!!! = -2
5!!! = 3
6!!! = -3
7!!! = 4
8!!! = -4
9!!! = 5
10!!! = -5
---
0!!!! = 0
1!!!! = 1
2!!!! = 0.5
3!!!! = 1.5
4!!!! = 0.375
5!!!! = 1.875
6!!!! = 0.3125
7!!!! = 2.1875
8!!!! = 0.27344
9!!!! = 2.4609
10!!!! = 0.24609

The shortest solution in each language wins.

Can the quadruple factorial also be rational division?

@MartinEnder I guess.

"The double factorial" definition's a fit off...

By "Take a non-negative input" do you mean "Take a non-negative integer input"?

@Erik, it's an alternative double fact ;-)

@StewieGriffin BTW it's a little bit sneaky that 0! -> 1.

@EriktheOutgolfer It's surprising to some folks sometimes, but it's standard, to keep the formula n!*(n+1)=(n+1)! true even for n=0.  Also, in other places in math, the product of an empty set is usually considered to be 1.

@aschepler Well, as I read this challenge, I first supposed that for 0! it wanted me to reduce the empty list by * which is different from the empty product in some languages.

Title should be Alternative Facts

@DigitalTrauma that was actually the original title, but I edited because it was kind of political, and there's always someone who dislikes such references.

Shouldn't the double factorial be defined as n!! = n * (n - 2) * (n - 4) * ...?

the double factorial n!! defined above is just the triangular numbers. T(n)=n(n+1)/2.

JavaScript (ES6), 88 bytes
s=>eval(([a,b]=s.split(/\b/),g=k=>+a?k-a?k+'_*+-/'[b.length]+`(${g(k+1)})`:k:+!b[1])(1))

Test cases

let f =

s=>eval(([a,b]=s.split(/\b/),g=k=>+a?k-a?k+'_*+-/'[b.length]+`(${g(k+1)})`:k:+!b[1])(1))

for(o = '!'; o <= '!!!!'; o += '!') {
  for(n = 0; n <= 10; n++) {
    console.log(n + o + ' = ' + f(n + o));
  }
}

Formatted and commented
s =>                                // given the input string s,
  eval(                             // evaluate as JS code:
    ( [a, b] = s.split(/\b/),       //   a = integer (as string) / b = '!' string
      g = k =>                      //   g = recursive function taking k as input
        +a ?                        //     if a is not zero:
          k - a ?                   //       if k is not equal to a:
            k + '_*+-/'[b.length] + //         append k and the operation symbol
            `(${g(k + 1)})`         //         append the result of a recursive call
          :                         //       else:
            k                       //         just append k and stop recursion
        :                           //     else:
          +!b[1]                    //       return 1 for multiplication / 0 otherwise
    )(1)                            //   initial call to g() with k = 1
  )                                 // end of eval()

Husk, 15 bytes
§!ëΠΣF-F/#'!oṫi

Try it online!
Explanation
Indexing into a list of functions: the joys of using a functional language.
§!ëΠΣF-F/#'!oṫi  Implicit input, say x = "6!!!"
              i  Convert to integer (parses the leading sequence of digits): 6
            oṫ   Descending range to 1: y = [6,5,4,3,2,1]
  ë              Four-element list containing the functions
   Π             product,
    Σ            sum,
     F-          left fold with subtraction (gives 0 for empty list), and
       F/        left fold with division (gives 0 for empty list).
 !               1-based index into this list with
         #'!     count of !-characters in input: gives F-
§                Apply to y and print implicitly: -3

I use a descending range and left folds, since - and / take their arguments in reverse order in Husk.

Indexing into a list of functions is woah...

I was thinking of Haskell, and then I see this... Truly seems to be the right tool for the job. +1

This is what Husk was made for :D

C# (.NET Core), 134 130 128 bytes
s=>{double e=s.Split('!').Length,n=int.Parse(s.Trim('!')),i=n,r=n;for(;--i>0;)r=e>4?i/r:e>3?i-r:e>2?i+r:i*r;return n<1&e<3?1:r;}

Try it online!
The best part of code golfing are the things you learn while trying to solve the challenges. In this one I have learnt that in C# you can trim other characters besides whitespaces from strings.

4 bytes saved thanks to LiefdeWen!
2 bytes saved because I do not need to substract 1 to s.Split('!').Length, just fix the limits in e>4?i/r:e>3?i-r:e>2?i+r:i*r and n<1&e<3?1:r.

You can make e n and i also double to avoid declaring it for r to save 4 bytes.

@LiefdeWen Or float to save another byte.

Perl 5, 62 bytes
61 bytes code + 1 for -p.
$_=/^0!$/+eval join(qw{| *( +( -( /(}[s/!//g],1..$_).")"x--$_

Thanks to @G B for pointing out a miss on my part!
Try it online! (this uses -l for readability)

0! should be 1 not 0

@GB Well that doesn't make any sense... Fixed for +5!

Python3, 124 130 121 119 bytes
At this point, I believe that recursion is the key to further byte saving.
s=input()
l=s.count('!')
v=int(s[:-l])+1
print(eval((" *+-/"[l]+"(").join(map(str,range(1,v)))+")"*(v-2)or"0")+(l<2>v))

Try the testcases on Try it online!
-9 bytes thanks to @Mr.Xcoder!
-2 bytes thanks to @Felipe Nardi Batista!

Fails for 6!. It should be 720.

I updated the Tio test suite.

-3 bytes.

Oh yeah, sure, didn't spot that

121 bytes

Behold ES6

-2 bytes

R, 113 111 bytes
function(s){z=strtoi((n=strsplit(s,'!')[[1]])[1])
n=length(n)
`if`(z,Reduce(c('*','+','-','/')[n],1:z,,T),n<2)}

Try some test cases!
ungolfed:
function(s){
  n <- strsplit(s,"!")[[1]]          # split on "!"
  z <- strtoi(n[1])                  # turn to integer
  n <- length(n)                     # count number of "!"
  FUN <- c(`*`,`+`,`-`,`/`)[[n]]     # select a function
  right <- TRUE                      # Reduce (fold) from the right
  if( z > 0)                         # if z > 0
    Reduce(FUN, 1:z,,right)          # return the value
  else
    (n < 2)                          # 1 if n = 1, 0 if n > 1
}

el(strsplit(s,"!"))  saves 1 byte

Pyth, 34 30 bytes
+uv++H@"/*+-"/Q\!G_tUK.vQKq"0!

Try it online!
Explanation
+uv++H@"/*+-"/Q\!G_tUK.vQKq"0!"Q    Implicit: append "Q
                                    Implicit: read input to Q
                      .vQ           Evaluate Q as Pyth code. This evaluates the integer,
                                    any !'s are parsed as unary NOT for the next expression
                                    and discarded.
                     K              Save the result to K.
                    U               Get a list [0, 1, ..., K-1].
                   t                Drop the first item to get [1, 2, ..., K-1].
                  _                 Reverse to get [K-1, K-2, ..., 1].
 u                       K          Starting from G = K, for H in [K-1, K-2, ..., 1] do:
             /Q\!                     Count the !'s in Q.
      @"/*+-"                         Get the correct operator.
    +H                                Prepend the current H.
   +             G                    Append the previous value G.
  v                                   Evaluate as Python code.
                          q"0!"Q    See if Q == "0!".
+                                   If so, add 1.

Using .U saves a byte.

Self-modifying x86_64 machine code, 123 bytes
0f b6 0f 31 c0 eb 11 0f be c9 8d 04 80 8d 44 41 d0 0f b6 4f 01 48 ff c7 83 f9 21 75 ea b9 21 21 21 a1 33 0f 0f bc c9 81 c1 ff 07 00 00 c1 e9 03 0f b6 c9 89 ca 09 c2 74 35 55 48 89 e5 c7 45 fc 59 58 5c 5e 8a 4c 0d fc 88 0d 15 00 00 00 f3 0f 2a c8 83 f8 02 5d 7c 1f ff c8 0f 57 c0 f3 0f 2a c0 f3 0f 5e c1 83 f8 01 0f 28 c8 7f eb c3 f3 0f 10 05 03 01 00 00 c3 0f 28 c1 c3

Why would interpreted languages be able to dynamically run code with fancy evals, but not plain machine code?
Try it with:

#include <stdio.h>
#include <sys/mman.h>
#include <errno.h>

char ff[] = "\x0f\xb6\x0f\x31\xc0\xeb\x11\x0f\xbe\xc9\x8d\x04\x80\x8d\x44\x41\xd0\x0f\xb6\x4f\x01\x48\xff\xc7\x83\xf9\x21\x75\xea\xb9\x21\x21\x21\xa1\x33\x0f\x0f\xbc\xc9\x81\xc1\xff\x07\x00\x00\xc1\xe9\x03\x0f\xb6\xc9\x89\xca\x09\xc2\x74\x35\x55\x48\x89\xe5\xc7\x45\xfc\x59\x58\x5c\x5e\x8a\x4c\x0d\xfc\x88\x0d\x15\x00\x00\x00\xf3\x0f\x2a\xc8\x83\xf8\x02\x5d\x7c\x1f\xff\xc8\x0f\x57\xc0\xf3\x0f\x2a\xc0\xf3\x0f\x5e\xc1\x83\xf8\x01\x0f\x28\xc8\x7f\xeb\xc3\xf3\x0f\x10\x05\x03\x01\x00\x00\xc3\x0f\x28\xc1\xc3";
int main()
{
    char* page = (char*)((unsigned long)((char*)ff) & (~0xfffLL));
    if (mprotect(page, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) {
        perror("mprotect");
        return -1;
    }
    float (*f)(char*) = (float (*)(char*))ff;
    char* testcases[] = { "0!","1!","2!","3!","4!","5!","6!","7!","8!","9!","10!",
                          "0!!","1!!","2!!","3!!","4!!","5!!","6!!","7!!","8!!","9!!","10!!",
                          "0!!!","1!!!","2!!!","3!!!","4!!!","5!!!","6!!!","7!!!","8!!!","9!!!","10!!!",
                          "0!!!!","1!!!!","2!!!!","3!!!!","4!!!!","5!!!!","6!!!!","7!!!!","8!!!!","9!!!!","10!!!!",
                        };
    for (int i = 0; i < 44; i++) {
        printf("%s -> %f\n", testcases[i], f(testcases[i]));
    }
}

Assembly:

_f:
100000d4f:  0f b6 0f    movzx   ecx, byte ptr [rdi]
100000d52:  31 c0   xor eax, eax
100000d54:  eb 11   jmp 17 <_f+18>
100000d56:  0f be c9    movsx   ecx, cl
100000d59:  8d 04 80    lea eax, [rax + 4*rax]
100000d5c:  8d 44 41 d0     lea eax, [rcx + 2*rax - 48]
100000d60:  0f b6 4f 01     movzx   ecx, byte ptr [rdi + 1]
100000d64:  48 ff c7    inc rdi
100000d67:  83 f9 21    cmp ecx, 33
100000d6a:  75 ea   jne -22 <_f+7>
100000d6c:  b9 21 21 21 a1  mov ecx, 2703302945
100000d71:  33 0f   xor ecx, dword ptr [rdi]
100000d73:  0f bc c9    bsf ecx, ecx
100000d76:  81 c1 ff 07 00 00   add ecx, 2047
100000d7c:  c1 e9 03    shr ecx, 3
100000d7f:  0f b6 c9    movzx   ecx, cl
100000d82:  89 ca   mov edx, ecx
100000d84:  09 c2   or  edx, eax
100000d86:  74 35   je  53 <_f+6E>
100000d88:  55  push    rbp
100000d89:  48 89 e5    mov rbp, rsp
100000d8c:  c7 45 fc 59 58 5c 5e    mov dword ptr [rbp - 4], 1583110233
100000d93:  8a 4c 0d fc     mov cl, byte ptr [rbp + rcx - 4]
100000d97:  88 0d 15 00 00 00   mov byte ptr [rip + 21], cl
100000d9d:  f3 0f 2a c8     cvtsi2ss    xmm1, eax
100000da1:  83 f8 02    cmp eax, 2
100000da4:  5d  pop rbp
100000da5:  7c 1f   jl  31 <_f+77>
100000da7:  ff c8   dec eax
100000da9:  0f 57 c0    xorps   xmm0, xmm0
100000dac:  f3 0f 2a c0     cvtsi2ss    xmm0, eax
100000db0:  f3 0f 5e c1     divss   xmm0, xmm1
100000db4:  83 f8 01    cmp eax, 1
100000db7:  0f 28 c8    movaps  xmm1, xmm0
100000dba:  7f eb   jg  -21 <_f+58>
100000dbc:  c3  ret
100000dbd:  f3 0f 10 05 03 01 00 00     movss   xmm0, dword ptr [rip + 259]
100000dc5:  c3  ret
100000dc6:  0f 28 c1    movaps  xmm0, xmm1
100000dc9:  c3  ret

Explanations will be added later. The basic idea is to modify the divss xmm0, xmm1 instruction at 0x100000db0 and replace it with a mulss, addss, subss or divss according to supplied operand. A small trick is also used to parse the input string.
Assembly generated with:

float f (char* s)
{
    int x;
    for (x=0; *s != '!'; s++) {
        x=10*x + (*s-'0');
    }
    unsigned char op = (__builtin_ctz(*(unsigned int *)s ^ 0xa1212121)-1) >> 3;
    if (x == 0 && op == 0) {
        return 1;
    }
    unsigned int lookup = 0x5e5c5859;
    unsigned char new_code = ((unsigned char*)&lookup)[op];
    asm("movb %0, 0x15(%%rip)" : : "r" (new_code));
    float sum;
    for (sum = x--; x>0; x--) {
        sum = x / sum;
    }
    return sum;
}

Ruby, 83 80 79 bytes
->s{z=s.count ?!;s<?1?1+1<=>z:eval([*1..w=s.to_i]*(".0"+"_*+-/"[z]+?()+?)*~-w)}

Try it online!
Explanation:
->s{
    # Get number of !
    z=s.count ?!

    # Special case: if the number is 0, then output 0 or 1 depending on z
    s<?1?1+1<=>z:

    # Otherwise build the full expression as a string and then evaluate it
    eval([*1..w=s.to_i]*(".0"+"_*+-/"[z]+?()+?)*~-w)
}

05AB1E, 27 bytes
þL"/*+-"¹'!¢©è".»"ì.VD_нi®Θ

Try it online!

DO you know why „.» doesn't work?

@Riley » is part of an unfinished compressed string, so it errors out and, as usually in 05AB1E, the error is ignored.

I was trying to do "*+-/"èU then after using L follow up with .»X but it treats X as a string, not a command and .»X.V is even wonkier.

@MagicOctopusUrn X doesn't eval. X.V are two commands.

@EriktheOutgolfer yeah, but I was hoping it'd eval before processing the fold. Hoping, not expecting :(. Could've sworn there was a "use single character String as command in dyadic chain" or something.

@MagicOctopusUrn Umm, what dyadic chain?

Possibly wrong word choice there ._.

Haskell, 105 102 98 96 bytes
0!3=0
x!y=foldr([(*),(+),(-),(/)]!!y)([1,0,0,1]!!y)[1..x]
f s|[(n,b)]<-lex s=read n!(length b-1)

Saved 9 bytes thanks to Zgarb and nimi.
Try it online.

@Zgarb You are right. Fixed.

I think you can also drop the parens around read n, and f= is unnecessary as per our rules.

@Zgarb Right again :) . Thanks!

Switching back to a named function and using lex saves two bytes: f s|[(n,b)]<-lex s=read n!(length b-1).

@nimi Wow, thanks! I'm so new to Haskell that I didn't even know about lex. That's awesome! :) I don't see how that saves bytes though - I get 99 bytes after this.

Your pointfree function is 40 bytes, my version 38 bytes. Compare them.

@nimi Right. I don't know what I was doing wrong earlier. I probably added some whitespace by mistake.

Java 8, 141 136 134 bytes
s->{float q=s.split("!",-1).length,n=new Float(s.split("!")[0]),i=n,r=n;for(;--i>0;r=q<3?i*r:q<4?i+r:q<5?i-r:i/r);return n<1&q<3?1:r;}

-5 bytes (141 → 136) thanks to @CarlosAlejo's C# answer.
Explanation:
Try it here.
s->{                                // Method with String parameter and float return-type
  float q=s.split("!",-1).length,   //  Amount of exclamation marks + 1
        n=new Float(s.split("!")[0]),
                                    //  The number before the exclamation marks
        i=n,                        //  Index (starting at `n`)
        r=n;                        //  Return sum (starting at `n`)
  for(;--i>0;                       //  Loop from `i-1` down to 1
    r=                              //   Change the result (`r`) to:
      q<3?                          //    If `q` is 2:
       i*r                          //     Multiply
      :q<4?                         //    Else if `q` is 3:
       i+r                          //     Addition
      :q<5?                         //    Else if `q` is 4:
       i-r                          //     Subtraction
      :                             //    Else (if `q` is 5):
       i/r                          //     Division
  );                                //  End of loop
  return n<1&q<3?                   //  Edge case if the input is `0!`:
          1                         //   Then return 1
         :                          //  Else:
          r;                        //   Return the result
}                                   // End of method

I have seen a similar answer somewhere else... :-D I keep forgetting that float is shorter than double.

@CarlosAlejo Yeah, I noticed your answer after my initial 141 byte answer. Changing float q=s.length()-(s=s.replace("!","")).length(),n=new Float(s) to the current answer saved me 5 bytes. :) Forgot to add a "bytes saved thanks to" part I noticed now.. Sorry about that.

oh, nevermind that, I'm glad you liked my answer. :-)

Jelly,  24 23 26  25 bytes
+ 3  2 bytes patching up to fix after misinterpretation :(
×
+
_
÷
ṣ”!µḢVRṚȯL©Ị$®ŀ@/

A full program (a monadic link with helper links referenced by program location)
Try it online! or see a test suite.
How?
× - Link 1, multiply: number, number

+ - Link 2, add: number, number

_ - Link 1, subtract: number, number

÷ - Link 1, divide: number, number

ṣ”!µḢVRṚȯL©Ị$®ŀ@/ - Main link: list of characters, a
ṣ”!               - split s at '!' characters
   µ              - monadic separation, call that b
    Ḣ             - head - pop and yield the digit list from b, modifying b
     V            - evaluate as Jelly code (get the number, say N)
      R           - range = [1,2,3,...,N]
       Ṛ          - reverse = [N,...,3,2,1]
            $     - last two links as a monad:
         L        -   length of modified b (number of '!' characters)
          ©       -   (copy to register)
           Ị      -   insignificant? (1 when just one '!', 0 when two or more)
        ȯ         - logical or (1 for "0!", 0 for "0!!...", the reversed-range otherwise)
                / - cumulative reduce by:
               @  -  with swapped arguments:
              ŀ   -    dyadic call of link at index:
             ®    -      recall value from register (number of '!' characters)

Fails for 0!.

Oh, haha - I had read your comment under the OP wrong - I thought they'd made 0! defined as 0 which would be wrong.

All fixed up now :)

Too bad TIO is broken right now so that I can't test if it's still invalid. :( :P Also too bad that you can't use / on an empty list. D: EDIT: Apparently valid for 0!, 0!!, 0!!! and 0!!!!. +1

APL (Dyalog), 30 bytes
Inspired by lstefano's solution.
{0::0⋄(⍎'×+-⌹'⊃⍨≢⍵~⎕D)/⍳⍎⍵∩⎕D}

Try it online!
{…} anonymous function where the argument is represented by ⍵:
 0:: if any error happens:
  0 return zero
 ⋄ now try:
  ⍵∩⎕D the intersection of the argument and the set of Digits (removes exclamation points)
  ⍎ execute that (turns it into a number)
  ⍳ ɩndices of that
  (…)/ insert (APL is right associative, as needed) the following function between terms:
   ⍵~⎕D argument without Digits (leaves exclamation points)
  ≢ tally that (i.e. how many exclamation points)
  '×+-⌹'⊃⍨ use that to pick from the list of symbols*
  ⍎ execute (turns the symbol into a function)

⌹ (matrix division) is used instead of ÷ (normal division) to cause an error on an empty list

What does :: do in a dfn?

It is an error guard. If at any point after the error guard is set up, an error with any of the numbers (0=1…999, 1000=1001…) to the left of the :: happens, then the value to the right of the :: is immediately returned.

Well, I never knew about that, thanks!

Jelly, 28 bytes
×
+
_
÷
³ċ”!
ḟ”!VRṚ¢ŀ@/¢Ị¤¹?

Try it online!
Got the idea of separating the links into lines from Jonathan Allan's answer for -2 bytes.

Gaia, 26 25 bytes
ẋ)@d┅v;l“×+⁻÷”=“ₔ⊢”+e¤ḥ!∨

Try it online!
Explanation
ẋ                          Split the input into runs of the same character.
 )                         Get the last one (the !'s).
  @                        Push an input (since there's none left, use the last one).
   d                       Parse as number (ignores the !'s).
    ┅v                     Get the reverse range: [n .. 1]
      ;                    Copy the ! string
       l“×+⁻÷”=            Get its length and index into this string of operators.
               “ₔ⊢”+       Append 'ₔ⊢' to the operator.
                    e      Eval the resulting string, which is "reduce by <operator> with
                            swapped arguments." Reducing an empty list gives 0.
                     ¤     Bring the !'s back to the top.
                      ḥ!   Remove the first character and check if it's empty.
                        ∨  Logical OR; turns 0 from 0! to 1, doesn't change anything else.

05AB1E, 25 24 bytes
þDLðýs¹'!¢<"*+-/"ès<×J.V

Try it online!

Mathematica, 152 bytes
(T=ToExpression;If[#=="0!!!!",0,s=T@StringCount[#,"!"];t=T@StringDrop[#,-s];{#!,i~Sum~{i,#},Sum[-i(-1)^i,{i,#}],N@Product[1/i^(-1)^i,{i,#}]}[[s]]&[t]])&

Javascript, 111 163 bytes
s=>([a,b]=s.split(/\b/),c=b.length,a==0&c==1||eval((p=[...Array(+a+1).keys()].slice(1).join(c-1?c-2?c-3?'/(':'-(':'+':'*'))+')'.repeat((p.match(/\(/g)||[]).length)))

Readable Version
s=>([a,b]=s.split(/\b/),c=b.length,a==0&c==1||eval((p=
[...Array(+a+1).keys()].slice(1).join(c-1?c-2?c-3?'/(':'-
(':'+':'*'))+')'.repeat((p.match(/\(/g)||[]).length)))

Perl 5, 96 bytes
s/(\d+)//;@a=1..$1;$"=qw|* + -( /(|[$l=-1+length];$_=$1?"@a".($l>1?')'x($1-1):''):$l?0:1;$_=eval

Try it online!

Dyalog APL, at least 29 chars
{(⍎i⊃'×+-÷')/⍳⍎⍵↓⍨-i←+/'!'=⍵}

The expression is ALMOST correct. It passes all the test cases EXCEPT 0!!!! for which it gives 1 instead of the required 0 and that's because in APL the reduction of an empty vector is supposed to return the neutral element for the function used to reduce. For the quotient that's 1. At the moment I don't have time to try and fix it but I'll leave it here for a rainy day.

It is raining: {0::0⋄(⍎'×+-⌹'⊃⍨≢⍵~⎕D)/⍳⍎⍵∩⎕D} Try it online!

Very cool! I don't mind at all if you claim it as your solution, given that the differences are more than the similarities.

Done.

source: Stack Exchange

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

sort: votes


text:
Ascii User Interfaces
In this challenge, we render Ascii user interfaces.
+----------------------+
|+-----------++-------+|
||<- Previous||Next ->||
|+-----------++-------+|
|== The title ==       |
|                      |
|Lorem ipsum dolor     |
|sit amet...           |
|+--------------+      |
||Post a comment|      |
|+--------------+      |
|+-----------------+   |
||User X commented:|   |
||                 |   |
||This is amazing! |   |
|+-----------------+   |
|+-----------------+   |
||User Y commented:|   |
||                 |   |
||lol              |   |
|+-----------------+   |
+----------------------+

Each drawing like this is made of one element, which can contain subelements. The possible elements are listed below:

Text element. Contains one or more lines of text.
Box element. Contains one subelement that is surrounded with borders. The borders have +s at the corners and -s and | at the edges.
Horizontal list. Contains one or more elements that are aligned horizontally.
Vertical list. Contains one or more elements that are aligned over each other vertically and to left horizontally.

Every element is a rectangle.
Each element, in addition to its content, has a property called baseline. The baseline is used to align the elements vertically: every element of a horizontal list is aligned such that their baselines are on the same line. In the example below, the baseline contain characters aeg. The baselines of the three box elements are (0-indexed) 1, 3 and 2.
   +-+
   |c|+-+
+-+|d||f|
|a||e||g|
|b|+-+|h|
+-+   +-+

The baselines are determined with the following rules:

For text elements, the first line of text is the baseline, ie. 0.
For box elements, the baseline is 1 + the baseline of the subelement.
For horizontal lists, the baseline is the maximum baseline in the list (3 in the example above).
For vertical lists, the baseline is the baseline of an element, which must be specified in the input.

Input
The input is a specification of an interface in some format (eg. lists, json). The example inputs have the following format:

A string element is a string: "..."
A box element is a list thats first element is "b": ["b", subelement]
A horizontal list is a list thats first element is "h": ["h", items...]
A vertical list is a list thats first element is "v" and the second element is the (0-indexed) number of the element thats baseline is used: ["v", n, items...]

Output
The output must contain the elements aligned using the rules I specified above. The output can be stdout, a list of strings or anything else meaningful.
Scoring
This is code-golf, the usual rules apply.
Test cases
1
["b", ["v", 0, ["h", ["b", "<- Previous"], ["b", "Next ->"]], "== The title ==\n\nLorem ipsum dolor\nsit amet...", ["b", "Post a comment"], ["b", "User X commented:\n\nThis is amazing!"], ["b", "User Y commented:\n\nlol"]]]

+----------------------+
|+-----------++-------+|
||<- Previous||Next ->||
|+-----------++-------+|
|== The title ==       |
|                      |
|Lorem ipsum dolor     |
|sit amet...           |
|+--------------+      |
||Post a comment|      |
|+--------------+      |
|+-----------------+   |
||User X commented:|   |
||                 |   |
||This is amazing! |   |
|+-----------------+   |
|+-----------------+   |
||User Y commented:|   |
||                 |   |
||lol              |   |
|+-----------------+   |
+----------------------+

2
["h", ["b", ["v", 0, "a", "b"]], ["b", ["v", 2, "c", "d", "e"]], ["b", ["v", 1, "f", "g", "h"]]]

   +-+
   |c|+-+
+-+|d||f|
|a||e||g|
|b|+-+|h|
+-+   +-+

3
["h", ["b", ["v", 0, ["b", ["h", "a\nb", "c"]], "d", "e", ["h", ["h", "f"], ["b", ["h", "g"]], "h"]]], ["b", "ijk\nl\nmn\no"], ["v", 2, ["b", "pqrst"], ["b", "uv\nw"], ["b", "x"]], ["b", ["b", ["b", "yz"]]]]

            +-----+
            |pqrst|
            +-----+
            +--+
            |uv|
            |w |   +------+
+-----+     +--+   |+----+|
|+--+ |+---++-+    ||+--+||
||ac| ||ijk||x|    |||yz|||
||b | ||l  |+-+    ||+--+||
|+--+ ||mn |       |+----+|
|d    ||o  |       +------+
|e    |+---+
| +-+ |
|f|g|h|
| +-+ |
+-----+

4
["h", "a * b = ", ["v", 0, "a + a + ... + a", "\\_____________/", "    b times"]]

a * b = a + a + ... + a
        \_____________/
            b times

Sweet jesus... It's geocities all over again.

I'm not quite sure how the baseline works, could you explain it further?

@StanStrum The baseline is used to align the items in a horizontal list vertically. The baselines of the items should match, ie. they should all be the same physical row. For example, in the swcond example the first box has been moved downwards so that the letter a is at the same line as e, as they are both at the baseline of their boxes. I'm not completely sure if "baseline" is the correct word for this, I know only that it is used in the field of typography for a similar purpose.

@fergusq On the first clause: "For text elements, the first line of text is the baseline, ie. 0.", does this mean the other "baselines" are shifting the text up?

@fergusq Baseline should be the correct word, IIRC it's used in the descriptions for CSS flexbox as well

@StanStrum If there are elements A and B in a horizontal list and they have baselines 0 and 1, then the element A is moved downwards by one line (or B is moved upwards, depending how you want to think it). The baseline of the text elements is the first line of text, and the elements are moved vertically so that that line is at the same line with the baselines of the other elements in the horizontal list.

Python 3, 721 694 693 671 661 bytes
Edit: Saved 27 bytes due to @Arnold Palmer and @Step Hen
Edit: Saved 1 byte
Edit: Saved 22 bytes thanks to @Arnold Palmer
Edit: Saved 10 bytes
This could probably be golfed quite a bit
L,M,R,e=len,max,range,lambda t:([list(r)+[" "]*(M(map(L,t.split("\n")))-L(r))for r in t.split("\n")],0)if str==type(t)else b(t)if"h">t[0]else h(t)if"v">t[0]else v(t);F=lambda t:"\n".join(map("".join,e(t)[0]))
def h(t):
	t=[e(r)for r in t[1:]];Z=M(s[1]for s in t);X=M(L(s[0])-s[1]for s in t)+Z;u=[[]for i in R(X)]
	for a,b in t:u=[u[j]+[Z-b<=j<L(a)+Z-b and a[j-Z+b][i]or" "for i in R(L(a[0]))]for j in R(X)]
	return u,Z
def b(t):t,b=e(t[1]);u=[["+",*"-"*L(t[0]),"+"]];return u+[["|"]+r+["|"]for r in t]+u,1+b
def v(t):w=[e(r)for r in t[2:]];return[a[i]+[" "]*(M(L(a[0])for a,d in w)-L(a[i]))for a,c in w for i in R(L(a))],sum(L(x[0])for x in w[:t[1]])+w[t[1]][1]

Try it online

You can also move all of the definitions and P,L,M,R,K=[" "],len,max,range,map to the top of the program (variables at the top), and outside of F.  Doing that you can get it down to at least 711 bytes. (TIO link too large to post).

@StepHen Not anymore, I've fixed the problem. :-)

Down to 671.  Had to use tinyurl since the TIO link was way too long.  I reworked a lot of your maps since they could be replaced with normal list comprehension stuff.  Because I was able to trim so many maps out, I also removed the K variable since it was costing 2 bytes.

Good job. You win the bounty.

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


text:
Where's my value?
My boss now wants me to implement a mechanism that lets him search for an item in an array, and gives him the index/indices where that value occurs.
Your Task:
Write a program or function that receives an array and a value (String, Integer, Float, or Boolean), and returns the indices of the array at which the value occurs (either 0 or 1 indexed, whichever you prefer).  If the value is not in the array return an empty array.
Input:
An array A and a value V, that may or may not be present in A.
Output:
An array containing the indice(s) at which the V occurs in A, or, if V does not occur in A, an empty array.
Test Cases:
Please note that the test cases are 0 based.
12, [12,14,14,2,"Hello World!",3,12,12]         -> [0,6,7]
"Hello World", ["Hi", "Hi World!", 12,2,3,True] -> []
"a", ["A",True,False,"aa","a"]                  -> [4]
12, [12,"12",12]                                -> [0,2]

Scoring:
This is code-golf, so the lowest score in bytes wins.

Can we assume that the given array only has one of those types (i.e. no arrays with mixed types) as many languages do not support arrays or lists with more than one type.

Sure, @flawr.  You may assume that the array will only consist of values of the same type as the value to check for, if your language requires it.

Are the comparisons supposed to be done without any type coercion? (e.g. "12" != 12)

That's correct, @Arnauld.  "12"!=12.  You should only return an index if your value exactly matches the value at that index.

All your arrays are 1D. Assumption?

@Adám I think that's indeed a valid assumption, since an inner array/list isn't part of (quote) "and a value (String, Integer, Float, or Boolean)".

@KevinCruijssen I meant the array to be searched. It could be multi-D.

@Adám Ah oops, misread. But I think it's still a valid assumption.

Can I use a language that only support integers?

@DJMcMayhem, sorry, but no.  You must support at least strings, integers, floats and booleans.

@Adám, valid assumption.  All arrays you must handle will be 1D (kudos to you if you support more though).

Must integers+floats+booleans all be separate? (integers + floats are the same in JS, integers + booleans are the same in a lot of languages)

No, you simply need to support some sort of numerical value that allows for decimal values, strings, and booleans of some sort.

Okay, so 1 and True don't have to be two different things. But can we use a language that only supports numbers (representing strings as lists of integers)?

@Zacharý - As long as it can take ["A"],"A" in some form and return [0], it's good. If it represents strings as lists of integers, then it should check if the lists of integers that represent strings are equal.

Okay. And I'm surprised there hasn't been a language yet that can do it in 1 byte!

Is output printed on standard out allowed, or just by function return?

@Jakob, standard output is allowed.

Can the value V be null?

No, although if your code supports null for V, that's great.

Pyth, 2 bytes
0-indexed.
xE

Try it online! or Check all the Test Cases

Explanation
xEQ  - Full Program. Takes Input from standard input. Q means evaluated input and is implicit at the end of the program.

x   - Get all the indexes of x in y
 E  - Evaluated Input #2 - The value
  Q - The list - Evaluated Input #1

You're supposed to return all occurrences not just the first.

@EriktheOutgolfer Fixed. Just take them in reverse order.

Pyth is definitely the best tool for the job then :P

Python 3, 45 bytes
-3  bytes thanks to @EriktheOutgolfer and @Chris_Rands
lambda y,x:[i for i,j in enumerate(x)if j==y]

Test Suite.
Today I learned enumerate(x) == zip(range(len(x)),x).

Python 3, 47 bytes
lambda n,l:[x for x in range(len(l))if l[x]==n]

Try it online! or Check all the Test Cases

Use enumerate() to bring it down a couple of bytes

@Chris_Rands Ended up being longer.

lambda n,l:[x for x,y in enumerate(l)if y==n]

I meant what @EriktheOutgolfer said

@JonathanAllan Fixed.

Once again, Python golfed code that's essentially idiomatic non-golfed solution :)

@ŁukaszRogalski Yeah, sort of...

JavaScript, 39 bytes
e=>a=>[...a.keys()].filter(i=>a[i]===e)

f=
e=>a=>[...a.keys()].filter(i=>a[i]===e)

console.log(f(12)([12,14,14,2,"Hello World!",3,12,12]));
console.log(f("Hello World")(["Hi", "Hi World!", 12,2,3,true]));
console.log(f("a")(["A",true,false,"aa","a"]));
console.log(f(12)([12,14,14,2,"Hello World!",3,12,'12']));

The above snippet might not work on all browsers, so here's a TIO link.

MATL, 2 bytes
mf

The m consumes two arguments, and checks each element in the array whether is equal to the other argument, f returns the indices of the truthy entries of an array.
Try it online!

It doesn't seem to work for the proposed test cases, same for the Octave solution.

You should use ismember instead of = to properly handle arrays of strings. mf

@LuisMendo We don't need to consider mixed input, see clarification from OP!

@flawr Oh, why is that only in a comment, and not in the challenge text? :-/

You'd have to ask the OP, not me:)

JavaScript (ES6), 44 43 bytes
Crossed out 44 is still regular 44 ;(
v=>a=>a.map((x,i)=>x===v&&++i).filter(x=>x)

Saved 1 bytes thanks to @Arnauld

let f=
v=>a=>a.map((x,i)=>x===v&&++i).filter(x=>x)
;

console.log(f(12)([12,14,14,2,"Hello World!",3,12,12]));         // => [1,7,8]
console.log(f("Hello World")(["Hi", "Hi World!", 12,2,3,true])); // => []
console.log(f("a")(["A",true,false,"aa","a"]));                  // => [5]

Can you make the === a normal == for one byte less?  I came up with literally the same thing, variable names and all haha.

=== is necessary to distinguish 12 from "12"

@kamoroso94 no, here's why.

R (+pryr), 20 bytes
pryr::f(which(a==b))

Which evaluates to the function
function (a, b)
which(a == b)

Where either a can be the value to look for and b the vector, or the other way around. When presented with two vectors of unequal lengths (a single value counts as a length-1 vector in R), R will wrap the shorter one to match the length of the longer one. Then the equality is checked. This generates a logical vector. which provides the indices where this vector is true.
Try it online!

Jelly, 3 bytes
⁼€T

Try it online!
-1 thanks to Mr. Xcoder. (dyadic chains)

Nice one. I am surprised Jelly does not have a pure built-in, like Pyth does.

@Mr.Xcoder I think most don't.

The irony of dyadic chains :)

C#, 88 72 bytes
using System.Linq;a=>o=>a.Select((i,n)=>o.Equals(i)?n:-1).Where(n=>n>=0)

Saved 16 bytes thanks to @LiefdeWen.
Try it online!

Amazing, I was still trying to figure out why i==o doesn't work.

@LiefdeWen Boxed value types.

72 bytes using System.Linq;a=>b=>a.Select((x,i)=>x.Equals(b)?i:-1).Where(x=>x>=0)

@LiefdeWen Nice one, I wouldn't have thought of switching it around.

You can save a lot :) : https://tio.run/##rZBNSwMxEIbv@yvGnBJYA129tbsgpX6hIPbQQymSbqc6kk1sklWk9Lev2V20Fb3pQDKTzJs8b1L648oa2xhVoX9RJcL03Qes5A2ZTbJNIEaplfdw19X9Ths@qEAlvFpawa0iw8VXay9q47w25cgun7EM80V6uExhbLWOBVnj5QUadFTKq4mpK3RqqXFEJhRFAWvIG5UXNi@UnGJ7gvOHlERekJCzJ3TIKbblZFMr7bma00KIZph88zGOEKtRzhwFjM9D7oMj8yivbXTPgKWw5gbf4NPrFgZZCoPTfsSSXaLWFmbW6dVRlJ@kvSLbCT7IhBDDvwFhGxHEWhDtKS0i62DB1QiRdeiD/Q/2jPXXx178wZiYUq0RxTqg@on5lXmPatUhD8S7pJ93zQc

05AB1E, 4 bytes
QāsÏ

Try it online!
1-indexed.

I think both of ours mess up on inputs of: 12 and [12,'12'], unless he said it's chill for languages that don't really concrete type to not care about types.

I actually think that 12 ≠ '12' in 05AB1E because sometimes they behave differently...not sure if there's any equality test which can support such a thing though.

If we wanted to test them for integer validity our answers would be like 60-bytes using is_alpha (a) and is_number (d), but I guess we can assume ours are valid until told otherwise.

Ruby, 38 bytes
->e,a{a.each_index.select{|x|a[x]==e}}

Try it online!

Welcome to PPCG!

Google Sheets, 101 bytes
=IfError(Join(",",Filter(Column(Offset(A1,0,0,1,Counta(Split(B1,",")))),Exact(Split(B1,","),A1))),"")

Value V in A1 and array A in B1 with each entry separated by a comma. Null entires are not allowed (row 5 below shows what happens).

Explanation:
Offset(A1,0,0,1,Counta(Split(B1,","))) returns a range that is one row tall and as many columns wide as there are entries in A1.
=IfError(Join(",",Filter(Column(~),Exact(Split(B1,","),A1))),"") filters the column numbers of that range based on whether or not the value in A1 is exactly each of the values in B1 and concatenates them all in a comma-delineated list.

Clojure, 40 bytes
First attempt at code golf.
keep-indexed maps a function over a collection here, passing the current index into the callback and yielding any non-nil return values.
(fn[a b](keep-indexed #(if(= %2 a)%1)b))

Try it online!

Ruby, 46 40 39 bytes
->e,a{i=-1;a.map{|x|i+=1;x==e&&i}-[!1]}

Saved 7 bytes!!! thanks to Eric Duminil.
Try it online.

-1 byte with !1 for false.

Haskell, 41 39 bytes
v!l=fst<$>(filter((==v).snd)$zip[1..]l)

Try it online!
Saved two bytes thanks to @flawr
Haskell is statically typed, so I had to use a little workaround to run the test cases.

You don't need your workaround anymore, see the comment of the OP.

Also define a operator v#l=... instead of f v l=..., will save you two bytes:)

@flawr I had the idea of v!l=..., but didn't kow if it was accepted. I'll edit the answer. Thanks!

Using map on some filter expression is often an indicator that a list comprehension might be shorter: v!l=[i|(i,x)<-zip[1..]l,x==v].

There is also a builtin, but unfortunately it is longer than Laikionis suggestion:)

Husk, 5 bytes
`fNm=

Try it online! 1-indexed.
Explanation
       -- implicitly input a value v and a list L
   m=  -- map "equals v" over the list L, resulting in a list of truthy and falsy values
`fN    -- filter the natural numbers N by discarding the numbers at falsy positions
          and keeping the ones at truthy positions

Does this work for arrays with strings, though?

@officialaimm It works for lists containing only strings: Try it online! Lists of mixed types are not supported by Haskell and thus by Husk, but OP allowed this explicitly in the comments.

Is there a documentation of Husk?

@flawr Yes, it's in the wiki on the github page: https://github.com/barbuz/Husk/wiki

@flawr If you have questions about the docs of Husk in general, join us in the chatroom!

should just be ¥  now.

APL (Dyalog Unicode), 2 bytesSBCS
Takes item to look for as left argument (must be scalar to find an item of the lookup array rather than a subarray) and the lookup array (which may have up to 15 dimensions) as right argument. Returns list of indices, each of which may has as many elements as the number of dimensions in the lookup array.
⍸⍷

Try it online!
⍸ ɩndices where
⍷ found

I was about to say it ties Pyth, but you know... Unicode. Wouldn't this be 2 bytes in APL Dyalog Classic (since it uses SBCS)?

@Mr.Xcoder ⍸ isn't in the character set. Still, since Dyalog uses way less than 256 unique chars, it could have been a single byte. When we add new glyphs, we refrain from changing the character set so that backwards compatibility is maintained.

Ah, Thanks! (I have no idea how APL / Dyalog works)

@Mr.Xcoder APL is a commercial language (not a golfing language), so Dyalog have certain obligations to existing subscribers.

APL isn't a golfing language, but there do exist open-source APL implementations (ngn and GNU).

Batch, 86 bytes
@set i=0
:g
@if "%~2"=="" exit/b
@if %1==%2 echo %i%
@set/ai+=1
@shift/2
@goto g

Takes input as command line parameters (value then the array elements as separate parameters). Note: String quoting is considered part of the match e.g. "1" won't equal 1 (would cost 6 bytes).

Python 2, 49 bytes
lambda l,v:filter(lambda i:l[i]==v,range(len(l)))

Try it online!
Not short enough, but I thought it was cool. ¯\_(ツ)_/¯

Perl 5, 28 bytes
sub{grep$_[$_]eq$_[0],1..@_}

Try it online!
The output is 1-indexed.
An anonymous function is quite unusual for Perl, but it happens to be the shortest I could think of. grep ..., 1 .. @_ iterates over the indexes of the input array (actually it goes one cell beyond the last, but it doesn't matter), keeping only the index that satisfy $_[$_]eq$_[0], ie. the ones where the value of the element ($_[$_]) is the same as the value we need to keep ($_[0]).

Slightly longer (31 bytes (30 + -l flag)), but as a full program:
$@=<>;$@eq$_&&print$.-1while<>

Try it online!

Haskell, 37 33 bytes
import Data.List
findIndices.(==)

Thanks @Laikoni for -4 bytes!
Try it online!

Pointfree is shorter: findIndices.(==)

Oh right, that is even more pointfree, thanks=)

Why not elemIndices?

Java 8, 146 113 112 111 110 108 bytes
import java.util.*;l->o->{List r=new Stack();for(int i;(i=l.indexOf(o))>-1;l.set(i,null))r.add(i);return r;}

-2 bytes thanks to @TAsk by using Vector instead of ArrayList.
-1 byte by using Stack instead of Vector.
-2 bytes thanks to @Jakob by inputting a ArrayList instead of an array.
0-indexed
Explanation:
Try it here.
import java.util.*;    // Required import for Vector and Vector
l->o->{                // Method with List and Object parameters
  List r=new Stack();  //  Result-list
  for(int i;(i=l.indexOf(o))>=-1;
                       //  Loop as long as we can find the object in the list
    l.set(i,null))     //   After every iteration, remove the found item from the list
      r.add(i);        //    Add the index to the result-list
                       //  End of loop (implicit / single-line body)
  return r;            //  Return the result-List
}                      // End of method

Cool! If I am not wrong Vector may save few bytes. :)

@TAsk Thanks! Need to remember that one. I use List+ArrayList pretty often.

List r=new Vector(); will work, too.

You can save 1 byte by taking a list instead: TIO. Seems like a small enough change not to merit a separate answer.

The change breaks searching for null, but that's fine.

Mathematica, 12 bytes
Position@##&

1-Indexed
input [Array,Value]

[{12, 14, 14, 2, "Hello World!", 3, 12, 12}, 12]

output

{{1}, {7}, {8}}

Why not just Position?

Haskell, 29 bytes
e#l=[i|(i,h)<-zip[0..]l,h==e]

Try it online!

Does that work with the heterogeneous input cases? (Mixtures of integers, strings, a "true" value, etc).

@Kaz: no, it doesn't. It's polymorphic and works for every type where equality is defined for, but all list elements have to be of the same type. According to a comment in the OP that's enough.

Japt, 9 bytes
mÈ¶V©YÄÃf

1-indexed.
Japt input doesn't support booleans, so they have been replaced with 0 and 1 in the test cases.
Try it online! with the -Q flag to format the array output.
0-indexed Solution, 11 bytes
l o f@gX ¶V

Try it online!

One of the few times ¶ rather than ¥ comes in handy :P I was thinking of doing something along the lines of m@Y*(X¶V} f, but I hadn't realized that wouldn't work for index 0. 1-indexing is clever...

Perl 6, 21 bytes
{grep :k,*===$^v,@^z}

Try it online!
The :k adverb to grep tells it to return the matching keys (indices) of the input sequence that match the predicate * === $^v.
If strings and numbers were considered equivalent, one could use a grep predicate of just $^v instead of * === $^v.

eqv might be better than === depending on what you want to consider equivalent values.

C 340 362 166 115 Bytes
Hello all. My first time here. I figured since I enjoy (attempting) to write optimized code I may as well give this a try.
@Rodney - ~39 bytes from the includes
@Zacharý - 7 bytes with implicit typing
0-indexed.
How to Run:
As per @Arnolds suggestion, the program takes arguments in a much more C friendly manner. This let me reduce the size of the file by a little more than half.
The arguments should be passed in the following order value [element1 ...]
where braces indicate optional arguments
You may or may not have to add escaped quotes to any strings that are provided in order to satisfy the condition of 12 != "12". On my system the this can be done in the following manner
prog-name.exe 12 3 "Hello" 12 4 "12"
Returns [2,4]     < This is incorrect

prog-name.exe 12 3 "\"Hello\"" 12 4 "\"12\""
Returns [2]       < Correct

golfed
#define P printf(
b=0;main(int c,char**v){P"[");for(--c;c-1;c--)b|=strcmp(v[1],v[c])?0:P b?",%i":"%i",c-2);P"]");}

ungolfed
#define P printf(

//Implicit only works in global(I totally knew this after almost 4 years of C :P)
b = 0;
main(int c,char**v)
{

    P"[");

    //match loop
    //b is used to determine if this is the first iteration. it can be assumed that printf will always return >0
    //subract two from c to get correct index number of match
    for(--c; c-1; c--)
        b |= strcmp(v[1], v[c]) ? 0 : P b ? ",%i" : "%i", c-2);

    P"]");

    return 0;
}

Welcome to the site.  I notice you have a lot of extra whitespace.  Particularly around operators i = 0.  These can be removed.  I suggest playing around with the whitespace a bit.

With the way you handle the list, a first argument of ,12 and second argument of [12,14,14,2,"Hello World!",3,12,12] prints [5,6] which is technically incorrect.

@ArnoldPalmer I updated the code to make it a little more verbose at detecting data types. However, since C doesn't have all the fancy type conversion such as JavaScript, it is still vulnerable to having a comma in a 'number' type. I pretty much just left it assuming correctly formatted input.

@Marcos There's a chance you may be able to take each value of the array as it's own command line argument. I don't golf in C ever, so not quite sure what the rules are, but it doesn't seem unreasonable to me that you'd be allowed to do that. Especially since accepting the array as a list leaves you vulnerable to this problem. Also, you still have a bit of white space in your golfed code. You don't need the spaces on the #include statements, strstr(h+i,n)-h ==i has an extra space, and you can do return-1 instead of return -1.

are implicit declarations allowed? I think you can ditch the #include statements

You could change the macro to #define P printf(, then change the code at the bottom to int main(int c,char**v){int b=0,i=0;P"[");for(;i<c-2;i++)b|=strcmp(v[1],v[i+2])?0:P b?",%i":"%i",i);P"]");} to save a byte. And int and #include can be implicit in C.

Common Lisp, 66 bytes
(lambda(x s)(loop as i in s as j from 0 when(equal i x)collect j))

Try it online!

TXR Lisp, 26 bytes
(op where(op equal @@1)@2)

In other words, "Where is argument 2 equal to argument 1?"
Run:
1> (op where(op equal @@1) @2)
#<interpreted fun: lambda (#:arg-01-0166 #:arg-02-0167 . #:rest-0165)>
2> [*1 12 #(12 14 14 2 "Hello world!" 3 12 12)]
(0 6 7)
3> [*1 "Hello World" #("Hi" "Hi world!" 12 2 3 t)]
nil

05AB1E, 4 bytes
Qƶ0K

Try it online!
It is 1-indexed, as shown below:
IN A-#------------------------> [2,3,3,3,4]
IN B-#------------------------> 3
-----#------------------------+-----------------
Q    # Vectorized equivalence | [0,1,1,1,0]
 ƶ   # Lift by index          | [0,2,3,4,0]
  0K # Remove zeros           | [2,3,4]

Clojure, 39 38 bytes
#(filter(comp #{%2}%)(range(count %)))

A bit obscure :) The first input argument is a vec of values and the second one is the searched value. % maps indexes to values, and the set #{%2} returns truthy (the input argument %2) or falsy nil for that value. comp composes these together.

MY, 5 bytes
⎕⎕=⍸↵

Try it online!
How?

⎕ evaluated line of input
⎕ evaluated line of input
= element-wise equality
⍸ indexes of truthy elements
↵ output with new line

MY is capable of something again! Order of the inputs does not matter. Indexing is 1-based by default.

J, 6 bytes
I.@:=

Assumes inputs are of the same type.
I do not know J very well. This took way too long.
= is (vectorized) equality. I. returns the indices of 1s in an array. @: is verb composition.
Try it online!

Japt, 9 3 bytes
ð¶V

Try it
ð¶V     :Implicit input of array U and element V
ð       :Indices of elements in U
 ¶V     :That are equal to V

Rust, 51 bytes
|a,v|(0..).zip(a).filter(move|a|a.1==v).map(|a|a.0)

Try it online!

Pyt, 6 bytes
=ĐŁř*ž

Try it online!
=           implicit inputs; is each element in the array equal to the value?
 Đ          duplicate resultant array
  Łř        get length and create array [1,2,3,...,<length>]
    *       multiply (does normal integer multiplication for integers, booleans,
            and floats, and does string multiplication for strings)
     ž      remove zeros; implicit print

Javascript,48 bytes
b=>a=>a.reduce((a,e,i)=>(e===b&&a.push(i),a),[])

let f=b=>a=>a.reduce((a,e,i)=>(e===b&&a.push(i),a),[]);

console.log(f(12)([12,14,14,2,"Hello World!",3,12,12]));         //[0,6,7]
console.log(f("Hello World")(["Hi", "Hi World!", 12,2,3,true])); //[]
console.log(f("a")(["A",true,false,"aa","a"]));                  //[4]
console.log(f(12)([12,"12",12]))                                 //[0,2]

D, 78 bytes
int[]f(T)(T[]a,T e){int[]r;for(int i;i<a.length;i++)if(e==a[i])r~=i;return r;}

The calling mechanism is ... really odd: Try it online!.
D has a variant type!

Swift 4, 46 bytes
{a,e in a.enumerated().flatMap{$1==e ?$0:nil}}

a.enumerated() produces an array of (index, element) pairs.
flatMap compares the element (the second member of the tuple, accessed by the implicit closure parameter $1), and either returns the index (the first member of the tuple, accessed by the implicit closure parameter $0), or nil.
flatMap has the effect of removing nils from the output sequence, so only the indices remain.
This is a byte shorter than the more obvious
{a,e in a.enumerated().filter{$1==e}.map{$0.0}}

SmileBASIC, 77 53 bytes
DEF S A,V
FOR I=0TO LEN(A)-1IF V==A[I]THEN?I
NEXT
END

Also works with strings/characters in addition to normal arrays/values.

PHP, 99 bytes
Not the best, but at least I try.
PD: Hate PHP's functions name

function f($c,$a){return array_filter(array_keys($a), function($b)use($a,$c){return $a[$b]==$c;});}

Try it online!

Kotlin, 66 bytes
{v:Any,l:List<Any>->l.mapIndexedNotNull{i,j->if(j==v)i else null}}

Try it online!
mapIndexedNotNull really is the powerhouse of this lambda. It's the same thing as mapIndexed (map with an additional index argument) with the added bonus that it excludes null results from the output. Find something we don't like? Return null!
{ v: Any, l: List<Any> ->          // lambda
    l.mapIndexedNotNull { i, j ->  // map with index, removing nulls
        if(j == v) i else null     // return index if equal else null
    }
}

J, 2 bytes
ss

String search is in the strings library which is implicitly imported if your interpreter isn’t too old. It’s defined as I.@E. (compare with the APL solution) so it can also look for sequences of values. Try it online!

Factor, 7 bytes
indices

Try it online!

jq, 25 bytes
.[0]as$r|.[1]|indices($r)

All input to jq has to be valid JSON, so the examples need to be enclosed in brackets.  And boolean constants like True need to be translated to true, etc...  Other than that, it essentially sets things up to use a builtin function indices() which does exactly what the challenges wants.
.[0]as$r                  - Set var "$r" to what we want to find
        |.[1]             - Select the list of options...
             |indices($r) - Find positions of "$r" in the list

The output is a list of integers, with the offsets to matching entries.  The output is an empty list of the target isn't in the list.
Try it online!

Thunno, \$ 2 \log_{256}(96) \approx \$ 1.65 bytes
zI

Attempt This Online!
Built-in solution.

Go, 75 bytes, int only
func(e int,A[]int)(I[]int){for i,E:=range A{if e==E{I=append(I,i)}};return}

Attempt This Online!
Go, 98 bytes, generic
func f[T any](e T,A[]T,C func(T,T)bool)(I[]int){for i,E:=range A{if C(e,E){I=append(I,i)}};return}

Attempt This Online!
Golang is statically typed, so both solutions take in a homogenous slice.
The challenge as-written is possible with interface{} shenanigans.
Go, 133 bytes, as written
func f[T any](e T,A[]any,C func(T,T)bool)(I[]int){for i,E:=range A{switch E:=any(E).(type){case T: if C(e,E){I=append(I,i)}}};return}

Attempt This Online!
Uses this trick to cast the generic type to interface{} so that it can be type-switched over.

Nibbles, 2 bytes
`?$_

Attempt This Online!
Built-in.
`? Find indices
$   in the first argument
_   of the second argument


text:
Seeking Secret Swapping Sequences

This is a cops-and-robbers challenge, the robbers thread can be found here.

Your task is to write some code that outputs an OEIS sequence, and contains the name of the sequence in the code (A______) and outputs a second separate sequence when the name of the sequence in the code is changed to the name of the second sequence.
Here's an example in Haskell that works for A000217 and A000290.
f x|last"A000217"=='0'=x^2|1>0=sum[1..x]

Try it online!
You are then to reveal one of the two sequences, and the code keeping the second sequence a secret.  Robbers will attempt to figure out what the hidden sequence is.  If a robber manages to determine what your sequence is (or another sequence that fits the criteria) you answer is cracked.  If none do so in a week of your answer being posted you may mark your answer as Safe and reveal the intended solution for verification.  Safe answers cannot be cracked.
Input Output
Taken from here
Your code can be a function or complete program that takes n via a standard input method and outputs the nth term of the sequence as indexed by the provided index on the OEIS page.
You must support all values provided in the OEIS b files for that sequence, any number not in the b files need not be supported.
Scoring
Your score will be the number of bytes in your code, with less bytes being better.

Your score will be the number of bytes in your code, with less bytes being better. - Why isn't this tagged [tag:code-golf], then?

@Mr.Xcoder I forgot to.  Don't read into these things too much ;)

So code should output sequence of some length (defined or not?) or n-th element of sequence?

@DeadPossum nth term.

@WheatWizard guess I was looking somewhere else, but monitor. My bad

May we choose constant sequences (We should be allowed, IMHO)?

@Mr.Xcoder yes constant sequences are fine, (probably rather easy to crack though).  Did something give you the impression they were disallowed?

@WheatWizard Did something give you the impression they were disallowed? - No, of course not.

Can we amend leading zeroes in sequence number? Like A1

@DeadPossum No you cannot.

Were any marked as the answer? Hint, mine was safe and had the lower byte count ;)

@YiminRong No answers were marked.  I don't mark answers.

Python 3, 59 bytes, A162626, cracked
lambda n:n*(n+1)*(n+2)/3if 0<=n<=3else n*(n**2+5)/3#A162626

This is was supposed to be impossible, wasn't it?

Cracked

Python 3, 62 bytes, A017016 (Cracked)
n=int(input())
print(sum(1for i in"A017016"if i>"0")*-~n//-~n)

Try it online!

I tried to make it as obfuscated as possible...

@officialaimm I did that on purpose. I want to make this obfuscated. I don't really care about golfing, because Python won't win a code-golf obfuscation contest :p

Cracked?

By the way, was that the intended solution?

@totallyhuman Yeah, it was the indtended solution.

MATL, 30 29 bytes (Cracked)
A077430I\2-|Gw^1Mwx*10&Ylk1+&

A077430
Try it online!
-1 byte thanks to @Sanchises

Should be fixed now

Just a hint: you can replace  3 by I for 1 byte.

@Sanchises Thanks! Didn't knew I is initialized to 3

You should check out Table 3. Along with l (one) and O (zero), you should almost never have to use a space in your MATL programs. On a related note, check out Table 7 as well, which contains many useful predefined constants (although beware that e.g. 4X2Z% has a shorthand 1Z%)

Cracked.

Japt, 13 bytes (Cracked)
There is (at least) one other solution, if anyone else wants to take a stab at it.
p#A000012uCnG

Try it onlineA000012

Explanation

 # followed by a character in Japt gives us the charcode of that character, so #A=65, which the rest of the number then gets appended to, giving us 65000012 or 65000290.

u is the modulo method (it differs from % in that it will always return a positive number).

 The n method subtracts the number it is applied to from the number passed to it. C and G are the Japt constants for 11 & 15, respectively. So, CnG gives us 4.

We now have 65000012%4=0 and 65000290%4=2. The p method raises the number it's applied to (in this case that is, implicitly, the input integer U) to the power of the number passed to it, giving us the 2 final formulas of U**0 and U**2.

cracked?

@officialaimm: Correct, nicely done.

Since I don't know Japt, I had assumed the power to be raised was (sum_of_numbers_in_oeis(excluding 'A') + 1)%4. :D

@officialaimm: I love seeing robbers crack challenges in languages they don't know :) I actually posted this with the hope that it would be someone unfamiliar with Japt who would crack it.

A020338 may also work if string input is allowed (1-indexed).

C#, 75 bytes, (Cracked)
n=>{int r=1,e=3-0xA000244%2;for(;n>0;e*=e){r*=(n%2>0?e:1);n>>=1;}return r;}

A000244
Try it online!

Cracked

@Lynn What gave it away? The first sequence?

You are taking the OEIS number % 2 — so the program can literally only do two things, depending on the outcome of that: one for 0 and one for 1. So I put an odd number in its place, and the challenge kinda cracked itself.

@Lynn Ah suppose, didn't think obfuscating that part.

Python 2, 43 bytes, A000079 (Cracked)
Try it online
lambda n:((sum(map(ord,'A000079'))*2)%8)**n

Cracked?

@TheLethalCoder Well.. It fits, but it is not the one, that I've chosen. Also I made edit before your comment, and it no longer fits

You changed it after posting? A bit unfair.

@TheLethalCoder I did it to protect from this false-positive sequence :C

Cracked?

@TheLethalCoder Yep!

I knew it was powers of something I just had to find the right one.

@TheLethalCoder **n is a good clue :D Sorry for confusion with powers of 3, I somehow missed it, while checking other powers of X to be false-positive

I don't know about editing an entry, but from the rules in the OP, "If a robber manages to determine what your sequence is (or another sequence that fits the criteria) you answer is cracked", just FYI.

C#, 28 bytes (Cracked)
n=>n*n*("A000290"[6]<49?1:n)

Works with A000290.
An easy one to get this started.
Try it online!

It cannot be cracked yet >_<

@Mr.Xcoder Can now :)

Craked (although not really cracked!)

@Shaggy I just wanted to get the ball rolling :P

Python 2, 53 bytes, A000012 [cracked]
lambda x:len(`x**(sum(map(int,'A000012'[1:]))==22)`)

Try it online!

 The next sequence is A055642(length of digits in a decimal number). For which the number evaluates to itself, since sum of the digits in OEIS equals 22; the len(...) thus calculates to actual length of the input number for 'A055642'. For sequences A000012(or any other than A055642. The len will always equal to one, since the number evaluted will be '1'.

Cracked?

Haskell, 226 bytes, safe!
Not sure if clever or ugly, maybe both...
o n=read.pure.(!!n)$"A001906"
m::Integral a=>[a->a->a]
m=[const,(+),(-),(*),div,(^)]++(flip<$>m)
l=o 1:o 3-o 1:zipWith(m!!(o 6+o 3-o 2))(tail l)l
f=(l!!).((m!!(o 4+o 5+o 6-2*o 1-o 2))$sum[1|n<-[1..6],odd(o n)]).((m!!o 6)$o 3)

So now this computes A001906, but it should be able to generate a lot of sequences.
Try it online!

Solution: A131078
Wondering if this was too difficult or no one tried?
o 1 to o 6 are the digits of the series number, m is a list of operations. l is a recursively defined infinite list with the first two values derived from the series number and the remaining ones computed from the previous two using a fixed operation from m. In the case of A001906, the definition can be simplified to
l=0:1:zipWith(flip(+))(tail l)l

(flip(+)) is (usually) the same as (+), and we get a well known (but not the shortest) definition of the Fibonacci numbers. This recursion scheme could directly compute A001906, but that needs an operation more complicated than those in m. Another example: using starting values 1 and 2 and the operation (*) gives the series A000301. It is computed by our code when the series number is replaced with ?103206.
Finally, the function f indexes into the list l, but only after some transformation of the input. For A001906, the middle part reduces to (*)2, so that we only get the Fibonacci numbers at even positions. The right part becomes flip const 1, which is the identity function and does not further interfere.
For the solution A131078, the starting values of l are 1 and 0, and the operation is flip const, which lets l be 1,0,1,0,.... The middle part of f becomes (flip div 4), resulting in 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,.... This looked like a nice answer, but then I saw that A131078 starts at n=1, so I added the right part of f, which here is flip(-)1 to subtract one.
My idea was to make it a bit obfuscated by using m and indexing into it with digits from the series numbers, then it became more obfuscated (complicated terms) to make it work (maybe I wasn't searching long enough for alternatives); and then it became even more obfuscated (right part of f) to make it really work. Still I think some guessing and trying could have cracked it.

I tried a few sequences and they usually gave division by zero errors, negative exponent errors or just seemed to run forever. To be honest, Haskell freaks me out, just can't seem to wrap my head around it, spent too long in procedural I guess.

If you're just trying, there is the extra problem that even the solution gives a "negative index" error when given 0. That is fine because it only starts at 1! Starting at 1 should also remove some of the "division by zero" errors. I'm surprised by examples running forever. Maybe the index transformation creates very big values in these cases...

Python 3, 65 bytes, A000027, cracked
a=lambda a,n=((int("A000027",11)-0x103519a)%100%30+1)/2:a//(14-n)

Yay crazy arithmetic!

Um, A004526, gives n=12 which looks right, but the result will be off by one index - did I crack with bug or fall for a very clever red herring?

Neither; you've misinterpreted A004526, which clearly states a(n) = floor(n/2); the sequence listed starts with 0. That is the intended solution, however.

Oh yes the offset - right (whew), thanks! Well cracked then.

Smalltalk, 148 bytes, safe!
|x o|x:=(16rA018253*0.00861-1445345)floor. o:=OrderedCollection new. 1 to:x/2 do:[:i|x\\i=0 ifTrue:[o add:i]].o add:x.^o at:stdin nextLine asInteger

A018253
Takes an integer as input, sequence is 1-based.

 The intended second sequence is A133020. In the writeup for A018253 is a link to a list of entries for sequences related to the divisors of numbers. In that list, A133020 is under divisors of squares: 100². If you want to see the entire sequence, insert Transcript show: o printString; cr. before the return ^ statement in the code.

dc, 52 bytes, cracked
This one works with A000217:
?SaA000217d8d1+Sb%1r-dScla*r10 7^-Lb%+la*1+Lc+La*2/p

Try it online!

Cracked.

Chip, 67 bytes, cracked by Yimin Rong
2D5B#{*Cm49!}E-7
(A000012d#,zkmsh
b-\6/e2)[1Zv^~^S
33a#kcf3g88taz1@

A000012. A bit cheeky, yes.
Try it online!
Uses bytes for i/o, so I was nice and built a bashy/pythony wrapper.

Alternate sequence is A060843. Try it online for inputs 1..4.

Yimin Rong hunched right, such a short Chip program can only calculate very simple things. The original sequence is all one's, and the alternate sequence is the busy beaver numbers, of which only 4 are known.

These numbers, 1, 6, 21, 107, are simply hard-coded for the inputs 1..4.

One interesting thing about using Chip for this challenge is that the digits 0-9 are not numbers, but logical elements. Specifically, 0-7 are the eight bits addressing the head of the stack, and 8 and 9 are the read and write toggles. That made this a bit more interesting and much more obfuscated.

A potential giveaway is that only A-D appear, meaning that we only have 4 bits for indexing the sequence. This meant that there could be at most 16 different values. In fact, only A-C are actually used for the alternate sequence, giving at most 8 different values.

For any who might be interested, here is the same code, stripped of the no-ops and unused elements:

.

   B  *C 49!
 A000012d ,z  s
b-\6/e   1Zv-~^S
`3a`-cf3g`8taz1

Just to exclude the obvious, you're not trying to sneak in an empty sequence, e.g. A290000? Technically, because your code returns nothing for input of zero, this sequence would match!

Ha, there is at least one value in the other sequence :) Also, I should say, I designed this to be 1-indexed, since that's how OEIS is indexed.

(Nevermind, I found counterexamples. My code is still 1-indexed.)

So I did some more looking into it, and the doing-nothing is python's fault. It wasn't giving any output for zero, so my code never ran. I've fixed that in the TIO link now. (Gave the bit-length a floor of 1 byte).

Cracked.

Python 3.6, 114 bytes, cracked
from random import*
g=lambda n:eval(''.join(Random("A005843").choices('n8-9+17n#8*+26%n1 32-3+4-545*-#6*7',k=34)))

A005843
g(n) returns the n-th value of the sequence for n >= 0.
random.choices(s,k) is new in Python 3.6, it returns k items selected from s with replacement.

Feel very much like encryption/hashing.

@ppperry - if that's against the rules, I'll remove it.

Cracked?


text:
Solving Secret Swapping Sequences

This is a cops-and-robbers challenge, the cops thread can be found here.

This is the robbers thread, your job here is to take submissions on the cops thread and try to find the hidden sequences.  If you find any sequence that can be substituted into the original code to compute that sequence that is a valid crack.  Please notify the cops of your cracks as they happen so they can update their answers.
Scoring
Your score will be the number of successful cracks you have made, with more cracks being better.

Why not just let robbers comment the sequence # in the cops thread?

@Lynn I think that robbers should be able to get upvotes for their work in cracking answers.  I prefer the two thread format for that reason.

Japt, Shaggy, A000290
p#A000290uCnG

Try it online!

Python 3: Mr. Xcoder, A010709
n=int(input())
print(sum(1for i in"A010709"if i>"0")*-~n//-~n)

Try it online!
Additionally, here's a golfed version of the original. :P
lambda n:sum(1for i in"A017016"if i>"0")*-~n//-~n

Well done... I knew it would be cracked soon

Python 3, pppery

A018226

The original code put the sequence name in a comment.  Since the comment probably can't affect the code I figured the hidden sequence had to be some sub-sequence of the original.  A quick search of the first couple terms brought up A018226.  Since it is a sub-sequence the code works for both.  A018226 is even listed on the original sequence's page if you look back

One way to generalize the magic number sequence in A018226.

That was the intended solution. I had the idea of trying to make people think it was impossible by putting the sequence in a comment.

@ppperry The comment was what gave it away :).  I figured it had to be a sub-sequence.  Good fun anyway!

Maybe I could have hid that better, but still is an interesting twist compared to the typical answers to this sort of thing; about numbers, rather than code.

Python 2, Dead Possum

A000244 (Powers of 3)

This no longer works, the OP updated the example after I posted this.

Python 2, Dead Possum

A000007: The characteristic function of 0: a(n) = 0^n.

C#, TheLethalCoder, A000244
Also works with A000079 (powers of two).

dc, Bruce Forte
Cracked with A027480.

Well done! What gave it away?

The modulus operations limit the number of sequences generated. In this case 8 × 9 = 72. So plugged the formula into a spreadsheet and generated all of them. Only a handful of sequences produced all integers for all terms, and of those made a guess that only sequences with all positive terms would be of interest. Then it was a matter of searching the sequences and plugging the reference number back in. Searched five, three had corresponding entries, the third one matched outputs for all inputs.

If only I had not divided by 2 ;P

C#, TheLethalCoder

A000578 (Cubes)

An easy one - it was also posted here.

Of course, people should stop posting the answers from the other challenge :)

Python 2: officialaimm, A055642
lambda x:len(`x**(sum(map(int,'A055642'[1:]))==22)`)

Try it online!
It took me a while to find the sequence... Mostly 'cause OEIS search is super slow for me. o0

Nicely done. (y)

Python 3, ppperry, A000027 -> A004526
f=lambda a,n=((int("A004526",11)-0x103519a)%100%30+1)/2:a//(14-n)

Try it online! (prints first few terms of both. Note the two sequences have offsets of 1 and 0 respectively, so the first has a leading zero - it threw me a little!)

MATL, Cinaski
Cracked with A055642.

Python 3.6, RootTwo
Original is A005843
Cracked with A001107
Try it online
The eval'd code of the original (minus comments) is n*2, of the cracked version is 4*n*n-n*3.
After filtering out syntax errors, undeclared variables, zero divisions, etc, it didn't take too long to run through the remaining list. There were a few false positives (like A004917) that I had to filter out by hand due to only checking the first few numbers, but it wasn't too common.
Also, A040489 tries to calculate n**3436485154-n, which slowed me down a bit. :P

Congrats. That's it. Did you brute force it?  I tried to make a few incorrect sequence ID's result in valid Python to slow things down, but not enough I guess.

@RootTwo I did mostly brute force it. I had some other heuristics in there too, but nothing very complex. Took a couple mins to find 1107, about 8 to get up to 5843. Out of curiousity, I went up to 50000. No other matches in that range. I'd guess 15-20% were valid python.

Chip, Phlarx
Cracked with A060843. On a hunch, guessed the sequence was going to be short!

You got it! Good job