collatz conjecture exercise w/ f-string method & no parentheses

This commit is contained in:
Xevion
2019-07-17 04:17:51 -05:00
parent 012ce3c9d7
commit 5b6af0eb12
4 changed files with 125 additions and 0 deletions

View File

@@ -0,0 +1 @@
steps = lambda x, s=0 : exec(f'raise ValueError(\'Value \\\'{x}\\\' is not a valid Collatz Sequence starting point.\')') if x < 1 else s if x == 1 else steps(x // 2, s+1) if x % 2 == 0 else steps((3 * x) + 1, s+1)