Guest User

Untitled

a guest
Feb 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. ,[<<<,]+[>>->[[[[>>[>>>]<+<-<[<<<]>>+<-]>[<+>-]>[>>>]<<[>[<+>-]]>[[<+>-]>+[<<<]>
  2. >>-[+>[<<<]<[>+>[->]<<[<]>-]>[<+>>+<-]>>>[>>>]]>>]<]>+[,<<<+]->[<<<]>>>>>+[,+>>>
  3. +]-[>>>]->]<[+<<<]+<<<++[->>>]+>>>->]<[,<<<]<[>>>+<<<-]>+>,>>>]<<.
  4.  
  5. ,[<<<,]
  6. +
  7. [
  8. for each suffix
  9. >>->
  10. [
  11. for each prefix
  12. [
  13. for each suffix
  14. [
  15. for each char while no mismatch
  16. [
  17. >>[>>>]
  18. <+<-<[<<<]
  19. > >+<-
  20. ]
  21. >[<+>-]
  22. >[>>>]
  23. <<
  24. [
  25. mismatch
  26. >[<+>-]
  27. ]
  28. >
  29. [
  30. [<+>-]
  31. >+[<<<]
  32. >>>-
  33. [
  34. match
  35. +>[<<<]
  36. <
  37. [
  38. >+>[->]
  39. <<[<]
  40. >-
  41. ]
  42. >[<+> >+<-]
  43. >>>[>>>]
  44. ]
  45. >>
  46. ]
  47. <
  48. ]
  49. >+[,<<<+]
  50. ->[<<<]
  51. >>> >>+[,+>>>+]
  52. -[>>>]
  53. ->
  54. ]
  55. <[+<<<]
  56. +<<<++[->>>]
  57. +>>>->
  58. ]
  59. <[,<<<]
  60. <[>>>+<<<-]
  61. >+>,>>>
  62. ]
  63. <<.
  64.  
  65. œ-QL€
  66. ŒṖÇ€FṀ
  67.  
  68. ŒṖÇ€FṀ Main link. Argument: s (string)
  69.  
  70. ŒṖ Generate all partitions of s.
  71. ǀ Apply the helper link to each partition.
  72. F Flatten the resulting array of lengths.
  73. Ṁ Take the maximum.
  74.  
  75.  
  76. œ-QL€ Helper link. Argument: P (partition)
  77.  
  78. Q Yield the elements of P, deduplicated.
  79. œ- Multiset subtraction; remove exactly one occurrence of each string in P.
  80. L€ Compute the lengths of the remaining strings.
  81.  
  82. M&!`(.*)(?=.*1)
  83. M%`.
  84. O#^`
  85. G1`
  86.  
  87. M&!`(.*)(?=.*1) # Prints overlapping greedy substrings occuring more than once
  88. M%`. # Replace each line with its length
  89. O#^` # Sort lines by number in reverse
  90. G1` # Return the first line
  91.  
  92. function r(a,b,m){return b=-~b,t=a.slice(0,b),n=a.indexOf(t,b),m=b>m&&!~n?m:b,a!=t&&r(a,b,m)||(a?r(a.slice(1),m,m):~-m)}
  93.  
  94. Max@StringLength@StringCases[#,a___~~___~~a___:>a,Overlaps->All]&
  95.  
  96. eSlM+ksmft/dTd./
  97.  
  98. #(apply max(for[R[(range(count %))]j R i R](let[[b e](split-at i(drop j %))](if((set(partition i 1 e))b)i 0)))))
  99.  
  100. function a(s){var l=s.length/2,z=1,f='';while(z<=l){var t=s.substr(0,z),c=0;for(var i=0;i<s.length;i++){if(s.substr(i,z)===t){c++;if(c>1){f=t}}}z++}return f.length}
  101.  
  102. console.log(a('abcabcabcabc')) // Output 6
  103. console.log(a('xyz')) // Output 0
  104. console.log(a('aaaaaaa')); // Output 3
  105. console.log(a('abcdefabc')); // Output 3
Add Comment
Please, Sign In to add comment