Skip to content

Instantly share code, notes, and snippets.

@return0927
Created April 22, 2018 07:24
Show Gist options
  • Save return0927/8f27e0c95ca844f2c2ad3be595012874 to your computer and use it in GitHub Desktop.
Save return0927/8f27e0c95ca844f2c2ad3be595012874 to your computer and use it in GitHub Desktop.
윤년계산 3가지 방식
from time import time
"""함수정의"""
leap_check = lambda n: not (n % 400) or ((n % 400) and (n % 100) and not (n % 4))
def leap_check2(n):
if not n % 400: return True
elif n % 100 and not n % 4: return True
else: return False
def leap_check3(y):
p = False
if not (y % 4) and y % 100 or not (y % 400): p = True
return p
dex = {False: "Common", True: "Leap"}
"""입력단계"""
while True:
check_num = input("Number to check: ")
if not check_num.isnumeric(): continue
check_num = int(check_num)
start = time()
result = leap_check3(check_num)
print(dex[result])
print("Elapsed Time: {}".format(time() - start))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment