# 疑难杂症

35

$A$$A$

$D$$D$$⟨D⟩$$\langle D\rangle$

1. 没有任何交叉的唯一循环的多项式为1。

2. $D$$D$$D$$D$$D$$D$$\left(-{A}^{2}-{A}^{-2}\right)$$(-A^2-A^{-2})$

3. $D$$D$

$A$$A$${A}^{-1}$$A^{-1}$

# 输入值

• 道克符号，例如[6,-12,2,8,-4,-10]。交叉点的编号必须从1开始。相应的奇数[1,3,5,7,...]是隐式的，不能作为输入提供。

• 与道克符号对应的交叉口的符号（1/ -1或（如果您更喜欢0/ 1false/ true'+'/ '-'）），例如[-1,-1,-1,1,-1,1]

# 输出量

${A}^{-2}+5+A-{A}^{3}$$A^{-2}+5+A-A^3$[[1,-2],[5,0],[1,1],[-1,3]]

$-k\dots k$$-k\ldots k$$k\in \mathbb{N}$$k\in \mathbb{N}$[0,1,0,5,1,0,-1]${A}^{0}$$A^0$

# 测验

// 4-tuples of [dowker_notation, crossing_signs, expected_result, description]
[
[[],[],[[1,0]],"unknot"],
[[2],[1],[[-1,3]],"unknot with a half-twist (positive crossing)"],
[[2],[-1],[[-1,-3]],"unknot with a half-twist (negative crossing)"],
[[2,4],[1,1],[[1,6]],"unknot with two half-twists (positive crossings)"],
[[4,6,2],[1,1,1],[[1,-7],[-1,-3],[-1,5]],"right-handed trefoil knot, 3_1"],
[[4,6,2,8],[-1,1,-1,1],[[1,-8],[-1,-4],[1,0],[-1,4],[1,8]],"figure-eight knot, 4_1"],
[[6,8,10,2,4],[-1,-1,-1,-1,-1],[[-1,-7],[-1,1],[1,5],[-1,9],[1,13]],"pentafoil knot, 5_1"],
[[6,8,10,4,2],[-1,-1,-1,-1,-1],[[-1,-11],[1,-7],[-2,-3],[1,1],[-1,5],[1,9]],"three-twist knot, 5_2"],
[[4,8,10,2,12,6],[1,1,-1,1,-1,-1],[[-1,-12],[2,-8],[-2,-4],[3,0],[-2,4],[2,8],[-1,12]],"6_3"],
[[4,6,2,10,12,8],[-1,-1,-1,-1,-1,-1],[[1,-10],[2,-2],[-2,2],[1,6],[-2,10],[1,14]],"granny knot (sum of two identical trefoils)"],
[[4,6,2,-10,-12,-8],[1,1,1,1,1,1],[[1,-14],[-2,-10],[1,-6],[-2,-2],[2,2],[1,10]],"square knot (sum of two mirrored trefoils)"],
[[6,-12,2,8,-4,-10],[-1,-1,-1,1,-1,1],[[1,-2],[1,6],[-1,10]],"example knot"]
]


# 外部资源

Mego

1
@ngn：好多了！我当时猜想那是什么意思，但表达得有点像绕口令。:)
Chas Brown

10

# K（NGN / K） ，196个 193字节

