Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.  You may assume the given string consists of lowercase English letters only and its length  will not exceed 10000. 

Example 1:

Input: "abab"

Output: True

Explanation: It's the substring "ab" twice.



Example 2:

Input: "aba"

Output: False



Example 3:

Input: "abcabcabcabc"

Output: True

Explanation: It's the substring "abc" four times. (And the substring "abcabc" twice.)

Difficulty: introductory

Starter code:

class Solution:
    def repeatedSubstringPattern(self, s: str) -> bool:
        

Solutions:
class Solution:
     def repeatedSubstringPattern(self, s):
         return s in (s + s)[1:-1]


class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         if not s:
             return False
             
         ss = (s + s)[1:-1]
         return s in ss


class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         double_s = s + s
         return s in double_s[1:len(double_s)-1]

class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         return any(s[:i] * (len(s) // i) == s for i in range(1, len(s) // 2 + 1) if len(s) % i == 0)

class Solution:
     def repeatedSubstringPattern(self, s):
         size = len(s)
         for x in range(1, size // 2 + 1):
             if size % x:
                 continue
             if s[:x] * (size // x) == s:
                 return True
         return False

class Solution:
     def repeatedSubstringPattern(self, s):
         size = len(s)
         for x in range(1, size // 2 + 1):
             if size % x:
                 continue
             if s[:x] * (size // x) == s:
                 return True
         return False

class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         n = len(s)                  # find len
         for i in range(n//2,0,-1):  # loop from end to start
             if n%i ==0:             # if n is sub_len integer tiems
                 repeat = s[0:i]
                 if repeat*(n//i) ==s: #if repeat*several_times == s
                     return True
         return False
 


class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         if len(s)<1:
             return True
         if len(s)==1:
             return False
         for lenofsub in range(1,len(s)):
             if (len(s)%lenofsub==0):
                 substring=[s[0:lenofsub]]*(len(s)//lenofsub)
                 if ''.join(substring)==s:
                     return True
         return False


class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         if not s:
             return False
             
         ss = (s + s)[1:-1]
         return s in ss 


class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
 
         ss = (s + s)[1:-1]
         return ss.find(s) != -1

class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         return s in (2 * s)[1:-1]


class Solution:
     def repeatedSubstringPattern(self, s):
         size = len(s)
         for x in range(1, size // 2 + 1):
             if size % x:
                 continue
             if s[:x] * (size // x) == s:
                 return True
         return False

class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         size = len(s)
         for i in range(1, size//2 + 1):
             if size % i:
                 continue
             if s[:i] * (size//i) == s:
                 return True
         return False

class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         return s in (s+s)[1:-1]

class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         s_len = len(s)
         for i in range(1,(s_len)//2+1):
             if s[i] == s[0]:
                 s_sub = s[:i]
                 s_new = s_sub * (s_len // i)
                 if s_new == s:
                     return True
         return False

class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         ss = (s*2)[1:-1]
         return s in ss

class Solution:
     def repeatedSubstringPattern(self, s):
         """
         :type s: str
         :rtype: bool
         """
         length = len(s)
         
         base = 1
         while base <= length // 2:
             if length % base == 0:
                 if s[:base]*(length//base) == s:
                     return True
             base += 1
         
         return False