## Task:

You have to write a function `pattern` which returns the following Pattern(See Examples) upto n number of rows. 

* Note:```Returning``` the pattern is not the same as ```Printing``` the pattern.

### Rules/Note:

* The pattern should be created using only unit digits.
* If `n < 1` then it should return "" i.e. empty string.
* `The length of each line is same`, and is equal to the number of characters in a line i.e `n`.
* Range of Parameters (for the sake of CW Compiler) :
  + `n ∈ (-50,150]`
   
### Examples:

 + pattern(8):

       88888888
       87777777
       87666666
       87655555
       87654444
       87654333
       87654322
       87654321
       
 + pattern(17):
   
       77777777777777777
       76666666666666666
       76555555555555555
       76544444444444444
       76543333333333333
       76543222222222222
       76543211111111111
       76543210000000000
       76543210999999999
       76543210988888888
       76543210987777777
       76543210987666666
       76543210987655555
       76543210987654444
       76543210987654333
       76543210987654322
       76543210987654321


[List of all my katas]("http://www.codewars.com/users/curious_db97/authored")

Difficulty: introductory

Starter code:

def pattern(n):
	

Solutions:
def pattern(n):
    return "\n".join(
        "".join(
            str((n - min(j, i)) % 10) for j in range(n)
        )
        for i in range(max(n, 0))
    )

def pattern(n):
    return '\n'.join(''.join(str((n - min(i, j))%10) for j in range(n)) for i in range(n))

def pattern(n):
    return "\n".join(["".join([str(j % 10) for j in range(n, n - i, - 1)]).ljust(n, str((n-i) % 10)) for i in range(n)])

def pattern(n):
    return "\n".join("".join(str(max(r, c) % 10) for c in range(n, 0, -1)) for r in range(n, 0, -1))


def pattern(n):
  return '\n'.join(''.join(str(j%10) for j in range(n, i, -1)) + str(i%10) * i for i in range(n, 0, -1))

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

def pattern(n):
    if n < 1: return ''
    res = []
    current = str(n)[-1]
    strng = ''
    res.append(current*n)
    for i in range(1,n):
        strng = (strng + current)
        if current == '0':
            res.append(strng.ljust(n, '9'))
            current = '9'
        else:
            res.append(strng.ljust(n, str(int(current) - 1)))
            current = str(int(current)-1)
    return '\n'.join(res)

def pattern(n):

    pattern = ""
    pattern_sub = ""

    for x in range(n, 0, -1):
        pattern += pattern_sub
        pattern += str(x % 10) * x
        pattern_sub += str(x%10)
        if x > 1: pattern += "\n"

    return pattern

def pattern(n):
    if n < 1: return ''
    if n == 1: return '1'
    res = []
    for i in range(1, n+1):
        res.append(''.join([str(i%10)]*i + [str(s%10) for s in range(i+1, n+1)])[::-1])
    return '\n'.join(res[::-1])

def pattern(n):
    d = int(str(n)[-1])
    ptn = str(d) * n
    arr = [ptn]
    for i in range(n-1):
        if ptn[-1] != '0':
            ptn = ptn[:i+1] + str(int(ptn[-1])-1) * (n-i-1)
        else:
            ptn = ptn[:i+1] + '9' * (n-i-1)
        arr.append(''.join(ptn))
    result = ('\n').join(arr)
    return result