{!N::2*n:#x;{+/d,'x,'d:&:'-2!(|/n)-n:#:'x}(+/1-2*s){j::+,/y;,/(&0|2*x;(-1+#?{x[j]&:x@|j;x}/!N){-(d,x)+x,d:&4}/,1;&0|-2*x)}'(N!{(x,'|1+x;x+/:!2)}'((2*!n),'-1+x|-x)@'0 1=/:x>0)@'/:+~(y<0)=s:!n#2}


12

# Brain-Flak，1316字节

(({})<({()<(({}<>))><>}){(({})[()()]<{([{}]({})<>({}<>))}{}(([({}<>)]<<>({}<>)<>((({})<<>{({}<>)<>}<>>))>)){({}<>)<>}<>{}(({}<{}(({}<{({}<>)<>}>))>))<>{({}<>)<>}>)}<>>){(({}){}()<({}<>)>)<>{}(({}){}<>)<>}<>{}{}(()){(<({}<({}<>)>)>)<>((){[()](<(({})<>){({}[({})]<>({}<>))}{}({}<>({}<{}<>{({}<>)<>}>)[()])<>({}({})[()])(([()]{()(<({}[({})]())>)}{})<{(<{}{}>)}{}><>{()((<({}()[({}<>)])<>>))}{}<{}{}>)((){[()]<({}()<({}<({}<<>({()<({}<>)<>>}<>){({}[()]<(({})<({()<({}<>)<>>})<>>)<>{({}[()]<<>({}<>)>)}{}>)}<>>)<>>)>)((){[()](<{}(({})<<>(({})<(<<>({}<<>({}<(()()){({}[()]<([{}]()<>)<>({}<<>{({}({})<>[({}<>)])}{}{}>){({}<>)<>}<>>)}{}>{})>)>)<>{}{({}<>)<>}<>([({}<>)]<((()))>)(())<>({}<>)<>{}({}[()]){<>({}<<>(()()){({}[()]<({}<<>{({}<>)<>}>){({}[({})]<>({}<>))}{}(({})<<>({}<>)<>([{}])>)>)}{}{}>)<>({}<(({})())>[()]<>)}{}({}<<>{}([{}]()<{({}<>)<>}>){({}({})<>[({}<>)])}{}{}>){({}<>)<>}<>{}{}{}>{})>)>)}{}){(<{}(({})<<>(({}{})<<>(<({}<>)>)<>{}{({}<>)<>}<>>(({}){}){})>)>)}>}{}){(<{}([{}]<({}<<>([{}]()<>)<>({}<<>{({}({})<>[({}<>)])}{}{}>){({}<>)<>}<>>({})({}){})>)>)}{}>)}{}){{}(([{}]){}<>{}{}<<>({}<>{}){([{}]({}()()<{}({}<>)(())<>>))}{}{}{}>{})(())<>{{}({}<>)(())<>}(<>)<>}{}}{}{}<>{}{}({}<{{}({}<>)(())<>}<>{{}{((<(())>))}{}}{}{{}({}<>)(())<>}>)<>{{}({}<(<()>)<>([]){{}({}<>)(())<>([])}{}>)<>{{}({}<>)<>}{}{}({}<>)<>}<>


# Part 1: extract edges
(({})<

({()<(({}<>))><>}){

(({})[()()]<

{([{}]({})<>({}<>))}{}(([({}<>)]<<>({}<>)<>((({})<<>{({}<>)<>}<>>))>)){({}<>)<>}

<>{}(({}<{}(({}<{({}<>)<>}>))>))<>{({}<>)<>}

>)}

<>>){(({}){}()<({}<>)>)<>{}(({}){}<>)<>}<>

{}{}(())

# Part 2: Compute bracket polynomial
{

# Move degree/sign to other stack
(<({}<({}<>)>)>)<>

# If current shape has crossings:
((){[()](<

# Consider first currently listed edge in set
# Find the other edge leaving same crossing
(({})<>){({}[({})]<>({}<>))}{}

# Move to top of other stack
# Also check for twist
({}<>({}<{}<>{({}<>)<>}>)[()])

# Check for twist in current edge
<>({}({})[()])

(

# Remove current edge if twist
([()]{()(<({}[({})]())>)}{})<{(<{}{}>)}{}>

# Remove matching edge if twist
<>{()((<({}()[({}<>)])<>>))}{}<{}{}>

# Push 1 minus number of twists from current vertex.
)

# If number of twists is not 1:
((){[()]<

# While testing whether number of twists is 2:
({}()<

# Keep sign/degree on third stack:
({}<({}<

# Duplicate current configuration
<>({()<({}<>)<>>}<>){({}[()]<(({})<({()<({}<>)<>>})<>>)<>{({}[()]<<>({}<>)>)}{}>)}

# Push sign and degree on separate stacks
<>>)<>>)

# If number of twists is not 2: (i.e., no twists)
>)((){[()](<{}

# Make first copy of sign/degree
(({})<<>(({})<

# Make second copy of sign/degree
(<<>({}<<>({}<

# Do twice:
(()()){({}[()]<

# Prepare search for vertex leading into crossing on other side
([{}]()<>)

# While keeping destination on third stack:
<>({}<

# Search for matching edge
<>{({}({})<>[({}<>)])}{}

# Replace old destination
{}>)

# Move back to original stack
{({}<>)<>}<>

>)}{}

>{})>)>)

# Move duplicate to left stack
<>{}{({}<>)<>}<>

# Create "fake" edges from current crossing as termination conditions
([({}<>)]<((()))>)(())<>

# Create representation of "top" new edge
({}<>)<>{}({}[()])

# While didn't reach initial crossing again:
{

# Keep destination of new edge on third stack
<>({}<<>

# Do twice:
(()()){({}[()]<

# Search for crossing
({}<<>{({}<>)<>}>){({}[({})]<>({}<>))}{}

# Reverse orientation of crossing
(({})<<>({}<>)<>([{}])>)

>)}{}

# Remove extraneous search term
{}

# Push new destination for edge
>)

# Set up next edge
<>({}<(({})())>[()]<>)

}

# Get destination of last edge to link up
{}({}<

# Find edge headed toward original crossing
<>{}([{}]()<{({}<>)<>}>){({}({})<>[({}<>)])}

# Replace destination
{}{}>)

# Move everything to left stack
{({}<>)<>}

# Clean up temporary data
<>{}{}{}

# Push new sign/degree of negatively smoothed knot
>{})>)

# Else (two twists)
# i.e., crossing is the twist in unknot with one half-twist
>)}{}){(<{}

# Copy sign and degree+orientation
(({})<<>(({}{})<

# Move sign to left stack
<>(<({}<>)>)

# Move copy of configuration to left stack
<>{}{({}<>)<>}

<>>(({}){}){})>)

>)}

# Else (one twist)
>}{}){(<

# Invert sign and get degree
{}([{}]<({}<

# Search term for other edge leading to this crossing
<>([{}]()<>)

# With destination on third stack:
<>({}<

# Find matching edge
<>{({}({})<>[({}<>)])}{}

# Replace destination
{}>)

# Move stuff back to left stack
{({}<>)<>}<>

>({})({}){})>)

>)}{}

# Else (no crossings)
>)}{}){{}

# If this came from the 2-twist case, undo splitting.
# If this came from an initial empty input, use implicit zeros to not join anything
# New sign = sign - 2 * next entry sign
(([{}]){}<>{}{}<

# New degree = average of both degrees
<>({}<>{})

# Find coefficient corresponding to degree
{([{}]({}()()<{}({}<>)(())<>>))}{}{}

{}>{})

# Move rest of polynomial back to right stack
(())<>{{}({}<>)(())<>}

# Set up next configuration
(<>)<>

}{}

}{}{}<>{}

# Step 3: Put polynomial in correct form

# Keeping constant term:
{}({}<

# Move to other stack to get access to terms of highest absolute degree
{{}({}<>)(())<>}<>

# Remove outer zeros
{{}{((<(())>))}{}}

# Move back to right stack to get access to lower order terms
{}{{}({}<>)(())<>}

>)<>

# While terms remain:
{

# Move term with positive coefficient
{}({}<(<()>)<>([]){{}({}<>)(())<>([])}{}>)<>{{}({}<>)<>}{}

# Move term with negative coefficient
{}({}<>)<>

}<>


Don Thousand

Don Thousand