Solution for problem 29: Distinct powers using a comprehension
minor update in matrix initialization (changes range from a:b-1 to a:b)