Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Roman-numerals-Encode/Elena/roman-numerals-encode.elena
Normal file
32
Task/Roman-numerals-Encode/Elena/roman-numerals-encode.elena
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import system'collections;
|
||||
import system'routines;
|
||||
import extensions;
|
||||
import extensions'text;
|
||||
|
||||
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(new StringWriter("I", self), (m,kv => m.replace(new StringWriter("I",kv.Key), kv.Value)));
|
||||
}
|
||||
|
||||
public 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