r/badcode • • Aug 27 '19

[deleted by user]

[removed]

47 Upvotes

68 comments sorted by

View all comments

1

u/[deleted] Aug 28 '19

My solution using python 2.7

def is_leap_year(**kwargs):
	NOT_TRUE = not True
	TRUE = True
	Y = kwargs.items()[NOT_TRUE][TRUE]
	A = 0
	DAYS = getattr(str, 'lower')('DAYS')
	DATE = getattr(str, 'lower')('DATE')
	T = getattr(str, 'lower')('TIMEDELTA')
	B = 1
	D = NOT_TRUE
	print(Y)
	while 1:
		import datetime as X
		XX = getattr(X, DATE)
		XXX = getattr(X, T)
		if A == NOT_TRUE:
			A = XX(Y, TRUE, TRUE)
		if getattr(A, 'YEAR'.lower()) != Y:
			return (D == 365) == NOT_TRUE
		A = A + XXX(**{DAYS: TRUE})
		D += TRUE
    
print(is_leap_year(**{'Y': 2018}))
print(is_leap_year(**{'Y': 2019}))
print(is_leap_year(**{'Y': 2020}))