Uiua
Just a dirty great hack and a few minutes of toasty CPU for part3 with live data.
"1,5,2,6,8,4,1,7,3"
βββΈβ @,
&p /+=β(β§β(β΅/-)|Γ·2/β₯) # Part1 --> 4
"1,5,2,6,8,4,1,7,3,5,7,8,2"
βββΈβ @,
Knot β (β(=Β―|=)β©β(Β±-)βΒ°β)
Knots β /β§/β₯β―β_2[β©βKnot]Β°β
β§ββ
&p /+β‘(/+β‘Knots€°ββΒ―)βΒ€+1β2β‘βΈβ§» # Part 2 --> 21
"1,5,2,6,8,4,1,7,3,6"
βββΈβ @,
β(β§
<2+1β‘β§»β΄|β§ββ) # Possible cuts, existing strings.
/β₯+β(β‘ΛββΒ€|β‘(/+β‘KnotsΒ€)βΒ€) # Part3 --> 7
all 9 comments