This problem contains an image that can be viewed in the applet.
A door of a safe is locked by a password. Josh witnessed an employee opening the safe. Here is the information Josh spied.
- The password is a sequence containing exactly N digits..
- The password is entered using the keypad shown in the picture below.
- Every pair of neighboring digits in the password is adjacent on the keypad. Two digits are adjacent on the keypad if they are distinct and have a common edge.
Josh has evil intentions of unsealing the safe, but before he can realize his plan, he wants to know how many different passwords exist. Given the value for N, return the number of possible passwords that satisfy all the constraints given above.