## Task:

You have to write a function **pattern** which returns the following Pattern(See Examples) upto (2n-1) rows, where n is parameter.

### Rules/Note:
* If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string.
* All the lines in the pattern have same length i.e equal to the number of characters in the longest line.
* Range of n is (-∞,100]

## Examples:

pattern(5):

        1    
       121   
      12321  
     1234321 
    123454321
     1234321 
      12321  
       121   
        1    


pattern(10):

             1         
            121        
           12321       
          1234321      
         123454321     
        12345654321    
       1234567654321   
      123456787654321  
     12345678987654321 
    1234567890987654321
     12345678987654321 
      123456787654321  
       1234567654321   
        12345654321    
         123454321     
          1234321      
           12321       
            121        
             1         

pattern(15):

                  1              
                 121             
                12321            
               1234321           
              123454321          
             12345654321         
            1234567654321        
           123456787654321       
          12345678987654321      
         1234567890987654321     
        123456789010987654321    
       12345678901210987654321   
      1234567890123210987654321  
     123456789012343210987654321 
    12345678901234543210987654321
     123456789012343210987654321 
      1234567890123210987654321  
       12345678901210987654321   
        123456789010987654321    
         1234567890987654321     
          12345678987654321      
           123456787654321       
            1234567654321        
             12345654321         
              123454321          
               1234321           
                12321            
                 121             
                  1              

pattern(20):

                       1                   
                      121                  
                     12321                 
                    1234321                
                   123454321               
                  12345654321              
                 1234567654321             
                123456787654321            
               12345678987654321           
              1234567890987654321          
             123456789010987654321         
            12345678901210987654321        
           1234567890123210987654321       
          123456789012343210987654321      
         12345678901234543210987654321     
        1234567890123456543210987654321    
       123456789012345676543210987654321   
      12345678901234567876543210987654321  
     1234567890123456789876543210987654321 
    123456789012345678909876543210987654321
     1234567890123456789876543210987654321 
      12345678901234567876543210987654321  
       123456789012345676543210987654321   
        1234567890123456543210987654321    
         12345678901234543210987654321     
          123456789012343210987654321      
           1234567890123210987654321       
            12345678901210987654321        
             123456789010987654321         
              1234567890987654321          
               12345678987654321           
                123456787654321            
                 1234567654321             
                  12345654321              
                   123454321               
                    1234321                
                     12321                 
                      121                  
                       1

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def pattern(n):
	

Solutions:
def pattern(n):
	lines = []
	for i in range(1, n + 1):
		line = ' ' * (n - i)
		line += ''.join((str(j % 10) for j in range(1, i + 1)))
		line += line[::-1][1:]
		lines.append(line)
	return '\n'.join(lines + lines[::-1][1:])


def pattern(n):
	lines = []
	for c in range(1, n + 1):
		s = ' ' * (n - c) + ''.join([str(s)[-1] for s in range(1, c + 1)])
		lines += [s + s[::-1][1:]]
	lines += lines[::-1][1:]
	return '\n'.join((str(x) for x in lines))


def pattern(n):
	result = []
	for i in range(1, n + 1):
		nums = ''.join([str(j % 10) for j in range(1, i + 1)])
		result.append(' ' * (n - i) + nums + nums[::-1][1:] + ' ' * (n - i))
	return '\n'.join(result + result[::-1][1:])


def pattern(n):
	mid = ''
	nums = '1234567890' * n
	for i in range(n):
		mid += nums[i]
	mid += mid[-2::-1]
	d = []
	for i in range(n - 1):
		d.append(''.join(mid.rsplit(mid[i:-i - 1], 1)).center(2 * n - 1))
	d.append(mid)
	for j in d[-2::-1]:
		d.append(j)
	return '\n'.join(d)


def pattern(n):
	if n < 1:
		return ''
	s = '1234567890' * (n // 10 + 1)
	width = 2 * n - 1
	triangle = [(s[:i + 1] + s[:i][::-1]).center(width) for i in range(n)]
	return '\n'.join(triangle + triangle[:-1][::-1])


from itertools import chain, cycle, islice

def pattern(n):
	w = 2 * n - 1

	def f():
		for i in chain(range(1, n + 1), range(n - 1, 0, -1)):
			xs = ''.join(islice(cycle('1234567890'), i))
			yield (xs + xs[-2::-1]).center(w)
	return '\n'.join(f())


def pattern(n):
	(l, s) = (2 * n - 1, ''.join((str(x % 10) for x in range(1, n + 1))))
	lst = [(s[:-i or n] + s[:-i - 1][::-1]).center(l) for i in range(n)]
	return '\n'.join(lst[1:][::-1] + lst)


mkP = lambda y: str(y % 10)
row = lambda n, x: ' ' * (n - x - 1) + ''.join(map(mkP, range(1, x + 1))) + ''.join(map(mkP, range(x + 1, 0, -1))) + ' ' * (n - x - 1)

def pattern(n):
	pyramid = [row(n, x) for x in range(n - 1)]
	return '\n'.join(pyramid + [row(n, n - 1)] + list(reversed(pyramid)))