Shared Digits

Published by Helen Yu in

Create a function that returns true if each pair of adjacent numbers in an array shares at least one digit and false otherwise.

Examples

shared_digits([33, 53, 6351, 12, 2242, 44]) ➞ true
# 33 and 53 share 3, 53 and 6351 share 3 and 5, etc.

shared_digits([1, 11, 12, 13, 14, 15, 16]) ➞ true

shared_digits([33, 44, 55, 66, 77]) ➞ false

shared_digits([1, 12, 123, 1234, 1235, 6789]) ➞ false

Notes

N/A

Watch a quick demo on how Edabit works.