adding hashset to reduce solution size, adding print method