# [Python 2], 79 bytes

<!-- language-all: lang-python -->

    lambda s:all(n==reduce(lambda n,c:-~[n,n%3+n%4][c>'L']%5,s,n)for n in range(5))

[Try it online!][TIO-l7jjmmi7]

[Python 2]: https://docs.python.org/2/
[TIO-l7jjmmi7]: https://tio.run/##NYm7DoMgGIV3noKFCCkdenEhoU/AxGpNQxEqCf4axJgufXWrvZxz8g3nG5657eG4eHldounujcGjMDFSkDK5ZrKO/m7gVuxfFXAgpx2Qc13ZS6GKmpR85MB8nzDgADgZeDhaMrbMbYgOH8SQAmTsaTLzLcAwZbpKtQUp/S/SKz5DSCP11XqjfgM "Python 2 – Try It Online"

This uses the group-theoretic approach from [Ilmari Karonen's GolfScript answer](https://codegolf.stackexchange.com/a/35996/20260) to my [2014 challenge][1], in particular to the bonus question.

Instead of the ant crawling around the dodecahedron, we imagine it stays in place while the dodecahedron turns under its feet. We must determine whether the sequence of rotations returns the dodecahedron to the initial position.

There are 60 rotation of the dodecahedron -- 12 faces times 5 positions per face. These rotations can be expressed as permutations of 5 elements. Specifically, they permute 5 colored tetrahedra shown below that partition the 20 vertices of the dodecahedron.

[![Five tetrahedra inside dodecahedron][2]][2]

We could take each rotation and write down which color tetrahedron moves onto which color's position to obtain a permutation of the five colors. Specifically, these are the [even permutations][3], which are half of the 5!=120 permutations of five elements, or 60, forming the [alternating group][4] \$A_5\$ on five elements. The other 60 odd permutations would involve reflecting the dodecahedron and well as rotating it, so they do not figure in this problem.

We want to choose two even permutations that represent the rotations from the ant turning left and right. As [noted by Ilmari Karonen][5], the two permutations must have order 5, corresponding to five left or five right turns brining the ant back to the same place. Moreover, their product must have order 5 as well, and neither can be a power of the other.

There are many choices for the two permutations. If we think of them as permuting the values 0 to 4, the pair our code uses is `12340` and `13042`. The first one simply adds one modulo 5. From here, there's 5 choices for the other one: `13042, 14302, 24310, 32041, 32410`. The code uses `13042` because it happens to have a short expression in Python `1+(n%3+n%4)%5`, or just `n%3+n%4` if we "share" the `+1` and `%5` for the other case`. I found this via some brute-forcing.

Now let's take another look at the code:

<!-- language-all: lang-python -->

    lambda s:all(n==reduce(lambda n,c:-~[n,n%3+n%4][c>'L']%5,s,n)for n in range(5))

[Try it online!][TIO-l7jjmmi7]

[Python 2]: https://docs.python.org/2/
[TIO-l7jjmmi7]: https://tio.run/##NYm7DoMgGIV3noKFCCkdenEhoU/AxGpNQxEqCf4axJgufXWrvZxz8g3nG5657eG4eHldounujcGjMDFSkDK5ZrKO/m7gVuxfFXAgpx2Qc13ZS6GKmpR85MB8nzDgADgZeDhaMrbMbYgOH8SQAmTsaTLzLcAwZbpKtQUp/S/SKz5DSCP11XqjfgM "Python 2 – Try It Online"

To check that the sequence of permutations combines to the identity, we test each starting value `n` from `range(5)`, apply the sequence of permutations to it using `reduce`, and check that `all` of them end up at the initial value. The `-~` is a shortcut to add one.

An alternative approach might be to implement the permutation composition directly using bit operations as I do in my [2018 answer](https://codegolf.stackexchange.com/a/157848/20260) to my challenge with the cube. The idea here would be store the state as a 15-bit number split into five 3-bit fields, and implement the two permutations of the 5 bit fields using bit operations. At least one of the bit operations would be fairly involved, but it would parallelize the current solution's applying permutations to 5 starting values, so I'm not sure which would win out.

----

**74 bytes**

<!-- language-all: lang-python -->

    lambda s:0in[n==reduce(lambda n,c:-~[n,48/~n][c>'L']%5,s,n)for n in 0,1,2]

[Try it online!][TIO-l7jzwosd]

[Python 2]: https://docs.python.org/2/
[TIO-l7jzwosd]: https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaHYyiAzLzrP1rYoNaU0OVUDKpynk2ylWxedp2NioV@XFxudbKfuox6raqpTrJOnmZZfpJCnkJmnYKBjqGMU@788IzMnVcHQqqAoM69EIU2jKLE8PjOvoLREQ1Pzvw8IcPkEwSBXEJAAIy6uIC4fiHQQiAwCAA "Python 2 – Try It Online"

Outputs True/False swapped.

I found `48/~n` as a shorter alternative for the second permutation when it is incremented and taken mod 5.

Also, instead of checking that the permutation maps each of `0,1,2,3,4` to themselves, this only checks `0,1,2`. This suffices because the map is bijective, so once `0,1,2` are fixed, `3` and `4` have to either map to themselves or swap, and because the permutation is even they can't swap.

**65 bytes**

<!-- language-all: lang-python -->

    S=s=`321.`
    for c in input():s=(s+s[ord(c)%9:3]+s)[3:8]
    print s==S

[Try it online!][TIO-l7k6igme]

[Python 2]: https://docs.python.org/2/
[TIO-l7k6igme]: https://tio.run/##K6gsycjPM/pfnpGZk6pgaJVakZqspKT0P9i22DbB2MhQL4ErLb9IIVkhMw@ICkpLNDStim01irWLo/OLUjSSNVUtrYxjtYs1o42tLGK5Cooy80oUim1tg/@DTFHyAQElLiWfIBgEcoKAFBgB2SAuSB6mMAhEBykBAA "Python 2 – Try It Online"

This uses a different mapping pair: `34012, 34120`. These are nice to implement as operations on lists, moving the last two elements to the front in both cases, and for the latter cycling the last 3. To start, we just need any sequence of 5 distinct elements, so we use `` `321.` `` which equals `'321.0'`.

**61 bytes**

<!-- language-all: lang-python -->

    n=27
    for c in input():n=n%16*64|n/16*4**(c>'L')%63
    print n<28

[Try it online!][TIO-l7k6e4j6]

[Python 2]: https://docs.python.org/2/
[TIO-l7k6e4j6]: https://tio.run/##K6gsycjPM/pfnpGZk6pgaJVakZqspKT0P8/WyJwrLb9IIVkhMw@ICkpLNDSt8mzzVA3NtMxMavL0gbSJlpZGsp26j7qmqpkxV0FRZl6JQp6NkcV/kAlKPiCgxKXkEwSDQE4QkAIjIBvEBcnDFAaB6CAlAA "Python 2 – Try It Online"
Bitwise shenanigans

**60 bytes**

<!-- language-all: lang-python -->

    L=1;R=1j
    for c in input():exec c+"=(L+R)%5%5j"
    print L*1j==R

[Try it online!][TIO-l7l5gxrc]

[Python 2]: https://docs.python.org/2/
[TIO-l7l5gxrc]: https://tio.run/##NUxBCoQwDLz3FSEg6Hrqgpdd8oOc8oVSsWWpRSqur6@NYGZgZsgw@SzLmt71WMLPg/34v3eIWJnsV8hGM68bOAipMe@lH@4GuBGp51GGbuqmiCZvIRXgl41EUnUAWQ8NsjxoQZrcbF6j/p@iqApe "Python 2 – Try It Online"

A new method based on [alephalpha's finding][6] that \$A_5 \cong PSL(2,5)\$. A cute trick here is using `L` and `R` for variables so we can plug the character we read and `exec`.


  [1]: https://codegolf.stackexchange.com/q/35978/20260
  [2]: https://i.sstatic.net/zCRYMm.jpg
  [3]: https://en.wikipedia.org/wiki/Parity_of_a_permutation
  [4]: https://en.wikipedia.org/wiki/Alternating_group
  [5]: https://codegolf.stackexchange.com/a/35996/20260
  [6]: https://codegolf.stackexchange.com/a/251549/20260