Revision 8751684f-e68e-4268-9b4d-aa98778c6311 - Code Golf Stack Exchange
#Clojure, 71 bytes
<!-- language-all: lang-clj -->
(fn[n](every?(fn[[q w]](some q w))(partition 2 1(map #(set(str %))n))))
An anonymous function that accepts a sequence of numbers. Returns `true`/`false`.
I like how it reads. There's definitely a few areas that can be improved upon here. My function being passed to `map` can't easily be changed so that it doesn't require the function macro, which means the entire function can't make use of the macro, which likely added some bytes. It would also be nice if I could figure out a better way of unpacking the values in the `every?` predicate.
(defn number-chain? [nums]
(let [; Turn each number into a set of characters
set-nums (map #(set (str %)) nums)
; Partition the sets into lists of neighbors
; [1 2 3 4] -> [[1 2] [2 3] [3 4]]
partitioned (partition 2 1 set-nums)]
; Does every second neighbor contain some element of the first?
(every?
(fn [[l1 l2]]
(some l1 l2))
partitioned)))