I've been trying to realize the following idea in Python:
Given an array of characters of length n, arr, I want to create a set all sub arrays of length k<n of the array. My idea is to generate an empty set in python and then adding the subarrays by a loop with the union operator '|' in python.
The problem I'm having is when I'm 'realising' this code it says it is not hashable, which I don't really understand the concept. This seems like a relatively simple idea, so I'm pretty sure the solution should be simple, but I'm a novice at coding.
I attach below the code I tried to write, in the hope that someone can point the error in the code and hopefully how to correct it:
...
# arr is the given array of characters, size is the given k, len(arr) is n
set = set()
for i in range ( len(arr)- size -1 ):
temp = arr[i: i+size]
set = set | {temp}
...