We've had a few challenges involving the Look-and-say sequence. Quick reminder:
- The sequence starts with
- Subsequent terms of this sequence are generated by enumerating each group of repeating digits in the previous term,
So the first few terms are:
1 "one" 11 "one one" (we look at the previous term) 21 "two ones" 1211 "one two, one one" 111221 "one one, one two, two ones" 312211 "three ones, two twos, one one"
Now let's do the same thing, but use Roman Numerals instead. We start with
I and follow the same rules (we apply the digit-counting rule to characters instead, so we read
one one, one five, one ten instead of
one four, one ten or some other way):
I "one" II "one one" III "two ones" = "II" + "I" IIII "three ones" = "III" + "I" IVI "four ones" = "IV" + "I" IIIVII "one one, one five, one one" IIIIIVIII "three ones, one five, two ones" = ("III" + "I") + ("I" + "V") + ("II" + "I")
Given a positive integer
- Output first
Nnumerals of this sequence (any reasonable separator is fine, as well as
["I", "II", "III", ...]
Nth term of this sequence (it may be 0-indexed).
Remember to make your code as short as possible, since this is a code-golf challenge!
EDIT: I believe that there is always one standard/preferred way of expressing integers as roman numerals, (like
XCV instead of
VC). Couple of Roman numeral converters I found online corroborate my opinion. If in doubt, use an online converter, as listing all the possible edge-cases and specific rules of writing Roman numerals is not the point of this challenge.
EDIT2: @PeterTaylor and @GregMartin pointed out that only numbers less or equal to
5 appear in the sequence, so you don't have to worry about the ambiguity of Roman numerals (numbers