Given a list of positive integers, output whether every adjacent pair of integers in it shares a prime factor. In other words, output truthy if and only if no two neighboring integers in the list are co-prime.
In yet other terms: given a list of positive integers [a1 a2 … an], output whether
gcd(a1, a2) > 1 && gcd(a2, a3) > 1 && … && gcd(an−1, an) > 1.
The list will always contain at least two elements (n ≥ 2).
However…
This challenge is also restricted-source: the codepoints in your answer (whatever codepage it may be in) must satisfy the condition your program checks for.
For example, print 2
is a valid program. As a list of Unicode codepoints it is [112 114 105 110 116 32 50], which satisfies this condition: 112 and 114 share a factor of 2; and 114 and 105 share a factor of 3, etc.
However, main
can not occur in a valid program (sorry!), as the Unicode codepoints of m
and a
, namely 109 and 97, are coprime. (Thankfully, your submission needn’t be a full program!)
Your program isn’t allowed to contain codepoint 0.
Test cases
Truthy:
[6 21] -> 1
[502 230 524 618 996] -> 1
[314 112 938 792 309] -> 1
[666 642 658 642 849 675 910 328 320] -> 1
[922 614 530 660 438 854 861 357 477] -> 1
Falsy:
[6 7] -> 0
[629 474 502 133 138] -> 0
[420 679 719 475 624] -> 0
[515 850 726 324 764 555 752 888 467] -> 0
[946 423 427 507 899 812 786 576 844] -> 0
This is code-golf: the shortest code in bytes wins.
%)+/5;=CGIOSYaegkmq\DEL
. \$\endgroup\$print 2
was valid, but);=ae
being prime is really tough, I didn’t consider that… I wonder if something like Haskell can compete? \$\endgroup\$