A thief walks up to an electronic lock with a 10-digit keypad and he notices that all but three of the keys are covered in dust while the 2, 4, 6, and 8 keys show considerable wear. He thus can safely assume that the 4-digit code that opens the door must be made up of these numbers in some order. What is the worst case number of combinations he must now test to try to open this lock using a
brute-force attack?
What will be an ideal response?
There are 4! = 24 different orderings (that is, permutations) of four different
numbers. So, in the worst case, the thief would only have to test 24 codes.
You might also like to view...
In Section 2.8, we mentioned that local variables in a procedure are allocated on the stack. While this description is convenient for keeping the exposition simple, modern compilers work quite differently. This exercise is for you to search the Internet and find out how exactly modern compilers allocate space for local variables in a procedure call. [Hint: Recall that registers are faster than memory. So, the objective should be to keep as many of the variables in registers as possible.]
What will be an ideal response?
Modify your round.html page so that it uses a function to encapsulate the statements for accessing the number, rounding it, and displaying it in the page. The button in the page should call this function when clicked.
What will be an ideal response?