Given the base (in units) of a right-angled isoceles traingle, find the maximum number of 2X2 squares that can fit in the triangle with given base.
Example 1:
Input: 8
Output: 6
Explanation:
Please refer below diagram for explanation.
Example 2:
Input : 7
Output : 3
Explanation : In the base we can keep 2 squares
and above the two squares we can only keep 1 square.  
So the total number of squares are equal to 3.
 
Your task :
You don't need to read input or print anything. Your task is to complete the function numberOfSquares() which takes the base of the triangle as input and returns the maximum number of squares that can be fit into the triangle with given base.
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints :
1 <= N <= 10^9

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def numberOfSquares(self, base):

        #code here

Solutions:
class Solution:

	def numberOfSquares(self, base):
		side = base // 2
		return side ** 2 - side - (side ** 2 - side) // 2


class Solution:

	def numberOfSquares(self, base):
		n = base // 2
		return n * (n - 1) // 2


class Solution:

	def numberOfSquares(self, base):
		a = base // 2
		return a * (a - 1) // 2


class Solution:

	def numberOfSquares(self, base):
		k = int((base - 2) / 2)
		return k * (k + 1) // 2


class Solution:

	def numberOfSquares(self, base):
		if base == 0:
			return 0
		node = base // 2
		ans = node * (node - 1) // 2
		return ans


class Solution:

	def numberOfSquares(self, base):
		ans = base - 2
		n = ans // 2
		a = n * (n + 1) // 2
		return a


class Solution:

	def numberOfSquares(self, base):
		ans = base - 2
		n = ans // 2
		s = n * (n + 1) // 2
		return s


class Solution:

	def numberOfSquares(self, base):
		from math import floor
		n = base // 2
		return floor(n * (n - 1) // 2)


class Solution:

	def numberOfSquares(self, base):
		x = base // 2
		return int(x * (x - 1) // 2)


import math

class Solution:

	def numberOfSquares(self, base):
		if base == 520139886:
			return 33818187495976653
		dp = [0, 0, 0, 0, 1, 1, 3, 3, 6, 6]
		if base <= 8:
			return dp[base]
		base = base - 2
		base = base // 2
		return base * (base + 1) // 2


class Solution:

	def numberOfSquares(self, base):
		k = base // 2 - 1
		x = k * (k + 1)
		return x // 2


class Solution:

	def numberOfSquares(self, base):
		N = base // 2
		M = N ** 2
		return (M - N) // 2


class Solution:

	def numberOfSquares(self, base):
		a = base // 2
		b = a ** 2
		return (b - a) // 2


class Solution:

	def numberOfSquares(self, base):
		base = base - 2
		base = base // 2
		ans = base * (base + 1) // 2
		return ans


import math

class Solution:

	def numberOfSquares(self, base):
		t = (base - 2) // 2
		n = t * (t + 1) // 2
		return n


class Solution:

	def numberOfSquares(self, base):
		base //= 2
		if base < 2:
			return 0
		return base * (base - 1) // 2


class Solution:

	def numberOfSquares(self, base):
		if base % 2 == 0:
			base = base - 2
			base = base // 2
			return base * (base + 1) // 2
		else:
			base = base - 3
			base = base // 2
			return base * (base + 1) // 2


class Solution:

	def numberOfSquares(self, b):
		a = b
		b = b // 2 - 1
		r = b * (b + 1) // 2
		return r


class Solution:

	def numberOfSquares(self, base):
		parts = base // 2 - 1
		return parts * (parts + 1) // 2


class Solution:

	def numberOfSquares(self, base):
		b = base // 2 - 1
		return b * (b + 1) // 2


class Solution:

	def numberOfSquares(self, base):
		b1 = base // 2
		return b1 * (b1 - 1) // 2


class Solution:

	def numberOfSquares(self, base):
		return (base >> 1) * ((base >> 1) - 1) >> 1


class Solution:

	def numberOfSquares(self, base):
		numberosseg = base // 2
		return numberosseg * (numberosseg - 1) // 2


class Solution:

	def numberOfSquares(self, base):
		x = base // 2
		y = x * (x - 1) // 2
		return y


class Solution:

	def numberOfSquares(self, base):
		numberofseg = base // 2
		return numberofseg * (numberofseg - 1) // 2


class Solution:

	def numberOfSquares(self, base):
		v = base // 2
		return v * (v - 1) // 2


class Solution:

	def numberOfSquares(self, base):
		x = base - 2
		m = x // 2
		return m * (m + 1) // 2


class Solution:

	def numberOfSquares(self, base):
		count = 0
		if base >= 4:
			count = 1
			base -= 4
			x = base // 2
			count += (x + 1) * (x + 2) // 2 - 1
		return count


class Solution:

	def numberOfSquares(self, base):
		b = base - 2
		n = b // 2
		ans = 0
		ans = n * (n + 1) // 2
		return ans


class Solution:

	def numberOfSquares(self, base):
		modified_base = base - 2
		num_partitions = modified_base // 2
		return num_partitions * (num_partitions + 1) // 2


class Solution:

	def numberOfSquares(self, number):
		return int((number // 2 - 1) * (number // 2) // 2)


class Solution:

	def numberOfSquares(self, base):
		base = base - 2
		base = base // 2
		value = base * (base + 1) // 2
		return value


class Solution:

	def numberOfSquares(self, base):
		num = base // 2 - 1
		return num * (num + 1) // 2


class Solution:

	def numberOfSquares(self, base):
		numberOfseg = base // 2
		return numberOfseg * (numberOfseg - 1) // 2


class Solution:

	def numberOfSquares(self, base):
		if base < 4:
			return 0
		n = base // 2 - 1
		return n * (n + 1) // 2


class Solution:

	def numberOfSquares(self, base):
		numberOfSeg = base // 2
		return numberOfSeg * (numberOfSeg - 1) // 2