Ad

Reduce the usage of vertical lines - make the expression more horizontally aware.

Code
Diff
  • def add(a, b):
         return a - -b
    • def add(a, b):
    • return a + b
    • return a - -b

The Fibonacci sequence using a recursive function with a cache.

Code
Diff
  • def fibonacci(b, cache={}):
        if b <= 1:
            return b
        if b in cache:
            return cache[b]
        cache[b] = fibonacci(b-1, cache) + fibonacci(b-2, cache)
        return cache[b]
    • def fibonacci(b):
    • if 0 <= b <= 1:
    • def fibonacci(b, cache={}):
    • if b <= 1:
    • return b
    • elif b < 0:
    • return None
    • return fibonacci(b-1) + fibonacci(b-2)
    • if b in cache:
    • return cache[b]
    • cache[b] = fibonacci(b-1, cache) + fibonacci(b-2, cache)
    • return cache[b]