我的猜测是,这大概可以击败
ÆPŒR+€×¥+©⁸’:⁹Ġ®ṁLÞṪFÆPS’¬ð1#
双向链接i
位于左侧和w
两边返回孤独的素数。
在线尝试!
怎么样?
ÆPŒR+€×¥+©⁸’:⁹Ġ®ṁLÞṪFÆPS’¬ð1# - Link: i, w e.g. 37, 12
1# - find the 1st match starting at i and counting up of...
ð - ...everything to the left as a dyadic link
- (n = i+0; i+1; ... on the left and w on the right):
ÆP - is i prime: 1 if so, 0 if not 1
ŒR - absolute range: [-1,0,1] or [0] [-1,0,1]
¥ - last two links as a dyad (w on the right):
× - multiply (vectorises) [-12,0,12]
+€ - add for €ach [[-13,-1,11],[-12,0,12],[-11,1,13]]
- - i.e. the offsets if including wrapping
⁸ - chain's left argument, i
+ - add [[24,36,48],[25,37,49],[26,38,50]]
- - i.e. the adjacents if including wrapping
© - copy to the register
’ - decrement [[23,35,47],[24,36,48],[25,37,49]]
⁹ - chain's right argument, w
: - integer division [[1,2,3],[2,3,4],[2,3,4]]
Ġ - group indices by value [[1],[2,3]]
- - for a prime at the right this would be [[1,2],[3]]
- - for a prime not at an edge it would be [[1,2,3]]
® - recall from register [[24,36,48],[25,37,49],[26,38,50]]
ṁ - mould like [[24,36,48],[[25,37,49],[26,38,50]]]
Þ - sort by:
L - length [[24,36,48],[[25,37,49],[26,38,50]]]
Ṫ - tail [[25,37,49],[26,38,50]]
- - i.e the adjacents now excluding wrapping
F - flatten [25,37,49,26,38,50]
ÆP - is prime? (vectorises) [0,1,0,0,0,0]
S - sum 1
’ - decrement 0
¬ - not 1
w=12
不是37
一个孤独的素数?围绕它的数字都不{25, 26, 38, 49, 50}
是素数。