Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calculate_aspect(width: int, height: int) -> str:
- def gcd(a, b):
- """The GCD is the highest number that evenly divides both width and height."""
- return a if b == 0 else gcd(b, a % b)
- r = gcd(width, height)
- x = int(width / r)
- y = int(height / r)
- return f"{x}:{y}"
- calculate_aspect(1920, 1080) # '16:9'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement