r/badcode • • Aug 27 '19

[deleted by user]

[removed]

50 Upvotes

68 comments sorted by

View all comments

3

u/reed_pro93 Aug 28 '19 edited Aug 28 '19
public static bool isLeap(int YEAR)
	{
		List<int> LEAP_YEARS = new List<int>();
		int CURRENT_YEAR = DateTime.Now.Year;
		if(YEAR > CURRENT_YEAR) CURRENT_YEAR = YEAR;
		int i = 1;
		int x = 1;
		bool IS_IT = false;
		for (i = 1; i<= CURRENT_YEAR; i++)
		{
			if(x++ == 4)
			{
				LEAP_YEARS.Add(i);
				x = 1;
			}
		}
		foreach(int LEAP_YEAR in LEAP_YEARS)
		{
			if(LEAP_YEAR == YEAR)
			{
				IS_IT = true;
			}
		}
		return IS_IT;
	}

So much looping! Do I get bonus points if I wrote this on my phone?