InstruçÔes

SequĂȘncia para olhar e dizer

A sequĂȘncia para olhar e dizer Ă© uma sequĂȘncia de nĂșmeros recursivamente definida. Definição da sequĂȘncia <ul><li>Take a decimal number</li> <li><span>Look</span> at the number, visually grouping consecutive runs of the same digit.</li> <li><span>Say</span> the number, from left to right, group by group; as how many of that digit there are - followed by the digit grouped.</li></ul><span> This becomes the next number of the sequence.</span> Um exemplo: <ul><li>Starting with the number 1, you have <span>one</span> 1 which produces 11</li> <li>Starting with 11, you have <span>two</span> 1's. I.E.: 21</li> <li>Starting with 21, you have <span>one</span> 2, then <span>one</span> 1. I.E.: (12)(11) which becomes 1211</li> <li>Starting with 1211, you have <span>one</span> 1, <span>one</span> 2, then <span>two</span> 1's. I.E.: (11)(12)(21) which becomes 111221</li></ul>

O que fazer:

Escreva uma função que aceita uma string como parùmetro, faz seu processamento e retorna a string resultante.

Critérios de Aceitação:

Testes:

  • `lookAndSay` deve ser uma função.
  • `lookAndSay("1")` deve retornar uma string.
  • `lookAndSay("1")` deve retornar `"11"`.
  • `lookAndSay("11")` deve retornar `"21"`.
  • `lookAndSay("21")` deve retornar `"1211"`.
  • `lookAndSay("1211")` deve retornar `"111221"`.
  • `lookAndSay("3542")` deve retornar `"13151412"`.

Console