6 kyu
Look and say sequence generator
381 of 867GiacomoSorbi
Description:
The look and say sequence is a sequence in which each number is the result of a "look and say" operation on the previous element.
Considering for example the classical version startin with "1"
: ["1", "11", "21, "1211", "111221", ...]
. You can see that the second element describes the first as "1(times number)1"
, the third is "2(times number)1"
describing the second, the fourth is "1(times number)2(and)1(times number)1"
and so on.
Your goal is to create a function which takes a starting string (not necessarily the classical "1"
, much less a single character start) and return the nth element of the series.
Examples
"1", 1 --> "1"
"1", 3 --> "21"
"1", 5 --> "111221"
"22", 10 --> "22"
"14", 2 --> "1114"
Trivia: "22"
is the only element that can keep the series constant.
Strings
Regular Expressions
Fundamentals
Similar Kata:
Stats:
Created | May 23, 2017 |
Published | May 23, 2017 |
Warriors Trained | 1986 |
Total Skips | 47 |
Total Code Submissions | 2851 |
Total Times Completed | 867 |
JavaScript Completions | 310 |
Ruby Completions | 62 |
Python Completions | 381 |
Crystal Completions | 7 |
C# Completions | 79 |
C Completions | 84 |
Haskell Completions | 5 |
Total Stars | 58 |
% of votes with a positive feedback rating | 95% of 249 |
Total "Very Satisfied" Votes | 226 |
Total "Somewhat Satisfied" Votes | 22 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |