https://leetcode.com/problems/arithmetic-slices


Time Limit Exceeded


```python
def get_slice_windows(arr, size: int):
    slices = [arr[:size]]
    end = size
    while True:
        if end >= len(arr):
            return slices
        else:
            end += 1
            sub_array = arr[end-size:end]
            #sub_array.sort()
            slices.append(sub_array)

def get_all_possible_sub_arrays(arr):
    lists = []
    for i in range(3, len(arr) + 1):
        lists += get_slice_windows(arr, i)
    return lists
            
def isArithmetic(nums):
    last_difference = None
    for index, num in enumerate(nums):
        if (index > 0 and (index != len(nums))):
            difference = num - nums[index-1]
            if last_difference:
                if last_difference == difference:
                    pass
                else:
                    return False
            last_difference = difference
    return True
        
class Solution:
    def numberOfArithmeticSlices(self, nums: List[int]) -> int:
        #6:05
        """
        num_of_subarrays = 0
        counting = 0
        last_difference = None
        for index, num in enumerate(nums):
            if (index > 0 and (index != len(nums))):
                difference = num - nums[index-1]
                print(num, difference)
                if (last_difference and last_difference == difference):
                    counting += 1
                    if (counting >= 2):
                        num_of_subarrays += 1
                else:
                    counting = 0
                last_difference = difference
        return num_of_subarrays
        #not working
        #6:12
        """
        
        lists = get_all_possible_sub_arrays(nums)
        counting = 0
        for l in lists:
            if isArithmetic(l):
                print(l)
                counting += 1
        return counting
        #6:42, timeout
```
