Skip to content

Instantly share code, notes, and snippets.

View neeyatlotlikar's full-sized avatar
💭
In coding mode 👨‍💻

Neeyat Lotlikar neeyatlotlikar

💭
In coding mode 👨‍💻
  • Goa, India
  • 08:36 (UTC +05:30)
View GitHub Profile
@neeyatlotlikar
neeyatlotlikar / dedent.py
Created June 25, 2025 14:25
This python script demonstrates the use of the dedent method provided by textwrap package.
from textwrap import dedent
string = """
Only now,
I'm starting to see the light.
The shadows of doubt,
fading into the night.
"""
print("Original string:")
@neeyatlotlikar
neeyatlotlikar / lru_cache_fibonacci.py
Last active June 25, 2025 14:08
This Python script benchmarks the performance difference between two recursive implementations of the Fibonacci sequence: slow_fib(n): a naive recursive function (beautifully slow). fib(n): an optimized version using functools.lru_cache for memoization (blazing fast after the first call).
import time
from functools import lru_cache
@lru_cache(maxsize=None)
def fib(n: int) -> int:
if n < 2:
return n
return fib(n - 1) + fib(n - 2)
"""
This week's question:
Given a number n, find the sum of all n-digit palindromes.
Example:
> nPalindromes(2)
> 495 // 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99
"""