Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
19
Task/Roman-numerals-Encode/Sidef/roman-numerals-encode.sidef
Normal file
19
Task/Roman-numerals-Encode/Sidef/roman-numerals-encode.sidef
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
func arabic2roman(num, roman='') {
|
||||
static lookup = [
|
||||
:M:1000, :CM:900, :D:500,
|
||||
:CD:400, :C:100, :XC:90,
|
||||
:L:50, :XL:40, :X:10,
|
||||
:IX:9, :V:5, :IV:4,
|
||||
:I:1
|
||||
];
|
||||
lookup.each { |pair|
|
||||
while (num >= pair.second) {
|
||||
roman += pair.first;
|
||||
num -= pair.second;
|
||||
}
|
||||
}
|
||||
return roman;
|
||||
}
|
||||
say("1990 in roman is " + arabic2roman(1990));
|
||||
say("2008 in roman is " + arabic2roman(2008));
|
||||
say("1666 in roman is " + arabic2roman(1666));
|
||||
Loading…
Add table
Add a link
Reference in a new issue