Challenge description
We've had a few challenges involving the Look-and-say sequence. Quick reminder:
- The sequence starts with
1
, - 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 IVX
as 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 N
, either:
- Output first
N
numerals of this sequence (any reasonable separator is fine, as well as["I", "II", "III", ...]
- Output
N
th 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 95
-> 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 1
- 8
are I
, II
, III
, IV
, V
, VI
, VII
, and VIII
)
4
/IV
/IIII
? Or95
/XCV
/VC
? There might not always be a unique way to express an integer, but I'm pretty sure there's always a preferred (standard) one - correct me if I'm wrong. \$\endgroup\$999
=900+90+9
=CM + XC + IX
=CMXCIX
and notIM
(This is the modern standard form. The romans themselves were not completely consistent). But as noted this is not needed here. \$\endgroup\$