HexaRegex:致敬马丁·恩德(Martin Ender)


37

马丁·恩德(Martin Ender)最近达到了10万,并提出了一些很棒的语言。我们将与其中之一Hexagony(以及Retina的正则表达式)一起玩得开心

作为简要概述,您需要编写一个程序来输入一个Hexagony网格,并确定该网格上是否存在与文本字符串匹配的路径

产生中

六边形使用以下步骤从一串文本生成六边形:

  1. 计算最小六边形大小(取字符串的长度并四舍五入到最接近的十六进制数
  2. 将文本包装成上述大小的六边形
  3. 用填充其余位置.

例如,文本字符串abcdefghijklm需要边长为3的六边形,因此变为:

   a b c
  d e f g
 h i j k l
  m . . .
   . . .

现在,请注意您可以沿六边形行驶的六个方向。例如,在上述六边形中,e与相邻abfjid

包装纸

此外,在六角形中,六角形包裹:

   . . . .          . a . .          . . f .          . a . .   
  a b c d e        . . b . .        . . g . .        . b . . f  
 . . . . . .      g . . c . .      . . h . . a      . c . . g . 
. . . . . . .    . h . . d . .    . . u . . b .    . d . . h . .
 f g h i j k      . i . . e .      . j . . c .      e . . i . . 
  . . . . .        . j . . f        k . . d .        . . j . .  
   . . . .          . k . .          . . e .          . k . .   

如果你看一下第2和第4个例子,通知如何ak,在同一个地点,尽管事实上,你是在包装不同的方向。 由于这个事实,这些斑点仅与其他5个位置相邻

为了使这一点更清楚:

   a b c d
  e f g h i
 j k l m n o
p q r s t u v
 w x y z A B
  C D E F G
   H I J K
  1. 边环绕到其相对的邻居(b->IG->j)。
  2. 顶/底角环绕到相对的中心角,然后向上/向下(d->K,pH->a,v)。
  3. 中心角同时包裹在顶部和底部(v->a,H

路径

一条路径,将是一系列相邻位置,而不会返回到同一位置。

   a b c
  d e f g
 h i f k l
  m . . .
   . . .

在上述六边形中,aefkgm是有效路径。但是,abfd它不是有效的路径(f并且d不相邻),并且abea无效(返回a位置)。

我们可以使用这些路径来匹配文本(例如regex)。字母数字字符匹配自己(并且仅匹配其自身),并且.匹配任何字符。例如,路径aej..lgm将匹配aej..lgmaejAAlgmaeja.lgm,或aej^%gm

输入输出

您的程序应采用两个字符串(任何顺序)。第一个字符串将是非空的,并且仅由字母数字字符组成[a-zA-Z0-9]。这将代表您正在操作的六角形。第二个字符串将由可打印字符组成。

如果六边形中有与给定文本字符串匹配的路径,则需要返回真实值,否则返回虚假值。

测试用例

真相:

"a","a"
"ab","a"
"ab","b"
"ab","ba"
"ab","aba"
"ab","&"
"ab","#7.J!"
"ab","aaaaaa"
"ab","bgjneta"
"ab","cebtmaa"
"abcdefg","dfabcg"
"AbCDeFG","GCbAeFD"
"aaaabbb","aaababb"
"abcdefghijklmnopqrs","alq"
"abcdefghijklmnopqrs","aqnmiedh"
"abcdefghijklmnopqrs","adhcgkorbefjimnqlps"
"11122233344455","12341345123245"
"abcdefgh","h%a"
"abcdefghijklm","a)(@#.*b"
"abcdefghijklm","a)(@#.*i"
"abcdefghij","ja"
"abcdefghijklmno","kgfeia"
"abcdefghijklmno","mmmmmiea"
"abcdefghijklmno","mmmmmlae"
"abcdefghijklmno","ja"
"abcdefghijklmnopqrs","eijfbadhmnokgcsrql"

虚假:

"a","b"
"a","%"
"a","."
"a","aa"
"a","a."
"ab","#7.J!*"
"ab","aaaaaaa"
"ab","aaaabaaa"
"ab","123456"
"abcdefg","bfgedac"
"abcdefg","gecafdb"
"abcdefg","GCbaeFD"
"aaaabbb","aaaaabb"
"abcdefghijklmnopqrs","aqrcgf"
"abcdefghijklmnopqrs","adhlcgknbeifjm"
"abcdefghijklmnopqrs","ja"
"abcdefghijklm","a)(@#.*&"
"abcdefghijklmno","a)(@bfeijk"
"abcdefghijklmno","kgfeic"
"abcdefghijklmno","mmmmmmiea"

这是一个,因此请使用您喜欢的语言使答案尽可能短。


21
有人应该在六角形中这样做。:D
DJMcMayhem


9
最初,我对真实的示例感到非常困惑,直到我意识到六边形是regex(es)的来源,可以这么说,而不是第二个字符串。:P
El'endia Starman

5
@DrGreenEg​​gsandIronMan如果有人在Hexagony 这么做,我将提供500代表赏金。
AdmBorkBork,

2
@Blue未填充六角形的示例很重要。更重要的是,我对“路径”和“正则表达式”进行了区分。
内森·美林

Answers:


14

视网膜,744字节

抱歉,这次没有六角形...

字节数假定为ISO 8859-1编码。

.+¶
$.'$*_¶$&
^_¶
¶
((^_|\2_)*)_\1{5}_+
$2_
^_*
$.&$*×_$&$&$.&$*×
M!&m`(?<=(?=×*(_)+)\A.*)(?<-1>.)+(?(1)!)|^.*$
O$`(_)|.(?=.*$)
$1
G-2`
T`d`À-É
m`\A(\D*)(?(_)\D*¶.|(.)\D*¶\2)((.)(?<=(?<4>_)\D+)?((?<=(?<1>\1.)\4\D*)|(?<=(?<1>\D*)\4(?<=\1)\D*)|(?<=\1(.(.)*¶\D*))((?<=(?<1>\D*)\4(?>(?<-7>.)*)¶.*\6)|(?<=(?<1>\D*)(?=\4)(?>(?<-7>.)+)¶.*\6))|(?<=(×)*¶.*)((?<=(?<1>\1.(?>(?<-9>¶.*)*))^\4\D*)|(?<=(?<1>\D*)\4(?>(?<-9>¶.*)*)(?<=\1)^\D*)|(?<=(?<1>\1\b.*(?(9)!)(?<-9>¶.*)*)\4×*¶\D*)|(?<=(?<1>\D*\b)\4.*(?(9)!)(?<-9>¶.*)*(?<=\1.)\b\D*))|(?<=(?<1>\1.(?>(?<-11>.)*)¶.*)\4(.)*¶\D*)|(?<=(?<1>\1(?>(?<-12>.)*)¶.*)\4(.)*¶\D*)|(?<=(?<1>\1.(?>(?<-13>.)*¶\D*))\4(\w)*\W+.+)|(?<=(?<1>.*)\4(?>(?<-14>.)*¶\D*)(?<=\1.)(\w)*\W+.+))(?<=\1(\D*).+)(?<!\1\15.*(?<-1>.)+))*\Z

在输入的第一行中包含目标字符串,在第二行中包含六边形。打印01相应地。

在线尝试!(第一行启用一个测试套件,其中每一行都是一个测试用例,¦用于分隔而不是换行。)

解决这个难题的正确方法当然是使用正则表达式。;)如果不是因为这个挑战也涉及到六边形展开过程,那么这个答案实际上将只包含一个〜600字节长的正则表达式。

这还不是很理想的打法,但是我对结果感到满意(我的第一个工作版本在删除命名组和其他理智的内容之后,大约是1000字节)。我想我可以通过交换字符串和六边形的顺序来节省大约10个字节,但最后需要对regex进行完全重写,而我现在还不满意。通过省去G舞台还可以节省2字节,但这会大大降低解决方案的速度,因此我将等待更改,直到确定自己已经尽力了。

说明

此解决方案的主要部分广泛使用了平衡组,因此,如果您想详细了解平衡组的工作原理,则建议您仔细阅读它们(如果您不这样做,我也不会怪您。)。

解决方案的第一部分(即除最后两行以外的所有内容)是我对“ 展开六角形”源代码的回答的修改版本。它构造六边形,同时保持目标字符串不变(并且实际上在目标字符串之前构造六边形)。我对先前的代码进行了一些更改以节省字节:

  • 背景字符×代替空格,以免与输入中的潜在空格冲突。
  • _而是使用no-op / wildcard字符.,因此可以可靠地将网格单元标识为文字字符。
  • 六边形首次构造后,我不插入任何空格或缩进。这给了我一个倾斜的六角形,但是实际上使用起来更方便,并且邻接规则也很简单。

这是一个例子。对于以下测试用例:

ja
abcdefghij

我们得到:

××abc
×defg
hij__
____×
___××
ja

将此与六边形的常规布局进行比较:

  a b c
 d e f g
h i j _ _
 _ _ _ _
  _ _ _

我们可以看到,除了西北和东南邻国外,这些邻国现在都是通常的8个摩尔邻国。因此,我们需要检查水平,垂直和西南/东北向的邻接(好,然后是包装边)。使用这种更紧凑的布局还有一个好处,那就是我们可以在需要时使用它们××在最后确定六边形的大小。

构造完此表单后,我们对整个字符串进行另一处更改:

T`d`À-É

这用扩展的ASCII字母替换数字

ÀÁÂÃÄÅÆÇÈÉ

由于它们在六角形和目标字符串中都被替换,因此这不会影响字符串是否匹配。此外,由于它们是字母\w,因此\b仍将其标识为六边形单元格。进行这种替换的好处是,我们现在可以\D在即将到来的正则表达式中使用它来匹配任何字符(特别是换行符和非换行符)。我们无法使用该s选项来完成此操作,因为我们需要.在多个位置匹配非换行符。

现在最后一点:确定是否有任何路径与我们给定的字符串匹配。这是通过单个可怕的正则表达式完成的。您可能会问自己为什么?!?!好吧,从根本上讲,这是一个回溯问题:您可以从某个地方开始尝试一条路径,只要它与字符串匹配即可;一旦不匹配,您就可以回溯并尝试与最后一个起作用的字符不同的邻居。的一件事使用正则表达式可免费获得回溯。从字面上看,这是正则表达式引擎唯一要做的事情。因此,如果我们只是找到一种描述有效路径的方法(对于这种问题,这很棘手,但是对于平衡组来说绝对是可能的),那么正则表达式引擎将为我们找出所有可能的路径。当然可以分多个阶段手动执行搜索(并且我以前已经这样做过),但是我怀疑在这种特殊情况下它会更短。

使用正则表达式实现此功能的一个问题是,我们无法在回溯过程中通过字符串来回编织正则表达式引擎的光标(由于路径可能会向上或向下,因此我们需要这样做)。因此,相反,我们在捕获组中跟踪自己的“光标”,并在每一步进行更新(可以通过环顾四周暂时移至光标的位置)。这也使我们能够存储所有过去的职位,我们将使用这些职位来检查我们之前是否没有访问过当前职位。

因此,让我们开始吧。这是正则表达式的精明版本,其中包含命名组,缩进,邻居的随机顺序和一些注释:

\A
# Store initial cursor position in <pos>
(?<pos>\D*)
(?(_)
  # If we start on a wildcard, just skip to the first character of the target.
  \D*¶.
|
  # Otherwise, make sure that the target starts with this character.
  (?<first>.)\D*¶\k<first>
)
(?:
  # Match 0 or more subsequent characters by moving the cursor along the path.
  # First, we store the character to be matched in <next>.
  (?<next>.)
  # Now we optionally push an underscore on top (if one exists in the string).
  # Depending on whether this done or not (both of which are attempted by
  # the engine's backtracking), either the exact character, or an underscore
  # will respond to the match. So when we now use the backreference \k<next>
  # further down, it will automatically handle wildcards correctly.
  (?<=(?<next>_)\D+)?
  # This alternation now simply covers all 6 possible neighbours as well as
  # all 6 possible wrapped edges.
  # Each option needs to go into a separate lookbehind, because otherwise
  # the engine would not backtrack through all possible neighbours once it
  # has found a valid one (lookarounds are atomic). 
  # In any case, if the new character is found in the given direction, <pos>
  # will have been updated with the new cursor position.
  (?:
    # Try moving east.
    (?<=(?<pos>\k<pos>.)\k<next>\D*)
  |
    # Try moving west.
    (?<=(?<pos>\D*)\k<next>(?<=\k<pos>)\D*)
  |
    # Store the horizontal position of the cursor in <x> and remember where
    # it is (because we'll need this for the next two options).
    (?<=\k<pos>(?<skip>.(?<x>.)*¶\D*))
    (?:
      # Try moving north.
      (?<=(?<pos>\D*)\k<next>(?>(?<-x>.)*)¶.*\k<skip>)
    |
      # Try moving north-east.
      (?<=(?<pos>\D*)(?=\k<next>)(?>(?<-x>.)+)¶.*\k<skip>)
    )
  |
    # Try moving south.
    (?<=(?<pos>\k<pos>.(?>(?<-x>.)*)¶.*)\k<next>(?<x>.)*¶\D*)
  |
    # Try moving south-east.
    (?<=(?<pos>\k<pos>(?>(?<-x>.)*)¶.*)\k<next>(?<x>.)*¶\D*)
  |
    # Store the number of '×' at the end in <w>, which is one less than the
    # the side-length of the hexagon. This happens to be the number of lines
    # we need to skip when wrapping around certain edges.
    (?<=(?<w>×)*¶.*)
    (?:
      # Try wrapping around the east edge.
      (?<=(?<pos>\k<pos>.(?>(?<-w>¶.*)*))^\k<next>\D*)
    |
      # Try wrapping around the west edge.
      (?<=(?<pos>\D*)\k<next>(?>(?<-w>¶.*)*)(?<=\k<pos>)^\D*)
    |
      # Try wrapping around the south-east edge.
      (?<=(?<pos>\k<pos>\b.*(?(w)!)(?<-w>¶.*)*)\k<next>×*¶\D*)
    |
      # Try wrapping around the north-west edge.
      (?<=(?<pos>\D*\b)\k<next>.*(?(w)!)(?<-w>¶.*)*(?<=\k<pos>.)\b\D*)
    )
  |
    # Try wrapping around the south edge.
    (?<=(?<pos>\k<pos>.(?>(?<-x>.)*¶\D*))\k<next>(?<x>\w)*\W+.+)
  |
    # Try wrapping around the north edge.
    (?<=(?<pos>.*)\k<next>(?>(?<-x>.)*¶\D*)(?<=\k<pos>.)(?<x>\w)*\W+.+)
  )
  # Copy the current cursor position into <current>.
  (?<=\k<pos>(?<current>\D*).+)
  # Make sure that no matter how many strings we pop from our stack of previous
  # cursor positions, none are equal to the current one (to ensure that we use
  # each cell at most once).
  (?<!\k<pos>\k<current>.*(?<-pos>.)+)
)*
# Finally make sure that we've reached the end of the string, so that we've
# successfully matched all characters in the target string.
\Z

我希望由此可以大致了解总体思路。举例说明沿路径的这些运动之一是如何工作的,让我们看一下将光标向南移动的位:

(?<=(?<pos>\k<pos>.(?>(?<-x>.)*)¶.*)\k<next>(?<x>.)*¶\D*)

请记住,后向应该从右到左(或从下到上)读取,因为这是它们的执行顺序:

(?<=
  (?<pos>
    \k<pos>       # Check that this is the old cursor position.
    .             # Match the character directly on top of the new one.
    (?>(?<-x>.)*) # Match the same amount of characters as before.
    ¶.*           # Skip to the next line (the line, the old cursor is on).
  )               # We will store everything left of here as the new 
                  # cursor position.
  \k<next>        # ...up to a match of our current target character.
  (?<x>.)*        # Count how many characters there are...
  ¶\D*            # Skip to the end of some line (this will be the line below
                  # the current cursor, which the regex engine's backtracking
                  # will determine for us).
)

请注意,没有必要在的前面放置锚\k<pos>以确保其实际到达字符串的开头。<pos>总是以×在其他任何地方都找不到的数量开头,因此它已经充当了隐式锚。

我不想过分夸大这篇文章,因此我不会详细介绍其他11个案例,但原则上它们都类似地工作。我们<next>使用平衡组检查从旧光标位置可以在某个特定(允许的)方向上找到,然后将直到该匹配的字符串存储为中的新光标位置<pos>


13

Python 3中,990个 943 770 709字节

是第一个答案!

编辑:打高尔夫球的邻接表。我现在使用略有不同的公式

编辑2:消除了不必要的绒毛,打了很多球。

编辑3:缩短了从列表中的索引转换为坐标的代码,还做了一些其他事情。

大部分字节与邻接表有关(它具有被打高尔夫球的最大潜力)。从那时起,解决该问题就很简单了(我也许可以用更少的字节来完成)。

打高尔夫球:

from math import*
b=abs
c=max
e=range
f=len
A=input()
B=input()
C=ceil(sqrt((f(A)-.25)/3)+.5)
D=3*C*~-C+1
E=2*C-1
F=C-1
A+='.'*(D-f(A))
G=[set()for x in e(D)]
I=lambda H:sum(E+.5-b(t-F+.5)for t in e(int(H+F)))
for x in e(D):
 r=sum([[J-F]*(E-b(J-F))for J in e(E)],[])[x];q=x-I(r);s=-q-r;a=lambda q,r:G[x].add(int(q+I(r)));m=c(map(b,[q,r,s]))
 if m==F:
  if q in(m,-m):a(-q,-s)
  if r in(m,-m):a(-s,-r)
  if s in(m,-m):a(-r,-q)
 for K,L in zip([1,0,-1,-1,0,1],[0,1,1,0,-1,-1]):
  M,H=q+K,r+L
  if c(map(b,[M,H,-M-H]))<C:a(M,H)
def N(i,O,P):
 Q=O and O[0]==A[i]or'.'==A[i];R=0
 if(2>f(O))*Q:R=1
 elif Q:R=c([(x not in P)*N(x,O[1:],P+[i])for x in G[i]]+[0])
 return R
print(c([N(x,B,[])for x in e(D)])*(f(B)<=D))

不带说明的:

from math import*

#Rundown of the formula:
# * Get data about the size of the hexagon
# * Create lookup tables for index <-> coordinate conversion
#   * q=0, r=0 is the center of the hexagon
#   * I chose to measure in a mix of cubic and axial coordinates,
#     as that allows for easy oob checks and easy retrevial  
# * Create the adjacency list using the lookup tables, while
#   checking for wrapping
# * Brute-force check if a path in the hexagon matches the
#   expression

# shorten functions used a lot
b=abs
c=max
e=range

# Get input

prog=input()
expr=input()

# sdln = Side length
# hxln = Closest hexagonal number
# nmrw = Number of rows in the hexagon
# usdl = one less than the side length. I use it a lot later

sdln=ceil(sqrt((len(prog)-.25)/3)+.5)
hxln=3*sdln*~-sdln+1
nmrw=2*sdln-1
usdl=sdln-1

# Pad prog with dots

prog+='.'*(hxln-len(prog))

# nmbf = Number of elements before in each row
# in2q = index to collum
# in2r = index to row

nmbf=[0]*nmrw
in2q=[0]*hxln
in2r=[0]*hxln

#  4    5
#   \  /
# 3 -- -- 0
#   /  \ 
#  2    1

# dirs contains the q,r and s values needed to move a point
# in the direction refrenced by the index

qdir=[1,0,-1,-1,0,1]
rdir=[0,1,1,0,-1,-1]

# generate nmbf using a summation formula I made

for r in e(nmrw-1):
    nmbf[r+1]=int(nmbf[r]+nmrw+.5-b(r-sdln+1.5))

# generate in2q and in2r using more formulas
# cntr = running counter

cntr=0
for r in e(nmrw):
    bgnq=c(-r,1-sdln)
    for q in e(nmrw-b(r-sdln+1)):
        in2q[cntr]=bgnq+q
        in2r[cntr]=r-usdl
        cntr+=1

# adjn = Adjacency sets

adjn=[set()for x in e(hxln)]

# Generate adjacency sets

for x in e(hxln):
    #Get the q,r,s coords
    q,r=in2q[x],in2r[x]
    s=-q-r
    # a = function to add q,r to the adjacency list
    a=lambda q,r:adjn[x].add(q+nmbf[r+usdl])
    # m = absolute value distance away from the center
    m=c(map(b,[q,r,s]))
    # if we are on the edge (includes corners)...
    if m==usdl:
        # add the only other point it wraps to
        if q in(m,-m):
            a(-q,-s)
        if r in(m,-m):
            a(-s,-r)
        if s in(m,-m):
            a(-r,-q)
    # for all the directions...
    for d in e(6):
        # tmp{q,r,s} = moving in direction d from q,r,s
        tmpq,tmpr=q+qdir[d],r+rdir[d]
        # if the point we moved to is in bounds...
        if c(map(b,[tmpq,tmpr,-tmpq-tmpr]))<sdln:
            # add it
            a(tmpq,tmpr)

# Recursive path checking function
def mtch(i,mtst,past):
    # dmch = Does the place we are on in the hexagon match
    #        the place we are in the expression?
    # out = the value to return
    dmch=mtst and mtst[0]==prog[i]or'.'==prog[i]
    out=0
    # if we are at the end, and it matches...
    if(2>len(mtst))*dmch:
        out=1
    # otherwise...
    elif dmch:
        # Recur in all directions that we haven't visited yet
        # replace '*' with 'and' to speed up the recursion
        out=c([(x not in past)*mtch(x,mtst[1:],past+[i])for x in adjn[i]]+[0])
    return out

# Start function at all the locations in the hexagon
# Automatically return false if the expression is longer
# than the entire hexagon
print(c([mtch(x,expr,[])for x in e(hxln)])*(len(expr)<=hxln))

如此接近视网膜!:(是的,击败Retina!


5

Javascript(ES6),511 500 496字节

(H,N)=>{C=(x,y)=>(c[x]=c[x]||[])[y]=y;S=d=>(C(x,y=x+d),C(y,x),C(s-x,s-y),C(s-y,s-x));r=(x,p,v)=>{p<N.length?(v[x]=1,c[x].map(n=>!v[n]&&(H[n]==N[p]||H[n]=='.')&&r(n,p+1,v.slice()))):K=1};for(e=x=K=0;(s=3*e*++e)<(l=H.length)-1;);H+='.'.repeat(s+1-l);for(a=[],b=[],c=[[]],w=e;w<e*2;){a[w-e]=x;b[e*2-w-1]=s-x;for(p=w;p--;x++){w-e||S(s-e+1);w<e*2-1&&(S(w),S(w+1));p&&S(1)}a[w]=x-1;b[e*3-++w]=s-x+1}a.map((v,i)=>S(b[i]-(x=v)));[N[0],'.'].map(y=>{for(x=-1;(x=H.indexOf(y,x+1))>-1;r(x,1,[]));});return K}

取消评论

// Entry point
//   H = haystack (the string the hexagon is filled with)
//   N = needle (the substring we're looking for)
(H, N) => {
  // C(x, y) - Helper function to save a connection between two locations.
  //   x = source location
  //   y = target location
  C = (x, y) => (c[x] = c[x] || [])[y] = y;

  // S(d) - Helper function to save reciprocal connections between two locations
  //        and their symmetric counterparts.
  //   d = distance between source location (x) and target location
  S = d => (C(x, y = x + d), C(y, x), C(s - x, s - y), C(s - y, s - x));

  // r(x, p, v) - Recursive path search.
  //   x = current location in hexagon
  //   p = current position in needle
  //   v = array of visited locations
  r = (x, p, v) => {
    p < N.length ?
      (v[x] = 1, c[x].map(n => !v[n] && (H[n] == N[p] || H[n] == '.') &&
      r(n, p + 1, v.slice())))
    :
      K = 1
  };

  // Compute e = the minimum required edge width of the hexagon to store the haystack.
  // Also initialize:
  //   x = current location in hexagon
  //   l = length of haystack
  //   s = size of hexagon (number of locations - 1)
  //   K = fail/success flag
  for(e = x = K = 0; (s = 3 * e * ++e) < (l = H.length) - 1;);

  // Pad haystack with '.'
  H += '.'.repeat(s + 1 - l);

  // Build connections c[] between locations, using:
  //   x = current location
  //   w = width of current row
  //   p = position in current row
  // Also initialize:
  //   a[] = list of locations on top left and top right edges
  //   b[] = list of locations on bottom left and bottom right edges
  for(a = [], b = [], c = [[]], w = e; w < e * 2;) {
    a[w - e] = x;
    b[e * 2 - w - 1] = s - x;

    for(p = w; p--; x++) {
      // connection between top and bottom edges
      w - e || S(s - e + 1);
      // connections between current location and locations below it
      w < e * 2 - 1 && (S(w), S(w + 1));
      // connection between current location and next location
      p && S(1)
    }
    a[w] = x - 1;
    b[e * 3 - ++w] = s - x + 1
  }

  // Save connections between top left/right edges and bottom left/right edges.
  a.map((v, i) => S(b[i] - (x = v)));

  // Look for either the first character of the needle or a '.' in the haystack,
  // and use it as the starting point for the recursive search. All candidate
  // locations are tried out.
  [N[0], '.'].map(y => {
    for(x = -1; (x = H.indexOf(y, x + 1)) > -1; r(x, 1, []));
  });

  // Return fail/success flag.
  return K
}

测试用例

下面的代码段将介绍所有真实和错误的测试用例。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.