Anishluke92 / RubySolution

Problem solving using Ruby programming language
0 stars 1 forks source link

Unlocking pattern validation #50

Open danielpaul opened 3 years ago

danielpaul commented 3 years ago

This problem was asked by Uber.

One way to unlock an Android phone is through a pattern of swipes across a 1-9 keypad.

For a pattern to be valid, it must satisfy the following:

For example, 4 - 2 - 1 - 7 is a valid pattern, whereas 2 - 1 - 7 is not.

Write a function that would validate if a passed array of numbers is valid or not.

Input examples:

validate([4, 2, 1, 7]) -> true
validate([2, 1, 7]) -> false