This is a problem where the only data structures you need,
other than the integer you are encoding and the string you
are building, is a small number of array literals.
Here is pseudo-code.
If self is negative, emit a negative sign.
If self is zero, emit N and finish.
Let n be the absolute value
Op 18-9-2020 om 16:13 schreef Pablo
Navarro:
Hi! Maybe you can use this algorithm:
Define a dictionary with these elements:
1000:'M',
900:'CM',
500: 'D',
400: 'CD',
Hi! Maybe you can use this algorithm:
Define a dictionary with these elements:
1000:'M',
900:'CM',
500: 'D',
400: 'CD',
100:"C",
90:'XC',
50:'L',
40:'XL',
10:'X',
9:'IX',
5:'V',
4:'IV',
1:'I'
Using this dictionary (romansDic), you define a recursive function:
toRomans(number){
i =
Op 18-9-2020 om 06:45 schreef Richard
O'Keefe:
Roman numerals are
much more complicated and much less consistent
than most people
realise. The regular M DC LX VI system is both
more modern and less
Roman numerals are much more complicated and much less consistent
than most people realise. The regular M DC LX VI system is both
more modern and less capable than anything the Romans would have
recognised. In particular,
- in the 8th century, N (short for "nulla") was adopted for zero
- the
Hello,
The challenge is to do it manually.
But I can take a look how that function is implented.
Roelof
Op 17-9-2020 om 18:13 schreef Aliaksei Syrel:
Hi Roelof,
You will not believe!
Hi Roelof,
You will not believe!
2 printStringRoman “II”
Have fun!
On Thu, 17 Sep 2020 at 18:20, Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:
> Hello,
>
>
>
> Can someone help me with a good plan to convert numbers to roman numbers.
>
>
>
> I could make a dictionary