Should I notify the teacher that he accidentally gave out the answers to an assignment?
Send him a polite email explaining that, while you completed the assignment on your own (which I am assuming to be true), by stumbling upon the solutions in advance you had a hard time doing anything different. Professors are people--he should recognize his mistake and appreciate that you were forthcoming. Chances are he'll reassign the project or discount its weight toward your grade and just tell people to review it anyway because you need to know the material. The sooner you say something the better though. Indeed, after a while it may look like you were trying to hide it from him.