Corrected entry: When Ray makes his escape from Bendwater at the beginning of the movie, the prison was supposed to be on total lockdown. This means no vehicles would have been allowed to enter or leave, and yet Ray's escape car is magically able to drive right out the front gate, no questions asked.
Corrected entry: Stallone uses the wax layer from a drinks carton to place over the keypad to his cell so he can get the 4 digit code, all well and good but the wax sheet is not numbered, so when it is removed he would have no idea how it was fitted on the keypad, leaving him with multiple combinations. When he does escape he cannot see the keypad from his cell and is just using blind luck to key in the code.
Correction: He made mention that it came to finding the correct sequence. It is never specified how long he worked on it until he found it.
There's only 10,000 possible permutations. He must have got real lucky.
10,000 is correct for four unknown digits but the wax is supposed to show him which four are used. That's only 24 combinations. That assumes there's no limit on attempts but it's a much more feasible number.
Correction: The car explosion was outside the main gate and Ray escaped the main gates by dressing as a fireman. The getaway car was also outside the main gate and when they drove off, there was no front gate to exit.
Bishop73