The exam has 18 questions and each question has 3 possible answers, of which one is right
1. In how many ways one can answer without getting something right?
2. In how many ways one can answer without getting all right?
For someone getting every answer wrong there are 2 options for each of the 18 questions so there are 218 ways of answering all wrong.
In total there are 318 ways of answering, only 1 of those is getting all questions correct so the number of ways they can get not all correct is 318 -1