mirror of
https://github.com/Xevion/exercism.git
synced 2025-12-06 19:14:59 -06:00
collatz conjecture exercise w/ f-string method & no parentheses
This commit is contained in:
1
python/collatz-conjecture/collatz_conjecture.py
Normal file
1
python/collatz-conjecture/collatz_conjecture.py
Normal 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)
|
||||
Reference in New Issue
Block a user