Guest User

Untitled

a guest
Jan 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. Œv¹y5×åO
  2.  
  3. Π# Compute all substrings from the input.
  4. v # For each substring.
  5. y5× # Repeat the substring 5 times (42 × 5 = 4242424242).
  6. ¹ å # Check if it's in the input string.
  7. O # Sum up the result. Non-boring numbers should give 0.
  8.  
  9. (.+)1{4}
  10.  
  11. L->java.util.regex.Pattern.compile("(.+)\1{4}").matcher(L).find();
  12.  
  13. import re;lambda u:re.search(r'(.+)1{4}',u)
  14.  
  15. process.stdin.on('data',t=>console.log(/(.+)1{4}/.test(t)))
  16.  
  17. alert(/(.+)1{4}/.test(prompt()))
  18.  
  19. n=>/(.+)1{4}/.test(n)
  20.  
  21. /(.+)1{4}/.test
  22.  
  23. $_=/(.+)1{4}/
  24.  
  25. s=>new Regex(@"(.+)1{4}").IsMatch(s);
  26.  
  27. []
  28.  
  29. f}*5TQ.: input as a string stored in Q
  30. f}*5TQ.:Q implicit arguments
  31. Q input
  32. .: all substrings of.
  33. f T filter for this condition, keep those returning true:
  34. *5 repeat five times
  35. } Q in Q? (True/False)
  36.  
  37. b=a__;StringContainsQ[b~~b~~b~~b~~b]
  38.  
  39. StringContainsQ@RegularExpression@"(.+)1{4}"
  40.  
  41. <?=preg_match('/(.+)1{4}/U',$n);
  42.  
  43. <?for($e=$n+1;--$e;)for($f=$e;$f--;)for($a=str_split(substr($n,$f),$e),$k=$c='';strlen($v=array_pop($a));)$c-$v?$k=0&$c=$v:($k++<3?:die(1));
  44.  
  45. import Data.List
  46. f x=or$tail[isInfixOf(concat$replicate 5 b)x|b<-subsequences x]
  47.  
  48. f "11111211"
  49. f "11111"
  50. f "12345"
  51. f "1112111"
  52. f "4242424242"
  53. f "-11111"
  54. f "3452514263534543543543543543876514264527473275"
  55.  
  56. s=int2str(i);all(s==s(1))
  57.  
  58. all(s==s(1))
  59.  
  60. DECLARE @t varchar(99)='11111'
  61.  
  62. ,@z bit=0,@a INT=1,@ INT=1WHILE @a<LEN(@t)SELECT @z=IIF(@t LIKE'%'+replicate(SUBSTRING(@t,@a,@),5)+'%',1,@z),@=IIF(@=20,1,@+1),@a+=IIF(@=1,1,0)PRINT @z
  63.  
  64. DECLARE @t varchar(99)='11111'
  65.  
  66. ,@z bit=0,
  67. @a INT=1,
  68. @ INT=1
  69. WHILE @a<LEN(@t)
  70. SELECT
  71. @z=IIF(@t LIKE'%'+replicate(SUBSTRING(@t,@a,@),5)+'%',1,@z),
  72. @=IIF(@=20,1,@+1),
  73. @a+=IIF(@=1,1,0)
  74.  
  75. PRINT @z
  76.  
  77. $args[0]-match"(.+)1{4}"
  78.  
  79. #(re-find #"(.+)1{4}"%)
  80.  
  81. b=s=>{for(let i=0;i<s.length-4;i++){for(let n=1;n<=Math.floor((s.length-i)/5);n++){if([1,2,3,4].every(k=>s.slice(i,i+n)==s.slice(i+n*k,i+n*(k+1))))return 1}}return 0}
  82.  
  83. // test any start pos, and length
  84. var b = s => {
  85. for (let i = 0; i <= s.length - 5; i++) {
  86. for (let n = 1; n <= Math.floor((s.length - i) / 5); n++) {
  87. // test if s is boring at position i, with length n
  88. if ([1, 2, 3, 4].every(k => s.slice(i, i + n) === s.slice(i + n * k, i + n * (k + 1)))) {
  89. return 1;
  90. }
  91. }
  92. }
  93. return 0;
  94. };
  95.  
  96. console.log(b('11111'));
  97. console.log(b('12345'));
  98. console.log(b('1112111'));
  99. console.log(b('-11111'));
  100. console.log(b('3452514263534543543543543543876514264527473275'));
Add Comment
Please, Sign In to add comment