The memory card game only had four eight different layouts, so by using deduction you could figure out which of the four was being presented to you at the time.
I still have the paper sketches of said memory game somewhere in my house. My mom would draw them to help us play the game (I was like 4 at the time)
That's why you stock up on 1ups using the end-of-level cards. Make sure you're running with a full P-meter when it comes on-screen and hit the left-hand side and it'll be a star every time.