solution 2 for anagram done, test matrices for problem 6 coded