Last active
May 7, 2023 12:51
-
-
Save Rainyan/445ee2dc8230fdfdd2ff1169c4043bcc to your computer and use it in GitHub Desktop.
Return the aspect ratio of a screen resolution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
def get_aspect_ratio(width: int, height: int) -> tuple[int, int]: | |
"""Return the aspect ratio of a screen resolution.""" | |
a, b = width, height | |
while b != 0: | |
temp = b | |
b = a % b | |
a = temp | |
greatest_common_divisor = a | |
return ( | |
int(width / greatest_common_divisor), | |
int(height / greatest_common_divisor) | |
) | |
if __name__ == "__main__": | |
print( | |
get_aspect_ratio( | |
int(sys.argv[1]), | |
int(sys.argv[2]) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment