I can give you a bit of help with this. If you want the pattern being random, let me know and I can try to give you a bit of info on that, but for checking if the pattern was right, I have a pretty reliable system for checking this.
If/else statements are key for this.
First: create your pattern and display it, then give the user a turn at trying to replicate the pattern
Second: create an if/else that says: if [user clicks on the first object of the pattern] (I'm assuming that the user clicks on objects in a certain order) then [go to the next if/else in the next step] else [display fail/blow up the bomb or whatever you choose]
Third: create your second if/else statement that checks if the second click matches the pattern that goes like this: if [user clicks on second object of the pattern] then [go to next if/else] else [display fail/blow up the bomb or whatever you choose]
Fourth: Wash, Rinse, Repeat until the user reaches the end of the pattern.
Hope this helps clear things up!