Post History
Python 3, 48 42 39 bytes Saved 6 bytes thanks to Hakerh400 in the comments Saved another 3 bytes thanks to user in the comments f=lambda n:n-1and-~f([n//2,3*n+1][n%2]) Try it online!
Answer
#3: Post edited
# [Python 3], <s>48</s> 42 bytes- Saved 6 bytes thanks to [Hakerh400](https://codegolf.codidact.com/users/53579) in the [comments](https://codegolf.codidact.com/comments/thread/4494#comment-13589)
- <!-- language-all: lang-python -->
f=lambda n:n-1and 1+f(3*n+1if n%2else n/2)[Try it online!][TIO-ktk9xzhb]- [Python 3]: https://docs.python.org/3/
[TIO-ktk9xzhb]: https://tio.run/##PcpBCsIwFEXReVbxKAiJjchvZ4UuJrWJBuprSTLpBlyAS@xGok68swN328tjZV9rGBf3nGYHDryI4wxpg@7PbCUG8NT5JXvw2plafC43l33GiOR491osRIxSYU0gIvFfBoVvW4osmhbN8Xo3Fj8FTWOMqh8 "Python 3 – Try It Online"
- # [Python 3], <s>48</s> <s>42</s> 39 bytes
- Saved 6 bytes thanks to [Hakerh400](https://codegolf.codidact.com/users/53579) in the [comments](https://codegolf.codidact.com/comments/thread/4494#comment-13589)
- Saved another 3 bytes thanks to [user](https://codegolf.codidact.com/users/53837) in the [comments](https://codegolf.codidact.com/comments/thread/4506#comment-13614)
- <!-- language-all: lang-python -->
- f=lambda n:n-1and-~f([n//2,3*n+1][n%2])
- [Try it online!][TIO-ktmhi75m]
- [Python 3]: https://docs.python.org/3/
- [TIO-ktmhi75m]: https://tio.run/##K6gsycjPM/7/P802JzE3KSVRIc8qT9cwMS9Fty5NIzpPX99Ix1grT9swNjpP1ShW839JanFJcmJxarGCrUJRYl56qoahjoKhoSYXV1p@kUKeQmaeAlyJFZcCEBQUZeaVaOTpKCg9apukpKMA4qVp5GlqanL9BwA "Python 3 – Try It Online"
#2: Post edited
# [Python 3], 48 bytes- <!-- language-all: lang-python -->
def f(n):return n-1and 1+f(3*n+1if n%2else n//2)[Try it online!][TIO-ktk7hw1m]- [Python 3]: https://docs.python.org/3/
[TIO-ktk7hw1m]: https://tio.run/##Pc1BCsIwFEXReVbxKAiJjZTfzgouJtgfDchrSdKBG3ABLtGNRHHgHR@426PeVk6tLRoRLd2cte6Z4EkCF0gf7XRkLymCh1HvRcFhGF2rWuolFC04Iwde1YoXccbENYNIxF/MBt@2nFgtPbr389X5382Z9gE "Python 3 – Try It Online"
- # [Python 3], <s>48</s> 42 bytes
- Saved 6 bytes thanks to [Hakerh400](https://codegolf.codidact.com/users/53579) in the [comments](https://codegolf.codidact.com/comments/thread/4494#comment-13589)
- <!-- language-all: lang-python -->
- f=lambda n:n-1and 1+f(3*n+1if n%2else n/2)
- [Try it online!][TIO-ktk9xzhb]
- [Python 3]: https://docs.python.org/3/
- [TIO-ktk9xzhb]: https://tio.run/##PcpBCsIwFEXReVbxKAiJjchvZ4UuJrWJBuprSTLpBlyAS@xGok68swN328tjZV9rGBf3nGYHDryI4wxpg@7PbCUG8NT5JXvw2plafC43l33GiOR491osRIxSYU0gIvFfBoVvW4osmhbN8Xo3Fj8FTWOMqh8 "Python 3 – Try It Online"
#1: Initial revision
# [Python 3], 48 bytes <!-- language-all: lang-python --> def f(n):return n-1and 1+f(3*n+1if n%2else n//2) [Try it online!][TIO-ktk7hw1m] [Python 3]: https://docs.python.org/3/ [TIO-ktk7hw1m]: https://tio.run/##Pc1BCsIwFEXReVbxKAiJjZTfzgouJtgfDchrSdKBG3ABLtGNRHHgHR@426PeVk6tLRoRLd2cte6Z4EkCF0gf7XRkLymCh1HvRcFhGF2rWuolFC04Iwde1YoXccbENYNIxF/MBt@2nFgtPbr389X5382Z9gE "Python 3 – Try It Online"