using permutations and all(), and not worrying about doing twice the work