June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
31
Task/Roman-numerals-Encode/Elena/roman-numerals-encode.elena
Normal file
31
Task/Roman-numerals-Encode/Elena/roman-numerals-encode.elena
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import extensions.
|
||||
import system'collections.
|
||||
import system'routines.
|
||||
|
||||
static RomanDictionary = Dictionary new;
|
||||
setAt(1000, "M");
|
||||
setAt(900, "CM");
|
||||
setAt(500, "D");
|
||||
setAt(400, "CD");
|
||||
setAt(100, "C");
|
||||
setAt(90, "XC");
|
||||
setAt(50, "L");
|
||||
setAt(40, "XL");
|
||||
setAt(10, "X");
|
||||
setAt(9, "IX");
|
||||
setAt(5, "V");
|
||||
setAt(4, "IV");
|
||||
setAt(1, "I").
|
||||
|
||||
extension $op
|
||||
{
|
||||
toRoman
|
||||
= RomanDictionary accumulate(String new("I",self)) with(:m:kv)(m replace(String new("I",kv key), kv value)).
|
||||
}
|
||||
|
||||
program =
|
||||
[
|
||||
console printLine("1990 : ", 1990 toRoman).
|
||||
console printLine("2008 : ", 2008 toRoman).
|
||||
console printLine("1666 : ", 1666 toRoman).
|
||||
].
|
||||
Loading…
Add table
Add a link
Reference in a new issue