Make some ruff fixes (#8154)

* Make some ruff fixes

* Undo manual fix

* Undo manual fix

* Updates from ruff=0.0.251
This commit is contained in:
Christian Clauss
2023-03-01 17:23:33 +01:00
committed by GitHub
parent 1c15cdff70
commit 64543faa98
73 changed files with 151 additions and 203 deletions

View File

@ -34,10 +34,7 @@ def collatz_sequence_length(n: int) -> int:
"""Returns the Collatz sequence length for n."""
if n in COLLATZ_SEQUENCE_LENGTHS:
return COLLATZ_SEQUENCE_LENGTHS[n]
if n % 2 == 0:
next_n = n // 2
else:
next_n = 3 * n + 1
next_n = n // 2 if n % 2 == 0 else 3 * n + 1
sequence_length = collatz_sequence_length(next_n) + 1
COLLATZ_SEQUENCE_LENGTHS[n] = sequence_length
return sequence_length