Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Œv¹y5×åO
- Œ # Compute all substrings from the input.
- v # For each substring.
- y5× # Repeat the substring 5 times (42 × 5 = 4242424242).
- ¹ å # Check if it's in the input string.
- O # Sum up the result. Non-boring numbers should give 0.
- (.+)1{4}
- L->java.util.regex.Pattern.compile("(.+)\1{4}").matcher(L).find();
- import re;lambda u:re.search(r'(.+)1{4}',u)
- process.stdin.on('data',t=>console.log(/(.+)1{4}/.test(t)))
- alert(/(.+)1{4}/.test(prompt()))
- n=>/(.+)1{4}/.test(n)
- /(.+)1{4}/.test
- $_=/(.+)1{4}/
- s=>new Regex(@"(.+)1{4}").IsMatch(s);
- []
- f}*5TQ.: input as a string stored in Q
- f}*5TQ.:Q implicit arguments
- Q input
- .: all substrings of.
- f T filter for this condition, keep those returning true:
- *5 repeat five times
- } Q in Q? (True/False)
- b=a__;StringContainsQ[b~~b~~b~~b~~b]
- StringContainsQ@RegularExpression@"(.+)1{4}"
- <?=preg_match('/(.+)1{4}/U',$n);
- <?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));
- import Data.List
- f x=or$tail[isInfixOf(concat$replicate 5 b)x|b<-subsequences x]
- f "11111211"
- f "11111"
- f "12345"
- f "1112111"
- f "4242424242"
- f "-11111"
- f "3452514263534543543543543543876514264527473275"
- s=int2str(i);all(s==s(1))
- all(s==s(1))
- DECLARE @t varchar(99)='11111'
- ,@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
- DECLARE @t varchar(99)='11111'
- ,@z bit=0,
- @a INT=1,
- @ INT=1
- WHILE @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
- $args[0]-match"(.+)1{4}"
- #(re-find #"(.+)1{4}"%)
- 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}
- // test any start pos, and length
- var b = s => {
- for (let i = 0; i <= s.length - 5; i++) {
- for (let n = 1; n <= Math.floor((s.length - i) / 5); n++) {
- // test if s is boring at position i, with length 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;
- };
- console.log(b('11111'));
- console.log(b('12345'));
- console.log(b('1112111'));
- console.log(b('-11111'));
- console.log(b('3452514263534543543543543543876514264527473275'));
Add Comment
Please, Sign In to add comment