Something dumb

I don’t remember where I saw this or what it’s called, but I thought I’d see how much code it would take to do it. You start out with a 1. Then you describe what it is for then next value. So you have one 1 (1 1). Then you continue with two 1’s (2 1). Then one 2 and one 1 (1 2 1 1). Continue again you have one 1, one 2, two 1’s (1 1 1 2 2 1). And you continue for the next, etc. Tap the screen to start and to show the next number. Slide the print window up to view the full print area. It slows down quite a bit as it gets larger, and I’m not sure how big it is when the first 4 shows up. I told you it was something dumb.

PS. I did a search and found that this is called the Look and Say Conway Sequence. I also found that the number 4 or higher won’t show.

function setup()
    str="1"
end

function create()
    print("size "..#str.."\
"..str)
    str2=""
    hold=string.sub(str,1,1)
    count=1
    for z=2,#str do
        value=string.sub(str,z,z)
        if value==hold then
            count=count+1
        else
            str2=str2..count..hold
            hold=value
            count=1
        end
    end
    str2=str2..count..hold
    str=str2
end

function touched(t)
    if t.state==BEGAN then
        create()
    end
end