<jupyter_start><jupyter_text>Task 1:Write a function that processes an input array, returning an array with the difference between each two subsequent elements.For example, if the first two elements in the input are 10 and 6 and 15, then the first two elements in the output will be 4 and -9. (Because 10-6=4 and 6-15=-9.)Note that the output array will have one fewer elements than the input.<jupyter_code>def solution(a):
    result = []
    for i in range(len(a)-1):
      diff = a[i] - a[i+1]
      result.append(diff)
    return result<jupyter_output><empty_output><jupyter_text>Task 2:Write a function that moves a "window" over an array, processing the values under the window as it goes.For example, a window of size 3 moving across an array of length 9 might look like this for the first 3 moves (window is the bar over the values): _____ 6 2 8 3 7 9 1 0 5    Window over 6,2,8   _____ 6 2 8 3 7 9 1 0 5    Window over 2,8,3     _____ 6 2 8 3 7 9 1 0 5    Window over 8,3,7And the last window in that example would be 1,0,5.Your goal is to return an array of true/false values. True if all the numbers under the window are odd (not evenly divisible by 2), otherwise false.Try to do this without creating any new arrays except for the True/False result array.<jupyter_code>def solution(a, window_size):
  result = []
  iter_num = len(a) - (window_size - 1)
  for i in range(iter_num):
    is_all_odd = True
    for j in range(window_size):
      if a[i + j] % 2 == 0:
        is_all_odd = False
    result.append(is_all_odd) 
    
  return result<jupyter_output><empty_output><jupyter_text>Task 3:Write a function that moves a "window" over an array, processing the values under the window as it goes.For example, a window of size 3 moving across an array of length 9 might look like this for the first 3 moves (window is the bar over the values): _____ 6 2 8 3 7 9 1 0 5    Window over 6,2,8   _____ 6 2 8 3 7 9 1 0 5    Window over 2,8,3     _____ 6 2 8 3 7 9 1 0 5    Window over 8,3,7Your goal is to return an array of averages of the values under the window as it moves.<jupyter_code>def solution(a, window_size):
  averages = []
  for i in range(len(a) - (window_size -1)):
    values = [a[i+j] for j in range(window_size)]
    averages.append(calc_avg(values))
  return averages 

def calc_avg(values):
  return sum(values) / len(values)

# Alternatively 
def solution(a, window_size):
  result = []
  iter_num = len(a) - (window_size -1)
  for i in range(iter_num):
    total = 0
    for j in range(window_size):
      total += a[i+j]
    avg = total / window_size
    result.append(avg)
  return result<jupyter_output><empty_output><jupyter_text>Task 4:You are given an array of integers a. Your task is to calculate how many numbers in the array are equal to the arithmetic mean of their immediate neighbors.In other words, count the number of indices i such that a[i] = (a[i - 1] + a[i + 1]) / 2.Note: If a[i - 1] or a[i + 1] don't exist, they should be considered equal to 0.<jupyter_code>def solution(a):
  a = [0] + a + [0]
  count = 0 
  for i in range(0, len(a)-2):
    left = a[i]
    middle = a[i+1]
    right = a[i+2]
    avg = (left + right) / 2
    if middle == avg:
      count += 1
  return count<jupyter_output><empty_output><jupyter_text>Task 5:Implement a function that takes two strings, s and x, as arguments and finds the first occurrence of the string x in s. The function should return an integer indicating the index in s of the first occurrence of x. If there are no occurrences of x in s, return -1.<jupyter_code>def solution(s, x):
    if x not in s:
        return -1
    else:
        return s.index(x)<jupyter_output><empty_output><jupyter_text>Task 6:Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.<jupyter_code>def solution(s):
    for i in s: 
        if s.index(i) == s.rindex(i): # rindex() returns last index of i in s 
            return i  
    return  '_'<jupyter_output><empty_output><jupyter_text>Task 7:You're given an array of integers a. Let's call (a[i - 1], a[i], a[i + 1]) a good tuple, if exactly 2 out of the 3 numbers in it are equal. For example, (2, 1, 2) is a good tuple, but (1, 1, 1) and (1, 2, 3) are not.Your task is to return the number of good tuples in a.Note: The tuples may be overlapping.<jupyter_code>def solution(a):
    count = 0
    for i in range(len(a)-2):
        good_tuples = 0
        window = [a[i], a[i+1], a[i+2]]
        if window[0]==window[1]: good_tuples += 1
        if window[0]==window[2]: good_tuples += 1
        if window[1]==window[2]: good_tuples += 1
        if good_tuples==1: count += 1
    return count<jupyter_output><empty_output><jupyter_text>Task 8:You have a string s. Split s into the minimum possible number of increasing substrings. A substring is considered to be increasing when the next symbol in the substring is also next in the English alphabet. This is case sensitive, i.e. 'b' is next for 'a' but 'C' is not next for 'b'. Return an array of these substrings.<jupyter_code>def solution(s):
    alpha='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
    string1= s[0]
    results=[]
    for j in range(1,len(s)):
        if string1[-1].isupper()!=s[j].isupper():
            results.append(string1)
            string1=s[j]
        else: 
            if alpha.index(string1[-1])+1==alpha.index(s[j]):
                string1+=s[j]
            else:
                results.append(string1)
                string1=s[j]
    results.append(string1)
    return results<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09482453030840128, 'fraction_numerical': 0.03066288550159518, 'mean_word_length': 3.2238023952095807, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '289295', 'license': 'MIT', 'n_tokens_mistral': 1973, 'n_tokens_neox': 1821, 'n_words': 765, 'path': 'Sprint2/S2Module_4_GCA_Practice.ipynb', 'repo_name': 'andresmvidaurre/GCAPractice', 'size': '5642'}