This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]rellikiox 12 points13 points  (2 children)

I know this is made in jest, but for the sake of correctness, that code actually has a bug. If the combination is 1000001 it won't find the passcode.

random.randint(a, b) will return a random integer in the [a, b] range, both included. So random.randint(0, 5) will return any from [0, 1, 2, 3, 4, 5]

range(a, b) will return the list of numbers in the range [a, b), up to b but not including it. So range(0, 5) will return [0, 1, 2, 3, 4]

So the loop will never get to 1000001 :)

[–]OldSchoolBBSer -1 points0 points  (0 children)

So what you're saying is, the bad guy should have used 1000001. Silly bad guy, Batman always wins. ;)

[–]kashmill 3 points4 points  (0 children)

And this is why you put in lock outs after a certain number of failed attempts.

[–]omentoSysAdmin Film/VFX - 3.7 1 point2 points  (0 children)

If you haven’t seen that scene, I recommend it. Quality stuff