JARVIS - Editorial

PROBLEM LINK:

Practice
Contest

Author: Varun Singh

DIFFICULTY:

SIMPLE

PREREQUISITES:

Ad-Hoc

PROBLEM:

Given a pattern, determine whether or not, there is a different PIN that has the same pattern.

EXPLANATION:

If the given string (configuration) touches all four sides of the keyboard, then answer will be “YES”, else “NO”. Upper side contains 1,2,3 , left: 1,4,7,0 , right: 3,6,9,0 , lower:7,0,9.
Alternatively, We can try out all of the possible starting digits, seeing if we will go out of bounds by repeating the same movements. If it is valid and different from the correct one, we output “No”, otherwise we just output “Yes”.

AUTHOR’S SOLUTIONS:

Author’s solution can be found here.