# Task
Get the digits sum of `n`th number from the [Look-and-Say sequence](http://en.wikipedia.org/wiki/Look-and-say_sequence)(1-based).

`1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, ...`

# Input/Output

`[input]` integer `n`

`n`th number in the sequence to get where `1 <= n <= 55`  and `n=1 is "1"`.

[output] an integer

The sum of digits in `n`th number from the `Look-and-Say` sequence.

# Example

For `n = 2`, the output shoule be 2.

`"11" --> 1 + 1 --> 2`

For `n = 3`, the output shoule be 3.

`"21" --> 2 + 1 --> 3`

For `n = 4`, the output shoule be 5.

`"1211" --> 1 + 2 + 1 + 1 --> 5`

Difficulty: introductory

Starter code:

def look_and_say_and_sum(n):
	

Solutions:
def look_and_say_and_sum(N):
    l=[1]
    for n in range(N-1):
        result = [1,l[0]]
        for i in range(1,len(l)):
            if l[i]==result[-1]:
                result[-2] += 1
            else:
                result += [1,l[i]] 
        l=result
    return sum(l)


def look_and_say_and_sum(n):
    return {
        1: 1,
        2: 2,
        3: 3,
        4: 5,
        5: 8,
        6: 10,
        7: 13,
        8: 16,
        9: 23,
        10: 32,
        11: 44,
        12: 56,
        13: 76,
        14: 102,
        15: 132,
        16: 174,
        17: 227,
        18: 296,
        19: 383,
        20: 505,
        21: 679,
        22: 892,
        23: 1151,
        24: 1516,
        25: 1988,
        26: 2602,
        27: 3400,
        28: 4410,
        29: 5759,
        30: 7519,
        31: 9809,
        32: 12810,
        33: 16710,
        34: 21758,
        35: 28356,
        36: 36955,
        37: 48189,
        38: 62805,
        39: 81803,
        40: 106647,
        41: 139088,
        42: 181301,
        43: 236453,
        44: 308150,
        45: 401689,
        46: 523719,
        47: 682571,
        48: 889807,
        49: 1159977,
        50: 1511915,
        51: 1970964,
        52: 2569494,
        53: 3349648,
        54: 4366359,
        55: 5691884,
        }[n]




def look_and_say_and_sum(n):
    return [0, 1, 2, 3, 5, 8, 10, 13, 16, 23, 32, 44, 56, 76, 102, 132, 174, 227, 296, 383, 505, 679, 892, 1151, 1516, 1988, 2602, 3400, 4410, 5759, 7519, 9809, 12810, 16710, 21758, 28356, 36955, 48189, 62805, 81803, 106647, 139088, 181301, 236453, 308150, 401689, 523719, 682571, 889807, 1159977, 1511915, 1970964, 2569494, 3349648, 4366359, 5691884, 7419702, 9671795, 12608013, 16435261, 21424450][n]


look_and_say_and_sum=l=lambda n,s='1':n<2and sum(map(int,s))or l(n-1,''.join(str(len(list(g)))+k for k,g in __import__('itertools').groupby(s)))

def look_and_say_and_sum(n):
    oldstr = "1"
    newstr = ""
    total = 1
    i = 1
    while (i < n):
        j = 0
        total = 0
        newstr = ""
        length = len(oldstr)
        while (j < length):
            look = oldstr[j]
            count = 0
            while (j < length and look == oldstr[j]):
                count += 1
                j += 1
            total += count
            total += int(look)
            newstr += str(count)
            newstr += look
        oldstr = newstr
        i += 1
    return (total)

def look_and_say_and_sum(n):
    from itertools import groupby
    e = '1'
    for i in range(n - 1):
        e = ''.join(str(list(b).count(a)) + a for a, b in groupby(e))
    return sum(map(int, e))

look_and_say_and_sum=lambda n:[0,1,2,3,5,8,10,13,16,23,32,44,56,76,102,132,174,227,296,383,505,679,892,1151,1516,1988,2602,3400,4410,5759,7519,9809,12810,16710,21758,28356,36955,48189,62805,81803,106647,139088,181301,236453,308150,401689,523719,682571,889807,1159977,1511915,1970964,2569494,3349648,4366359,5691884][n]

from itertools import groupby

d=['1']
def look_and_say_and_sum(n):
    i=len(d)-1
    s=d[i]
    for _ in range(i,n):
        x=''
        for c,g in groupby(s):
            x+=f'{len(list(g))}{c}'
        s=x
        d.append(s)
    return sum(map(int,d[n-1]))

for i in range(1,10):
    print(i,look_and_say_and_sum(i))

from itertools import groupby
def look_and_say_and_sum(n):
    s='1'
    for _ in range(n-1):
        s=''.join(k+str(len(list(v))) for k,v in groupby(s))
    return sum(int(d) for d in s)